Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for programmatically instantiating MessageDispatcherServlet [SWS-832] #906

Closed
gregturn opened this issue Apr 30, 2013 · 4 comments
Closed

Comments

@gregturn
Copy link
Member

@gregturn gregturn commented Apr 30, 2013

Mark Diskin opened SWS-832 and commented

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)

<servlet>
	<servlet-name>spring-ws</servlet-name>
	<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
		<init-param>
			<param-name>transformWsdlLocations</param-name>
			<param-value>true</param-value>
		</init-param>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>
				org.springframework.web.context.support.AnnotationConfigWebApplicationContext
			</param-value>
		</init-param>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>org.springframework.ws.samples.echo.code_approach.SpringWSConfig</param-value>
		</init-param>
</servlet>

Affects: 2.1.3

Reference URL: http://forum.springsource.org/showthread.php?136478-Spring-3-2-Java-Config-Example&p=443683#post443683

Issue Links:

  • #910 Add JavaConfig support

Referenced from: commits 7d97453, 6576999

1 votes, 4 watchers

@gregturn
Copy link
Member Author

@gregturn gregturn commented May 29, 2013

Marten Deinum commented

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.

[code]
MessageDispatcherServlet mds = new MessageDispatcherServlet();
mds.setTransformWsdlLocations(true);
mds.setContextClass(AnnotationConfigWebApplicationContext.class);
mds.setContextConfigLocation("org.springframework.ws.samples.echo.code_approach.SpringWSConfig");

ctx.addServlet("spring-ws", mds);

[/code]
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.

@gregturn
Copy link
Member Author

@gregturn gregturn commented Jun 13, 2013

Nick Williams commented

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.

@gregturn
Copy link
Member Author

@gregturn gregturn commented Jul 2, 2013

Arjen Poutsma commented

Related git pull request at #3

@gregturn
Copy link
Member Author

@gregturn gregturn commented Jul 2, 2013

Nick Williams commented

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.