use of org.springframework.web.servlet.DispatcherServlet in project chassis by Kixeye.
the class HttpTransportConfiguration method httpServer.
@Bean(initMethod = "start", destroyMethod = "stop")
@Order(0)
public Server httpServer(@Value("${http.enabled:false}") boolean httpEnabled, @Value("${http.hostname:}") String httpHostname, @Value("${http.port:-1}") int httpPort, @Value("${https.enabled:false}") boolean httpsEnabled, @Value("${https.hostname:}") String httpsHostname, @Value("${https.port:-1}") int httpsPort, @Value("${https.selfSigned:false}") boolean selfSigned, @Value("${https.mutualSsl:false}") boolean mutualSsl, @Value("${https.keyStorePath:}") String keyStorePath, @Value("${https.keyStoreData:}") String keyStoreData, @Value("${https.keyStorePassword:}") String keyStorePassword, @Value("${https.keyManagerPassword:}") String keyManagerPassword, @Value("${https.trustStorePath:}") String trustStorePath, @Value("${https.trustStoreData:}") String trustStoreData, @Value("${https.trustStorePassword:}") String trustStorePassword, @Value("${https.excludedCipherSuites:}") String[] excludedCipherSuites, ConfigurableWebApplicationContext webApplicationContext) throws Exception {
// set up servlets
ServletContextHandler context = servletContextHandler();
// create a new child application context
AnnotationConfigWebApplicationContext childApplicationContext = (AnnotationConfigWebApplicationContext) transportWebMvcContext(webApplicationContext, context).getContext();
// register swagger
childApplicationContext.getBean(SwaggerRegistry.class).registerSwagger(context, getObjectMappers(webApplicationContext));
// configure the spring mvc dispatcher
DispatcherServlet dispatcher = new DispatcherServlet(childApplicationContext);
// enable gzip
context.addFilter(GzipFilter.class, "/*", null);
// map application servlets
context.addServlet(new ServletHolder(dispatcher), "/");
if (healthCheckRegistry != null) {
context.addServlet(new ServletHolder(new HealthServlet(healthCheckRegistry)), "/healthcheck");
}
// create the server
Server server;
if (metricRegistry == null || !monitorThreadpool) {
server = new Server();
server.setHandler(context);
} else {
server = new Server(new InstrumentedQueuedThreadPool(metricRegistry));
InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
instrumented.setHandler(context);
server.setHandler(instrumented);
}
// set up connectors
if (httpEnabled) {
InetSocketAddress address = StringUtils.isBlank(httpHostname) ? new InetSocketAddress(httpPort) : new InetSocketAddress(httpHostname, httpPort);
JettyConnectorRegistry.registerHttpConnector(server, address);
}
if (httpsEnabled) {
InetSocketAddress address = StringUtils.isBlank(httpsHostname) ? new InetSocketAddress(httpsPort) : new InetSocketAddress(httpsHostname, httpsPort);
JettyConnectorRegistry.registerHttpsConnector(server, address, selfSigned, mutualSsl, keyStorePath, keyStoreData, keyStorePassword, keyManagerPassword, trustStorePath, trustStoreData, trustStorePassword, excludedCipherSuites);
}
return server;
}
use of org.springframework.web.servlet.DispatcherServlet in project Activiti by Activiti.
the class JPAWebConfigurer method initSpring.
/**
* Initializes Spring and Spring MVC.
*/
private ServletRegistration.Dynamic initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
log.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(DispatcherServletConfiguration.class);
log.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping("/service/*");
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.setAsyncSupported(true);
return dispatcherServlet;
}
use of org.springframework.web.servlet.DispatcherServlet in project Activiti by Activiti.
the class WebConfigurer method initSpring.
/**
* Initializes Spring and Spring MVC.
*/
private ServletRegistration.Dynamic initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
log.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(DispatcherServletConfiguration.class);
log.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping("/service/*");
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.setAsyncSupported(true);
return dispatcherServlet;
}
use of org.springframework.web.servlet.DispatcherServlet in project Protocol-Adapter-OSLP by OSGP.
the class WebDeviceSimulatorInitializer method onStartup.
/**
*/
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
startUp(servletContext);
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
final ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
}
Aggregations