Search in sources :

Example 1 with MessageDispatcherServlet

use of org.springframework.ws.transport.http.MessageDispatcherServlet in project webservices-axiom by apache.

the class ScenarioTestCase method setUp.

@Override
protected void setUp() throws Exception {
    server = new Server();
    // Set up a custom thread pool to improve thread names (for logging purposes)
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName("jetty");
    server.setThreadPool(threadPool);
    Connector connector = new SelectChannelConnector();
    connector.setPort(0);
    server.setConnectors(new Connector[] { connector });
    ServletContextHandler handler = new ServletContextHandler(server, "/");
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setContextClass(GenericWebApplicationContext.class);
    servlet.setContextInitializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {

        public void initialize(ConfigurableApplicationContext applicationContext) {
            configureContext((GenericWebApplicationContext) applicationContext, config.getServerMessageFactoryConfigurator(), new ClassPathResource("server.xml", ScenarioTestCase.this.getClass()));
        }
    });
    ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.setName("spring-ws");
    servletHolder.setInitOrder(1);
    handler.addServlet(servletHolder, "/*");
    server.start();
    context = new GenericXmlApplicationContext();
    MockPropertySource propertySource = new MockPropertySource("client-properties");
    propertySource.setProperty("port", connector.getLocalPort());
    context.getEnvironment().getPropertySources().replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, propertySource);
    configureContext(context, config.getClientMessageFactoryConfigurator(), new ClassPathResource("client.xml", getClass()));
    context.refresh();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Connector(org.eclipse.jetty.server.Connector) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) MessageDispatcherServlet(org.springframework.ws.transport.http.MessageDispatcherServlet) ClassPathResource(org.springframework.core.io.ClassPathResource) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) MockPropertySource(org.springframework.mock.env.MockPropertySource) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext)

Example 2 with MessageDispatcherServlet

use of org.springframework.ws.transport.http.MessageDispatcherServlet in project spring-boot by spring-projects.

the class WebServicesAutoConfiguration method messageDispatcherServlet.

@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    String path = this.properties.getPath();
    String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
    ServletRegistrationBean<MessageDispatcherServlet> registration = new ServletRegistrationBean<>(servlet, urlMapping);
    WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
    registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
    for (Map.Entry<String, String> entry : servletProperties.getInit().entrySet()) {
        registration.addInitParameter(entry.getKey(), entry.getValue());
    }
    return registration;
}
Also used : ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Map(java.util.Map) MessageDispatcherServlet(org.springframework.ws.transport.http.MessageDispatcherServlet) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MessageDispatcherServlet (org.springframework.ws.transport.http.MessageDispatcherServlet)2 Map (java.util.Map)1 Connector (org.eclipse.jetty.server.Connector)1 Server (org.eclipse.jetty.server.Server)1 SelectChannelConnector (org.eclipse.jetty.server.nio.SelectChannelConnector)1 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 MockPropertySource (org.springframework.mock.env.MockPropertySource)1 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)1