From c8cc8b7cbd3d704f232e3e9b7d7c867b923f9dfb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 24 Mar 2015 21:21:18 +0100 Subject: [PATCH] Removed outdated references to Servlet 2.3/2.4 (cherry picked from commit 673dac5) --- .../support/OpenSessionInViewFilter.java | 5 ++-- .../support/OpenSessionInViewFilter.java | 5 ++-- .../OpenPersistenceManagerInViewFilter.java | 23 +++++++++++++++++-- .../OpenEntityManagerInViewFilter.java | 8 +++---- .../DestructionCallbackBindingListener.java | 6 ++--- .../request/RequestContextListener.java | 4 ++-- ...ServletContextResourcePatternResolver.java | 6 ++--- .../web/filter/CharacterEncodingFilter.java | 19 +++++++-------- .../web/filter/DelegatingFilterProxy.java | 14 +++++------ .../web/filter/OncePerRequestFilter.java | 10 ++++++-- .../web/filter/RequestContextFilter.java | 5 ++-- .../multipart/support/MultipartFilter.java | 4 ++-- .../web/util/HttpSessionMutexListener.java | 8 +++---- .../web/servlet/HandlerInterceptor.java | 2 +- .../servlet/view/AbstractTemplateView.java | 8 +++---- 15 files changed, 76 insertions(+), 51 deletions(-) diff --git a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java index ff77e37cae..88f0573aeb 100644 --- a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java +++ b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -38,7 +38,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.filter.OncePerRequestFilter; /** - * Servlet 2.3 Filter that binds a Hibernate Session to the thread for the entire + * Servlet Filter that binds a Hibernate Session to the thread for the entire * processing of the request. Intended for the "Open Session in View" pattern, * i.e. to allow for lazy loading in web views despite the original transactions * already being completed. @@ -98,6 +98,7 @@ public class OpenSessionInViewFilter extends OncePerRequestFilter { return this.sessionFactoryBeanName; } + /** * Returns "false" so that the filter may re-bind the opened Hibernate * {@code Session} to each asynchronously dispatched thread and postpone diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java index 6a059c3a0c..72e15aaa52 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -38,7 +38,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.filter.OncePerRequestFilter; /** - * Servlet 2.3 Filter that binds a Hibernate Session to the thread for the entire + * Servlet Filter that binds a Hibernate Session to the thread for the entire * processing of the request. Intended for the "Open Session in View" pattern, * i.e. to allow for lazy loading in web views despite the original transactions * already being completed. @@ -164,6 +164,7 @@ public class OpenSessionInViewFilter extends OncePerRequestFilter { return this.flushMode; } + /** * Returns "false" so that the filter may re-bind the opened Hibernate * {@code Session} to each asynchronously dispatched thread and postpone diff --git a/spring-orm/src/main/java/org/springframework/orm/jdo/support/OpenPersistenceManagerInViewFilter.java b/spring-orm/src/main/java/org/springframework/orm/jdo/support/OpenPersistenceManagerInViewFilter.java index b71d0cfbf0..1a3a114c78 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jdo/support/OpenPersistenceManagerInViewFilter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jdo/support/OpenPersistenceManagerInViewFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -32,7 +32,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.filter.OncePerRequestFilter; /** - * Servlet 2.3 Filter that binds a JDO PersistenceManager to the thread for the + * Servlet Filter that binds a JDO PersistenceManager to the thread for the * entire processing of the request. Intended for the "Open PersistenceManager in * View" pattern, i.e. to allow for lazy loading in web views despite the * original transactions already being completed. @@ -79,6 +79,25 @@ public class OpenPersistenceManagerInViewFilter extends OncePerRequestFilter { } + /** + * Returns "false" so that the filter may re-bind the opened {@code PersistenceManager} + * to each asynchronously dispatched thread and postpone closing it until the very + * last asynchronous dispatch. + */ + @Override + protected boolean shouldNotFilterAsyncDispatch() { + return false; + } + + /** + * Returns "false" so that the filter may provide an {@code PersistenceManager} + * to each error dispatches. + */ + @Override + protected boolean shouldNotFilterErrorDispatch() { + return false; + } + @Override protected void doFilterInternal( HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter.java index e56ce874dd..c69d69b4af 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewFilter.java @@ -37,7 +37,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.filter.OncePerRequestFilter; /** - * Servlet 2.3 Filter that binds a JPA EntityManager to the thread for the + * Servlet Filter that binds a JPA EntityManager to the thread for the * entire processing of the request. Intended for the "Open EntityManager in * View" pattern, i.e. to allow for lazy loading in web views despite the * original transactions already being completed. @@ -122,9 +122,9 @@ public class OpenEntityManagerInViewFilter extends OncePerRequestFilter { /** - * Returns "false" so that the filter may re-bind the opened - * {@code EntityManager} to each asynchronously dispatched thread and postpone - * closing it until the very last asynchronous dispatch. + * Returns "false" so that the filter may re-bind the opened {@code EntityManager} + * to each asynchronously dispatched thread and postpone closing it until the very + * last asynchronous dispatch. */ @Override protected boolean shouldNotFilterAsyncDispatch() { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/DestructionCallbackBindingListener.java b/spring-web/src/main/java/org/springframework/web/context/request/DestructionCallbackBindingListener.java index f1467553b8..660172f903 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/DestructionCallbackBindingListener.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/DestructionCallbackBindingListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -21,8 +21,8 @@ import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; /** - * Adapter that implements the Servlet 2.3 HttpSessionBindingListener - * interface, wrapping a session destruction callback. + * Adapter that implements the Servlet HttpSessionBindingListener interface, + * wrapping a session destruction callback. * * @author Juergen Hoeller * @since 3.0 diff --git a/spring-web/src/main/java/org/springframework/web/context/request/RequestContextListener.java b/spring-web/src/main/java/org/springframework/web/context/request/RequestContextListener.java index 8a6098c605..5739f09e75 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/RequestContextListener.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/RequestContextListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.context.i18n.LocaleContextHolder; /** - * Servlet 2.4+ listener that exposes the request to the current thread, + * Servlet listener that exposes the request to the current thread, * through both {@link org.springframework.context.i18n.LocaleContextHolder} and * {@link RequestContextHolder}. To be registered as listener in {@code web.xml}. * diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java index ca457f2380..e33a0928a7 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -37,8 +37,8 @@ import org.springframework.util.StringUtils; /** * ServletContext-aware subclass of {@link PathMatchingResourcePatternResolver}, * able to find matching resources below the web application root directory - * via Servlet 2.3's {@code ServletContext.getResourcePaths}. - * Falls back to the superclass' file system checking for other resources. + * via {@link ServletContext#getResourcePaths}. Falls back to the superclass' + * file system checking for other resources. * * @author Juergen Hoeller * @since 1.1.2 diff --git a/spring-web/src/main/java/org/springframework/web/filter/CharacterEncodingFilter.java b/spring-web/src/main/java/org/springframework/web/filter/CharacterEncodingFilter.java index c1ccfdd278..ece091f794 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/CharacterEncodingFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/CharacterEncodingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2015 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. @@ -23,15 +23,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Servlet 2.3/2.4 Filter that allows one to specify a character encoding for - * requests. This is useful because current browsers typically do not set a - * character encoding even if specified in the HTML page or form. + * Servlet Filter that allows one to specify a character encoding for requests. + * This is useful because current browsers typically do not set a character + * encoding even if specified in the HTML page or form. * - *

This filter can either apply its encoding if the request does not - * already specify an encoding, or enforce this filter's encoding in any case + *

This filter can either apply its encoding if the request does not already + * specify an encoding, or enforce this filter's encoding in any case * ("forceEncoding"="true"). In the latter case, the encoding will also be - * applied as default response encoding on Servlet 2.4+ containers (although - * this will usually be overridden by a full content type set in the view). + * applied as default response encoding (although this will usually be overridden + * by a full content type set in the view). * * @author Juergen Hoeller * @since 15.03.2004 @@ -65,9 +65,6 @@ public class CharacterEncodingFilter extends OncePerRequestFilter { * {@link javax.servlet.http.HttpServletRequest#getCharacterEncoding()} * returns a non-null value. Switch this to "true" to enforce the specified * encoding in any case, applying it as default response encoding as well. - *

Note that the response encoding will only be set on Servlet 2.4+ - * containers, since Servlet 2.3 did not provide a facility for setting - * a default response encoding. */ public void setForceEncoding(boolean forceEncoding) { this.forceEncoding = forceEncoding; diff --git a/spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java b/spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java index 3ed0e08877..47899bef01 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java +++ b/spring-web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -29,16 +29,16 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; /** - * Proxy for a standard Servlet 2.3 Filter, delegating to a Spring-managed - * bean that implements the Filter interface. Supports a "targetBeanName" - * filter init-param in {@code web.xml}, specifying the name of the - * target bean in the Spring application context. + * Proxy for a standard Servlet Filter, delegating to a Spring-managed bean that + * implements the Filter interface. Supports a "targetBeanName" filter init-param + * in {@code web.xml}, specifying the name of the target bean in the Spring + * application context. * *

{@code web.xml} will usually contain a {@code DelegatingFilterProxy} definition, * with the specified {@code filter-name} corresponding to a bean name in * Spring's root application context. All calls to the filter proxy will then * be delegated to that bean in the Spring context, which is required to implement - * the standard Servlet 2.3 Filter interface. + * the standard Servlet Filter interface. * *

This approach is particularly useful for Filter implementation with complex * setup needs, allowing to apply the full Spring bean definition machinery to @@ -183,7 +183,7 @@ public class DelegatingFilterProxy extends GenericFilterBean { /** * Set the name of the target bean in the Spring application context. - * The target bean must implement the standard Servlet 2.3 Filter interface. + * The target bean must implement the standard Servlet Filter interface. *

By default, the {@code filter-name} as specified for the * DelegatingFilterProxy in {@code web.xml} will be used. */ diff --git a/spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java b/spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java index db7fc15216..366912374e 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/OncePerRequestFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -113,11 +113,12 @@ public abstract class OncePerRequestFilter extends GenericFilterBean { } } + private boolean skipDispatch(HttpServletRequest request) { if (isAsyncDispatch(request) && shouldNotFilterAsyncDispatch()) { return true; } - if ((request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null) && shouldNotFilterErrorDispatch()) { + if (request.getAttribute(WebUtils.ERROR_REQUEST_URI_ATTRIBUTE) != null && shouldNotFilterErrorDispatch()) { return true; } return false; @@ -129,6 +130,7 @@ public abstract class OncePerRequestFilter extends GenericFilterBean { * the course of a single request. This method returns {@code true} if the * filter is currently executing within an asynchronous dispatch. * @param request the current request + * @since 3.2 * @see WebAsyncManager#hasConcurrentResult() */ protected boolean isAsyncDispatch(HttpServletRequest request) { @@ -139,6 +141,7 @@ public abstract class OncePerRequestFilter extends GenericFilterBean { * Whether request processing is in asynchronous mode meaning that the * response will not be committed after the current thread is exited. * @param request the current request + * @since 3.2 * @see WebAsyncManager#isConcurrentHandlingStarted() */ protected boolean isAsyncStarted(HttpServletRequest request) { @@ -189,6 +192,7 @@ public abstract class OncePerRequestFilter extends GenericFilterBean { * invoked during subsequent async dispatches. If "false", the filter will * be invoked during async dispatches with the same guarantees of being * invoked only once during a request within a single thread. + * @since 3.2 */ protected boolean shouldNotFilterAsyncDispatch() { return true; @@ -199,11 +203,13 @@ public abstract class OncePerRequestFilter extends GenericFilterBean { * processes and error mapped in {@code web.xml}. The default return value * is "true", which means the filter will not be invoked in case of an error * dispatch. + * @since 3.2 */ protected boolean shouldNotFilterErrorDispatch() { return true; } + /** * Same contract as for {@code doFilter}, but guaranteed to be * just invoked once per request within a single request thread. diff --git a/spring-web/src/main/java/org/springframework/web/filter/RequestContextFilter.java b/spring-web/src/main/java/org/springframework/web/filter/RequestContextFilter.java index 173083d56c..c5925e5e90 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/RequestContextFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/RequestContextFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -27,7 +27,7 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; /** - * Servlet 2.3 Filter that exposes the request to the current thread, + * Servlet Filter that exposes the request to the current thread, * through both {@link org.springframework.context.i18n.LocaleContextHolder} and * {@link RequestContextHolder}. To be registered as filter in {@code web.xml}. * @@ -68,6 +68,7 @@ public class RequestContextFilter extends OncePerRequestFilter { this.threadContextInheritable = threadContextInheritable; } + /** * Returns "false" so that the filter may set up the request context in each * asynchronously dispatched thread. diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java index db70bfae0d..b9ac26ed9c 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -29,7 +29,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartResolver; /** - * Servlet 2.3 Filter that resolves multipart requests via a MultipartResolver. + * Servlet Filter that resolves multipart requests via a {@link MultipartResolver}. * in the root web application context. * *

Looks up the MultipartResolver in Spring's root web application context. diff --git a/spring-web/src/main/java/org/springframework/web/util/HttpSessionMutexListener.java b/spring-web/src/main/java/org/springframework/web/util/HttpSessionMutexListener.java index 319c4b7ec9..2d940b4aa3 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HttpSessionMutexListener.java +++ b/spring-web/src/main/java/org/springframework/web/util/HttpSessionMutexListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 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. @@ -21,9 +21,9 @@ import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; /** - * Servlet 2.3 HttpSessionListener that automatically exposes the - * session mutex when an HttpSession gets created. - * To be registered as a listener in {@code web.xml}. + * Servlet HttpSessionListener that automatically exposes the session mutex + * when an HttpSession gets created. To be registered as a listener in + * {@code web.xml}. * *

The session mutex is guaranteed to be the same object during * the entire lifetime of the session, available under the key defined diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java index efaacd335b..2aa28d5dfb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java @@ -48,7 +48,7 @@ import org.springframework.web.method.HandlerMethod; * in the application context, referenced by the mapping bean definition * via its "interceptors" property (in XML: a <list> of <ref>). * - *

HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in + *

HandlerInterceptor is basically similar to a Servlet Filter, but in * contrast to the latter it just allows custom pre-processing with the option * of prohibiting the execution of the handler itself, and custom post-processing. * Filters are more powerful, for example they allow for exchanging the request diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractTemplateView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractTemplateView.java index d8db4d4e3e..f1d6e37d3d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractTemplateView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractTemplateView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2015 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. @@ -170,9 +170,9 @@ public abstract class AbstractTemplateView extends AbstractUrlBasedView { /** * Apply this view's content type as specified in the "contentType" * bean property to the given response. - *

When running on Servlet 2.4, only applies the view's contentType - * if no content type has been set on the response before. This allows - * handlers to override the default content type beforehand. + *

Only applies the view's contentType if no content type has been + * set on the response before. This allows handlers to override the + * default content type beforehand. * @param response current HTTP response * @see #setContentType */