From 3c726aa6c17f7fb8b772aa710ea2a5b3f4d268e0 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 9 Jul 2014 21:24:59 +0200 Subject: [PATCH] Polishing --- .../client/MockAsyncClientHttpRequest.java | 2 +- .../view/groovy/GroovyMarkupConfig.java | 10 +++--- .../view/groovy/GroovyMarkupConfigurer.java | 36 +++++++------------ .../servlet/view/groovy/GroovyMarkupView.java | 26 +++++--------- .../view/groovy/GroovyMarkupViewResolver.java | 8 ++--- .../WebSocketScopeConfiguration.java | 5 +-- 6 files changed, 34 insertions(+), 53 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java index d44e045bf56..bfe609dec7d 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java @@ -36,7 +36,6 @@ import org.springframework.util.concurrent.SettableListenableFuture; */ public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements AsyncClientHttpRequest { - public MockAsyncClientHttpRequest() { } @@ -44,6 +43,7 @@ public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements super(httpMethod, uri); } + @Override public ListenableFuture executeAsync() throws IOException { SettableListenableFuture future = new SettableListenableFuture(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfig.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfig.java index 6404a0d4f7a..fda4abc09b0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfig.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfig.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.view.groovy; import groovy.text.markup.MarkupTemplateEngine; @@ -23,15 +24,16 @@ import groovy.text.markup.MarkupTemplateEngine; * Detected and used by GroovyMarkupView. * * @author Brian Clozel - * @see GroovyMarkupConfigurer * @since 4.1 + * @see GroovyMarkupConfigurer */ public interface GroovyMarkupConfig { /** - * Return the Groovy MarkupTemplateEngine for the current web application context. - * May be unique to one servlet, or shared in the root context. - * @return the Groovy Template engine + * Return the Groovy {@link MarkupTemplateEngine} for the current + * web application context. May be unique to one servlet, or shared + * in the root context. + * @return the Groovy MarkupTemplateEngine engine */ MarkupTemplateEngine getTemplateEngine(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java index 9e666ad44bc..b85c92219f0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.view.groovy; import java.io.IOException; @@ -26,7 +27,6 @@ import groovy.text.markup.MarkupTemplateEngine; import groovy.text.markup.TemplateConfiguration; import groovy.text.markup.TemplateResolver; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -55,9 +55,9 @@ import org.springframework.util.StringUtils; * * By default this bean will create a {@link MarkupTemplateEngine} with: *
    - *
  • a parent ClassLoader for loading Groovy templates with their references - *
  • the default configuration in the base class {@link TemplateConfiguration} - *
  • a {@link groovy.text.markup.TemplateResolver} for resolving template files + *
  • a parent ClassLoader for loading Groovy templates with their references + *
  • the default configuration in the base class {@link TemplateConfiguration} + *
  • a {@link groovy.text.markup.TemplateResolver} for resolving template files *
* * You can provide the {@link MarkupTemplateEngine} instance directly to this bean @@ -78,7 +78,6 @@ import org.springframework.util.StringUtils; * @author Brian Clozel * @author Rossen Stoyanchev * @since 4.1 - * * @see GroovyMarkupView * @see * Groovy Markup Template engine documentation @@ -119,15 +118,12 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration this.templateEngine = templateEngine; } - /** - * {@inheritDoc} - */ public MarkupTemplateEngine getTemplateEngine() { return templateEngine; } @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } @@ -161,8 +157,8 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration } /** - * Create a parent classloader for Groovy to use as parent classloader when - * loading and compiling templates. + * Create a parent ClassLoader for Groovy to use as parent ClassLoader + * when loading and compiling templates. */ protected ClassLoader createTemplateClassLoader() throws IOException { String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath()); @@ -183,20 +179,11 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration /** * Resolve a template from the given template path. - * - *

The default implementation uses the Locale associated with the current - * request, as obtained through - * {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder}, - * to find the template file. Effectively the locale configured at the engine - * level is ignored. - * + *

The default implementation uses the Locale associated with the current request, + * as obtained through {@link org.springframework.context.i18n.LocaleContextHolder LocaleContextHolder}, + * to find the template file. Effectively the locale configured at the engine level is ignored. * @see LocaleContextHolder - * @see #setLocale(java.util.Locale) - * - * @param classLoader - * @param templatePath - * @return - * @throws IOException + * @see #setLocale */ protected URL resolveTemplate(ClassLoader classLoader, String templatePath) throws IOException { MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(templatePath); @@ -233,4 +220,5 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration return GroovyMarkupConfigurer.this.resolveTemplate(this.classLoader, templatePath); } } + } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupView.java index 05859b99cf7..cd8d1b74979 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupView.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.view.groovy; import java.io.BufferedWriter; import java.io.IOException; import java.util.Locale; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -43,7 +43,6 @@ import org.springframework.web.util.NestedServletException; * @author Brian Clozel * @author Rossen Stoyanchev * @since 4.1 - * * @see GroovyMarkupViewResolver * @see GroovyMarkupConfigurer * @see @@ -56,20 +55,15 @@ public class GroovyMarkupView extends AbstractTemplateView { /** * Set the MarkupTemplateEngine to use in this view. - * *

If not set, the engine is auto-detected by looking up up a single * {@link GroovyMarkupConfig} bean in the web application context and using * it to obtain the configured {@code MarkupTemplateEngine} instance. - * * @see GroovyMarkupConfig */ public void setTemplateEngine(MarkupTemplateEngine engine) { this.engine = engine; } - /** - * {@inheritDoc} - */ @Override public boolean checkResource(Locale locale) throws Exception { try { @@ -86,7 +80,6 @@ public class GroovyMarkupView extends AbstractTemplateView { * If no {@link #setTemplateEngine(MarkupTemplateEngine) templateEngine} has * been manually set, this method looks up a {@link GroovyMarkupConfig} bean * by type and uses it to obtain the Groovy Markup template engine. - * * @see GroovyMarkupConfig * @see #setTemplateEngine(groovy.text.markup.MarkupTemplateEngine) */ @@ -99,7 +92,7 @@ public class GroovyMarkupView extends AbstractTemplateView { } /** - * Auto-detect a MarkupTemplateEngine via the ApplicationContext. + * Autodetect a MarkupTemplateEngine via the ApplicationContext. * Called if a MarkupTemplateEngine has not been manually configured. */ protected MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException { @@ -108,13 +101,13 @@ public class GroovyMarkupView extends AbstractTemplateView { GroovyMarkupConfig.class, true, false).getTemplateEngine(); } catch (NoSuchBeanDefinitionException ex) { - throw new ApplicationContextException( - "Expected a single GroovyMarkupConfig bean in the current Servlet web application context " + - "or the parent root context: GroovyMarkupConfigurer is the usual implementation. " + - "This bean may have any name.", ex); + throw new ApplicationContextException("Expected a single GroovyMarkupConfig bean in the current " + + "Servlet web application context or the parent root context: GroovyMarkupConfigurer is " + + "the usual implementation. This bean may have any name.", ex); } } + @Override protected void renderMergedTemplateModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -132,10 +125,9 @@ public class GroovyMarkupView extends AbstractTemplateView { return this.engine.createTemplateByPath(viewUrl); } catch (ClassNotFoundException ex) { - Throwable cause = ex.getCause() != null ? ex.getCause() : ex; - throw new NestedServletException( - "Could not find class while rendering Groovy Markup view with name '" + - getUrl() + "': " + ex.getMessage() + "'", cause); + Throwable cause = (ex.getCause() != null ? ex.getCause() : ex); + throw new NestedServletException("Could not find class while rendering Groovy Markup view with name '" + + getUrl() + "': " + ex.getMessage() + "'", cause); } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java index b37396a7ca6..e1b4bb98c43 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolver.java @@ -34,17 +34,15 @@ import org.springframework.web.servlet.view.AbstractTemplateViewResolver; * View object if a template is actually found. * * @author Brian Clozel - * @see GroovyMarkupConfigurer * @since 4.1 + * @see GroovyMarkupConfigurer */ public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver { - public GroovyMarkupViewResolver() { - this.setViewClass(requiredViewClass()); + setViewClass(requiredViewClass()); } - @Override protected Class requiredViewClass() { return GroovyMarkupView.class; @@ -58,4 +56,4 @@ public class GroovyMarkupViewResolver extends AbstractTemplateViewResolver { return viewName + "_" + locale; } -} \ No newline at end of file +} diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketScopeConfiguration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketScopeConfiguration.java index 66b75824d3a..f17ced513c5 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketScopeConfiguration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketScopeConfiguration.java @@ -16,13 +16,14 @@ package org.springframework.web.socket.config.annotation; +import java.util.Collections; + import org.springframework.beans.factory.config.CustomScopeConfigurer; import org.springframework.context.annotation.Bean; import org.springframework.messaging.simp.SimpSessionScope; -import java.util.Collections; - /** + * Bean configuration for a "websocket" scope, bound to {@link SimpSessionScope}. * * @author Rossen Stoyanchev * @since 4.1