Skip to content

Commit d183bbb

Browse files
committed
Javadoc refinements, exception fine-tuning, general polishing
Issue: SPR-13034
1 parent 2577ac3 commit d183bbb

File tree

13 files changed

+192
-168
lines changed

13 files changed

+192
-168
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import groovy.text.markup.MarkupTemplateEngine;
2020

2121
/**
22-
* Interface to be implemented by objects that configure and manage a
23-
* Groovy MarkupTemplateEngine for automatic lookup in a web environment.
24-
* Detected and used by GroovyMarkupView.
22+
* Interface to be implemented by objects that configure and manage a Groovy
23+
* {@link MarkupTemplateEngine} for automatic lookup in a web environment.
24+
* Detected and used by {@link GroovyMarkupView}.
2525
*
2626
* @author Brian Clozel
2727
* @since 4.1

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@
4646
*
4747
* @Bean
4848
* public GroovyMarkupConfig groovyMarkupConfigurer() {
49-
*
5049
* GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
5150
* configurer.setResourceLoaderPath("classpath:/WEB-INF/groovymarkup/");
5251
* return configurer;

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupView.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,8 +35,7 @@
3535
import org.springframework.web.util.NestedServletException;
3636

3737
/**
38-
* An {@link org.springframework.web.servlet.view.AbstractTemplateView AbstractTemplateView}
39-
* based on Groovy XML/XHTML markup templates.
38+
* An {@link AbstractTemplateView} subclass based on Groovy XML/XHTML markup templates.
4039
*
4140
* <p>Spring's Groovy Markup Template support requires Groovy 2.3.1 and higher.
4241
*

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,10 +21,9 @@
2121
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
2222

2323
/**
24-
* Convenience subclass of
25-
* {@link org.springframework.web.servlet.view.AbstractTemplateViewResolver}
26-
* that supports {@link GroovyMarkupView} (i.e. Groovy XML/XHTML markup templates)
27-
* and custom subclasses of it.
24+
* Convenience subclass of @link AbstractTemplateViewResolver} that supports
25+
* {@link GroovyMarkupView} (i.e. Groovy XML/XHTML markup templates) and
26+
* custom subclasses of it.
2827
*
2928
* <p>The view class for all views created by this resolver can be specified
3029
* via the {@link #setViewClass(Class)} property.

spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Support classes for the integration of
3-
* <a href="http://beta.groovy-lang.org/docs/groovy-2.3.0/html/documentation/markup-template-engine.html">
3+
* <a href="http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_the_markuptemplateengine">
44
* Groovy Templates</a> as Spring web view technology.
55
* Contains a View implementation for Groovy templates.
66
*/

spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateConfig.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,53 @@
2121

2222
/**
2323
* Interface to be implemented by objects that configure and manage a
24-
* {@link ScriptEngine} for automatic lookup in a web environment.
24+
* JSR-223 {@link ScriptEngine} for automatic lookup in a web environment.
2525
* Detected and used by {@link ScriptTemplateView}.
2626
*
2727
* @author Sebastien Deleuze
2828
* @since 4.2
2929
*/
3030
public interface ScriptTemplateConfig {
3131

32+
/**
33+
* Return the {@link ScriptEngine} to use by the views.
34+
*/
3235
ScriptEngine getEngine();
3336

37+
/**
38+
* Return the engine name that will be used to instantiate the {@link ScriptEngine}.
39+
*/
3440
String getEngineName();
3541

42+
/**
43+
* Return whether to use a shared engine for all threads or whether to create
44+
* thread-local engine instances for each thread.
45+
*/
46+
Boolean isSharedEngine();
47+
48+
/**
49+
* Return the scripts to be loaded by the script engine (library or user provided).
50+
*/
3651
String[] getScripts();
3752

53+
/**
54+
* Return the object where the render function belongs (optional).
55+
*/
3856
String getRenderObject();
3957

58+
/**
59+
* Return the render function name (mandatory).
60+
*/
4061
String getRenderFunction();
4162

63+
/**
64+
* Return the charset used to read script and template files.
65+
*/
4266
Charset getCharset();
4367

68+
/**
69+
* Return the resource loader path(s) via a Spring resource location.
70+
*/
4471
String getResourceLoaderPath();
4572

46-
Boolean isShareEngine();
47-
4873
}

spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateConfigurer.java

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.web.servlet.view.script;
1818

1919
import java.nio.charset.Charset;
20-
2120
import javax.script.ScriptEngine;
2221

2322
/**
@@ -40,9 +39,9 @@
4039
* }
4140
* </pre>
4241
*
43-
* <p>It is possible to use non thread-safe script engines and templating libraries, like
44-
* Handlebars or React running on Nashorn, by setting the
45-
* {@link #setSharedEngine(Boolean) sharedEngine} property to {@code false}.
42+
* <p><b>NOTE:</b> It is possible to use non thread-safe script engines and
43+
* templating libraries, like Handlebars or React running on Nashorn, by setting
44+
* the {@link #setSharedEngine sharedEngine} property to {@code false}.
4645
*
4746
* @author Sebastien Deleuze
4847
* @since 4.2
@@ -54,6 +53,8 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
5453

5554
private String engineName;
5655

56+
private Boolean sharedEngine;
57+
5758
private String[] scripts;
5859

5960
private String renderObject;
@@ -64,17 +65,14 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
6465

6566
private String resourceLoaderPath;
6667

67-
private Boolean sharedEngine;
6868

6969
/**
7070
* Set the {@link ScriptEngine} to use by the view.
7171
* The script engine must implement {@code Invocable}.
7272
* You must define {@code engine} or {@code engineName}, not both.
73-
*
7473
* <p>When the {@code sharedEngine} flag is set to {@code false}, you should not specify
7574
* the script engine with this setter, but with the {@link #setEngineName(String)}
76-
* one (since it implies multiple lazy instanciations of the script engine).
77-
*
75+
* one (since it implies multiple lazy instantiations of the script engine).
7876
* @see #setEngineName(String)
7977
*/
8078
public void setEngine(ScriptEngine engine) {
@@ -101,17 +99,35 @@ public String getEngineName() {
10199
return this.engineName;
102100
}
103101

102+
/**
103+
* When set to {@code false}, use thread-local {@link ScriptEngine} instances instead
104+
* of one single shared instance. This flag should be set to {@code false} for those
105+
* using non thread-safe script engines and templating libraries, like Handlebars or
106+
* React running on Nashorn for example.
107+
* <p>When this flag is set to {@code false}, the script engine must be specified using
108+
* {@link #setEngineName(String)}. Using {@link #setEngine(ScriptEngine)} is not
109+
* possible because multiple instances of the script engine need to be created lazily
110+
* (one per thread).
111+
* @see <a href="http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-">THREADING ScriptEngine parameter<a/>
112+
*/
113+
public void setSharedEngine(Boolean sharedEngine) {
114+
this.sharedEngine = sharedEngine;
115+
}
116+
117+
@Override
118+
public Boolean isSharedEngine() {
119+
return this.sharedEngine;
120+
}
121+
104122
/**
105123
* Set the scripts to be loaded by the script engine (library or user provided).
106124
* Since {@code resourceLoaderPath} default value is "classpath:", you can load easily
107125
* any script available on the classpath.
108-
*
109-
* For example, in order to use a Javascript library available as a WebJars dependency
126+
* <p>For example, in order to use a JavaScript library available as a WebJars dependency
110127
* and a custom "render.js" file, you should call
111128
* {@code configurer.setScripts("/META-INF/resources/webjars/library/version/library.js",
112129
* "com/myproject/script/render.js");}.
113-
*
114-
* @see #setResourceLoaderPath(String)
130+
* @see #setResourceLoaderPath
115131
* @see <a href="http://www.webjars.org">WebJars</a>
116132
*/
117133
public void setScripts(String... scriptNames) {
@@ -124,7 +140,7 @@ public String[] getScripts() {
124140
}
125141

126142
/**
127-
* Set the object where belongs the render function (optional).
143+
* Set the object where the render function belongs (optional).
128144
* For example, in order to call {@code Mustache.render()}, {@code renderObject}
129145
* should be set to {@code "Mustache"} and {@code renderFunction} to {@code "render"}.
130146
*/
@@ -138,11 +154,11 @@ public String getRenderObject() {
138154
}
139155

140156
/**
141-
* Set the render function name (mandatory). This function will be called with the
142-
* following parameters:
157+
* Set the render function name (mandatory).
158+
* This function will be called with the following parameters:
143159
* <ol>
144-
* <li>{@code template}: the view template content (String)</li>
145-
* <li>{@code model}: the view model (Map)</li>
160+
* <li>{@code template}: the view template content (String)</li>
161+
* <li>{@code model}: the view model (Map)</li>
146162
* </ol>
147163
*/
148164
public void setRenderFunction(String renderFunction) {
@@ -173,7 +189,7 @@ public Charset getCharset() {
173189
* Standard URLs like "file:" and "classpath:" and pseudo URLs are supported
174190
* as understood by Spring's {@link org.springframework.core.io.ResourceLoader}.
175191
* Relative paths are allowed when running in an ApplicationContext.
176-
* Default is "classpath:".
192+
* <p>Default is "classpath:".
177193
*/
178194
public void setResourceLoaderPath(String resourceLoaderPath) {
179195
this.resourceLoaderPath = resourceLoaderPath;
@@ -184,25 +200,4 @@ public String getResourceLoaderPath() {
184200
return this.resourceLoaderPath;
185201
}
186202

187-
/**
188-
* When set to {@code false}, use thread-local {@link ScriptEngine} instances instead
189-
* of one single shared instance. This flag should be set to {@code false} for those
190-
* using non thread-safe script engines and templating libraries, like Handlebars or
191-
* React running on Nashorn for example.
192-
*
193-
* <p>When this flag is set to {@code false}, the script engine must be specified using
194-
* {@link #setEngineName(String)}. Using {@link #setEngine(ScriptEngine)} is not
195-
* possible because multiple instances of the script engine need to be created lazily
196-
* (one per thread).
197-
* @see <a href="http://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngineFactory.html#getParameter-java.lang.String-">THREADING ScriptEngine parameter<a/>
198-
*/
199-
public void setSharedEngine(Boolean sharedEngine) {
200-
this.sharedEngine = sharedEngine;
201-
}
202-
203-
@Override
204-
public Boolean isShareEngine() {
205-
return this.sharedEngine;
206-
}
207-
208203
}

0 commit comments

Comments
 (0)