From 92bd240474fccfa7fd32e9a7707f628a846ac3cc Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Aug 2014 15:04:58 +0200 Subject: [PATCH] Polishing Issue: SPR-12079 --- .../support/WebApplicationObjectSupport.java | 15 ++++---- .../view/ResourceBundleViewResolver.java | 34 +++++++++---------- .../web/servlet/view/XmlViewResolver.java | 26 +++++++------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.java b/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.java index b333d592799..1764b6ced99 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationObjectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,16 +26,19 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.util.WebUtils; /** - * Convenient superclass for application objects running in a WebApplicationContext. - * Provides {@code getWebApplicationContext()}, {@code getServletContext()}, - * and {@code getTempDir()} methods. + * Convenient superclass for application objects running in a {@link WebApplicationContext}. + * Provides {@code getWebApplicationContext()}, {@code getServletContext()}, and + * {@code getTempDir()} accessors. + * + *

Note: It is generally recommended to use individual callback interfaces for the actual + * callbacks needed. This broad base class is primarily intended for use within the framework, + * in case of {@link ServletContext} access etc typically being needed. * * @author Juergen Hoeller * @since 28.08.2003 * @see SpringBeanAutowiringSupport */ -public abstract class WebApplicationObjectSupport extends ApplicationObjectSupport - implements ServletContextAware { +public abstract class WebApplicationObjectSupport extends ApplicationObjectSupport implements ServletContextAware { private ServletContext servletContext; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java index c4db9cc6c60..78731a71b5b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java @@ -36,24 +36,22 @@ import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.servlet.View; /** - * {@link org.springframework.web.servlet.ViewResolver} implementation - * that uses bean definitions in a {@link ResourceBundle}, specified by - * the bundle basename. + * A {@link org.springframework.web.servlet.ViewResolver} implementation that uses + * bean definitions in a {@link ResourceBundle}, specified by the bundle basename. * - *

The bundle is typically defined in a properties file, located in - * the class path. The default bundle basename is "views". + *

The bundle is typically defined in a properties file, located in the classpath. + * The default bundle basename is "views". * - *

This {@code ViewResolver} supports localized view definitions, - * using the default support of {@link java.util.PropertyResourceBundle}. - * For example, the basename "views" will be resolved as class path resources - * "views_de_AT.properties", "views_de.properties", "views.properties" - - * for a given Locale "de_AT". + *

This {@code ViewResolver} supports localized view definitions, using the + * default support of {@link java.util.PropertyResourceBundle}. For example, the + * basename "views" will be resolved as class path resources "views_de_AT.properties", + * "views_de.properties", "views.properties" - for a given Locale "de_AT". * - *

Note: this {@code ViewResolver} implements the {@link Ordered} - * interface to allow for flexible participation in {@code ViewResolver} - * chaining. For example, some special views could be defined via this - * {@code ViewResolver} (giving it 0 as "order" value), while all - * remaining views could be resolved by a {@link UrlBasedViewResolver}. + *

Note: This {@code ViewResolver} implements the {@link Ordered} interface + * in order to allow for flexible participation in {@code ViewResolver} chaining. + * For example, some special views could be defined via this {@code ViewResolver} + * (giving it 0 as "order" value), while all remaining views could be resolved by + * a {@link UrlBasedViewResolver}. * * @author Rod Johnson * @author Juergen Hoeller @@ -110,7 +108,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver * @see java.util.ResourceBundle#getBundle(String) */ public void setBasename(String basename) { - setBasenames(new String[] {basename}); + setBasenames(basename); } /** @@ -173,7 +171,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver *

Allows for pre-initialization of common Locales, eagerly checking * the view configuration for those Locales. */ - public void setLocalesToInitialize(Locale[] localesToInitialize) { + public void setLocalesToInitialize(Locale... localesToInitialize) { this.localesToInitialize = localesToInitialize; } @@ -198,7 +196,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver return factory.getBean(viewName, View.class); } catch (NoSuchBeanDefinitionException ex) { - // to allow for ViewResolver chaining + // Allow for ViewResolver chaining... return null; } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java index 67f3ac5192c..2dff2547930 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java @@ -32,18 +32,20 @@ import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.servlet.View; /** - * Implementation of ViewResolver that uses bean definitions in an - * XML file, specified by resource location. The file will typically - * be located in the WEB-INF directory; default is "/WEB-INF/views.xml". + * A {@link org.springframework.web.servlet.ViewResolver} implementation that uses + * bean definitions in a dedicated XML file for view definitions, specified by + * resource location. The file will typically be located in the WEB-INF directory; + * the default is "/WEB-INF/views.xml". * - *

This ViewResolver does not support internationalization. - * Consider ResourceBundleViewResolver if you need to apply - * different view resources per locale. + *

This {@code ViewResolver} does not support internationalization at the level + * of its definition resources. Consider {@link ResourceBundleViewResolver} if you + * need to apply different view resources per locale. * - *

Note: This ViewResolver implements the Ordered interface to allow for - * flexible participation in ViewResolver chaining. For example, some special - * views could be defined via this ViewResolver (giving it 0 as "order" value), - * while all remaining views could be resolved by a UrlBasedViewResolver. + *

Note: This {@code ViewResolver} implements the {@link Ordered} interface + * in order to allow for flexible participation in {@code ViewResolver} chaining. + * For example, some special views could be defined via this {@code ViewResolver} + * (giving it 0 as "order" value), while all remaining views could be resolved by + * a {@link UrlBasedViewResolver}. * * @author Juergen Hoeller * @since 18.06.2003 @@ -71,7 +73,7 @@ public class XmlViewResolver extends AbstractCachingViewResolver @Override public int getOrder() { - return order; + return this.order; } /** @@ -111,7 +113,7 @@ public class XmlViewResolver extends AbstractCachingViewResolver return factory.getBean(viewName, View.class); } catch (NoSuchBeanDefinitionException ex) { - // to allow for ViewResolver chaining + // Allow for ViewResolver chaining... return null; } }