Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-832

Add support for programmatically instantiating MessageDispatcherServlet

    Details

      Description

      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>

        Issue Links

          Activity

          mdiskin Mark Diskin created issue -
          Hide
          mdeinum Marten Deinum added a comment -

          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.

          Show
          mdeinum Marten Deinum added a comment - 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.
          Hide
          guitarking117 Nick Williams added a comment -

          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.

          Show
          guitarking117 Nick Williams added a comment - 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.
          arjen.poutsma Arjen Poutsma made changes -
          Field Original Value New Value
          Issue Type Improvement [ 4 ] New Feature [ 2 ]
          Hide
          arjen.poutsma Arjen Poutsma added a comment -
          Show
          arjen.poutsma Arjen Poutsma added a comment - Related git pull request at https://github.com/SpringSource/spring-ws/pull/3
          arjen.poutsma Arjen Poutsma made changes -
          Assignee Arjen Poutsma [ arjen.poutsma ]
          arjen.poutsma Arjen Poutsma made changes -
          Fix Version/s 2.2 M1 [ 12850 ]
          arjen.poutsma Arjen Poutsma made changes -
          Summary Add Java Config Support Add support for programmatically instantiating MessageDispatcherServlet
          arjen.poutsma Arjen Poutsma made changes -
          Fix Version/s 2.1.4 [ 14119 ]
          arjen.poutsma Arjen Poutsma made changes -
          Fix Version/s 2.2 M1 [ 12850 ]
          arjen.poutsma Arjen Poutsma made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          guitarking117 Nick Williams added a comment -

          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.

          Show
          guitarking117 Nick Williams added a comment - 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.
          arjen.poutsma Arjen Poutsma made changes -
          Link This issue relates to SWS-836 [ SWS-836 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          62d 17h 23m 1 Arjen Poutsma 02/Jul/13 3:37 AM

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              mdiskin Mark Diskin
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: