From 7d97453ec5c3ad2c7462877b5e7de2bb4eb8b446 Mon Sep 17 00:00:00 2001 From: beamerblvd Date: Thu, 13 Jun 2013 21:31:42 -0500 Subject: [PATCH] Added Java config support to Message Servlet Added Java configuration support to MessageDispatcherServlet so that it can be configured within a ServletContextListener or a ServletContainerInitializer. Issue: SWS-832 --- .../http/MessageDispatcherServlet.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java index ddc42cc7..2519a88a 100644 --- a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java +++ b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.FrameworkServlet; import org.springframework.web.util.WebUtils; @@ -120,8 +121,60 @@ public class MessageDispatcherServlet extends FrameworkServlet { private boolean transformSchemaLocations = false; - /** Public constructor, necessary for some Web application servers. */ + /** + * Public constructor, necessary for some Web application servers. + */ public MessageDispatcherServlet() { + this(null); + } + + /** + * Constructor to support programmatic configuration of the Servlet with the specified + * web application context. This constructor is useful in Servlet 3.0+ environments + * where instance-based registration of servlets is possible through the + * {@code ServletContext#addServlet} API. + *

Using this constructor indicates that the following properties / init-params + * will be ignored: + *

+ *

The given web application context may or may not yet be {@linkplain + * org.springframework.web.context.ConfigurableWebApplicationContext#refresh() refreshed}. + * If it has not already been refreshed (the recommended approach), then + * the following will occur: + *

+ * If the context has already been refreshed, none of the above will occur, under the + * assumption that the user has performed these actions (or not) per their specific + * needs. + *

See {@link org.springframework.web.WebApplicationInitializer} for usage examples. + * + * @param webApplicationContext the context to use + * @see FrameworkServlet#FrameworkServlet(WebApplicationContext) + * @see org.springframework.web.WebApplicationInitializer + * @see #initWebApplicationContext() + * @see #configureAndRefreshWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) + */ + public MessageDispatcherServlet(WebApplicationContext webApplicationContext) { + super(webApplicationContext); defaultStrategiesHelper = new DefaultStrategiesHelper(MessageDispatcherServlet.class); }