[SWS-832] Add support for programmatically instantiating MessageDispatcherServlet Created: 30/Apr/13  Updated: 03/Jul/13  Resolved: 02/Jul/13

Status: Resolved
Project: Spring Web Services
Component/s: Core, Documentation, OXM, Samples, Security, Test
Affects Version/s: 2.1.3
Fix Version/s: 2.1.4

Type: New Feature Priority: Major
Reporter: Mark Diskin Assignee: Arjen Poutsma
Resolution: Fixed Votes: 1
Labels: java-configuration
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relates to SWS-836 Add JavaConfig support Resolved
Reference URL: http://forum.springsource.org/showthread.php?136478-Spring-3-2-Java-Config-Example&p=443683#post443683


The current MessageDispatcherServlet does not support a pure code configuration (no web.xml) as it does not offering a way of passing the 'root' Spring application context when the dispatcher servlet is created. For the normal Spring MVC DispatcherServlet there is a constructor with a WebApplicationContext parameter (added in 3.1.x I believe) and the 'root' app context can be passed on using this parameter.

Additionally there code be some review of the current schema namespaces to see if they are appliable as annotation classes. All of this would need the samples, documentation to be updated.

Below is a way to get the core javaconfig to work with the existing springws release (but still need the web.xml)


Comment by Marten Deinum [ 29/May/13 ]

The DispatcherServlet only has an option to pass in the ApplicationContext to use, not the root context (see: http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html#DispatcherServlet(org.springframework.web.context.WebApplicationContext) for more information).

You still don't need a web.xml you can pass in all the attributes as properties to the MessageDispatcherServlet.

MessageDispatcherServlet mds = new MessageDispatcherServlet();

ctx.addServlet("spring-ws", mds);
So no need for a web.xml, however it would be nice if we could use the same method of configuration as we can use with the DispatcherServlet.

Comment by Nick Williams [ 13/Jun/13 ]

Pull request submitted.

Added Java configuration support to MessageDispatcherServlet so that it can be configured within a ServletContextListener or a ServletContainerInitializer.

The change was extremely minor. Biggest change is the Javadoc. I added a new constructor to call FrameworkServlet#FrameworkServlet(WebApplicationContext) and then copied the JavaDoc from FrameworkServlet to the new constructor (exactly like it was done in DispatcherServlet). Works great!

What's the roadmap for 2.1.4? I'd love to see this committed and 2.1.4 rolled out soon.

I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.

Comment by Arjen Poutsma [ 02/Jul/13 ]

Related git pull request at https://github.com/SpringSource/spring-ws/pull/3

Comment by Nick Williams [ 02/Jul/13 ]

I see you renamed this from "Add Java Config Support" to "Add support for programmatically instantiating MessageDispatcherServlet." This is accurate, to be sure, in describing my commit. However, the original request was for full Java configuration support, which this doesn't achieve. If you're going to rename this issue, it seems that another issue (enhancement) should be created for full Java configuration support.

Generated at Tue Oct 23 09:27:15 UTC 2018 using JIRA 7.9.2#79002-sha1:3bb15b68ecd99a30eb364c4c1a393359bcad6278.