use of org.springframework.web.context.request.RequestContextListener in project nutch by apache.
the class NutchUiServer method startServer.
private static void startServer() throws Exception, InterruptedException {
Server server = new Server(port);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(DefaultServlet.class, "/*");
context.addEventListener(new ContextLoaderListener(getContext()));
context.addEventListener(new RequestContextListener());
WicketFilter filter = new WicketFilter();
filter.setFilterPath("/");
FilterHolder holder = new FilterHolder(filter);
holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
context.addFilter(holder, "/*", Handler.DEFAULT);
server.setHandler(context);
server.start();
server.join();
}
use of org.springframework.web.context.request.RequestContextListener in project molgenis by molgenis.
the class MolgenisWebAppInitializer method onStartup.
/**
* A Molgenis common web application initializer
*/
protected void onStartup(ServletContext servletContext, Class<?> appConfig, int maxFileSize) {
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(appConfig);
// Manage the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(rootContext));
// Register and map the dispatcher servlet
DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
dispatcherServlet.setDispatchOptionsRequest(true);
// instead of throwing a 404 when a handler is not found allow for custom handling
dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
ServletRegistration.Dynamic dispatcherServletRegistration = servletContext.addServlet("dispatcher", dispatcherServlet);
if (dispatcherServletRegistration == null) {
LOG.warn("ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'");
} else {
final long maxSize = (long) maxFileSize * MB;
dispatcherServletRegistration.addMapping("/");
dispatcherServletRegistration.setMultipartConfig(new MultipartConfigElement(null, maxSize, maxSize, FILE_SIZE_THRESHOLD));
}
// add filters
Dynamic browserDetectionFiler = servletContext.addFilter("browserDetectionFilter", BrowserDetectionFilter.class);
browserDetectionFiler.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class);
etagFilter.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "dispatcher");
Dynamic corsFilter = servletContext.addFilter("corsFilter", CorsFilter.class);
corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/api/*");
corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/fdp/*");
// enable use of request scoped beans in FrontController
servletContext.addListener(new RequestContextListener());
servletContext.addListener(HttpSessionEventPublisher.class);
}
use of org.springframework.web.context.request.RequestContextListener in project ocvn by devgateway.
the class WebInitializer method onStartup.
@Override
public void onStartup(final ServletContext sc) throws ServletException {
sc.addFilter("Spring OpenEntityManagerInViewFilter", org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.class).addMappingForUrlPatterns(null, false, "/*");
FilterRegistration filter = sc.addFilter("wicket-filter", WicketFilter.class);
filter.setInitParameter(WicketFilter.APP_FACT_PARAM, SpringWebApplicationFactory.class.getName());
filter.setInitParameter(PARAM_APP_BEAN, "formsWebApplication");
// This line is the only surprise when comparing to the equivalent
// web.xml. Without some initialization seems to be missing.
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
filter.addMappingForUrlPatterns(null, false, "/*");
// // Request Listener
sc.addListener(new RequestContextListener());
sc.addListener(new HttpSessionEventPublisher());
}
use of org.springframework.web.context.request.RequestContextListener in project oc-explorer by devgateway.
the class WebInitializer method onStartup.
@Override
public void onStartup(final ServletContext sc) throws ServletException {
sc.addFilter("Spring OpenEntityManagerInViewFilter", org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.class).addMappingForUrlPatterns(null, false, "/*");
FilterRegistration filter = sc.addFilter("wicket-filter", WicketFilter.class);
filter.setInitParameter(WicketFilter.APP_FACT_PARAM, SpringWebApplicationFactory.class.getName());
filter.setInitParameter(PARAM_APP_BEAN, "formsWebApplication");
// This line is the only surprise when comparing to the equivalent
// web.xml. Without some initialization seems to be missing.
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
filter.addMappingForUrlPatterns(null, false, "/*");
// // Request Listener
sc.addListener(new RequestContextListener());
sc.addListener(new HttpSessionEventPublisher());
}
Aggregations