List of usage examples for javax.servlet ServletContext addListener
public void addListener(Class<? extends EventListener> listenerClass);
From source file:com.swordcode.webcore.security.testui.TestAppInitializer.java
@Override public void onStartup(ServletContext container) throws ServletException { // Use Spring AnnotationConfigWebApplicationContext to avoid using any xml files. AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(TestAppConfig.class); container.addListener(new ContextLoaderListener(rootContext)); ServletRegistration.Dynamic vaadinRoot = container.addServlet("vaadin", new SecurityTestUI.Servlet()); vaadinRoot.setLoadOnStartup(1);/*from w ww . j ava 2s . c om*/ vaadinRoot.setAsyncSupported(true); vaadinRoot.addMapping("/*"); // FilterRegistration.Dynamic jpaFilter = container.addFilter("springJPA", OpenEntityManagerInViewFilter.class); // jpaFilte // Filter f = new OpenEntityManagerInViewFilter(); // ServletRegistration.Dynamic filter = container.addFilter("/*", f);//org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.class); }
From source file:org.jboss.arquillian.spring.testsuite.beans.web.EmployeeWebInitializer.java
/** * {@inheritDoc}/*w w w. j a va 2 s .co m*/ */ public void onStartup(ServletContext servletContext) throws ServletException { // creates the web app context AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext(); webContext.register(WebAppConfig.class); // registers context load listener servletContext.addListener(new ContextLoaderListener(new AnnotationConfigWebApplicationContext())); // adds a dispatch servlet, the servlet will be configured from root web app context ServletRegistration.Dynamic servletConfig = servletContext.addServlet("employee", new DispatcherServlet(webContext)); servletConfig.setLoadOnStartup(1); servletConfig.addMapping("*.htm"); }
From source file:org.utb.project.ServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { WebApplicationContext webApplicationContext = getWebContext(); servletContext.setSessionTrackingModes(new HashSet<SessionTrackingMode>() { {/*ww w. ja va 2s. co m*/ add(SessionTrackingMode.COOKIE); } }); servletContext.addListener(new ContextLoaderListener(webApplicationContext)); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("ProyectoSoftware", new DispatcherServlet(webApplicationContext)); dispatcher.setAsyncSupported(true); dispatcher.setLoadOnStartup(0); dispatcher.addMapping("/*"); }
From source file:org.uoiu.platform.web.DefaultWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); // appContext.register(AppConfig.class); appContext.getEnvironment().setActiveProfiles("webapp"); servletContext.addListener(new ContextLoaderListener(appContext)); AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext(); mvcContext.register(MvcConfig.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(mvcContext)); dispatcher.setLoadOnStartup(1);/*from www . j a v a 2 s .c o m*/ dispatcher.addMapping("/"); FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", characterEncodingFilter()); encodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); }
From source file:com.techlooper.config.web.DispatcherServletInitializer.java
public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); SessionCookieConfig sessionCookieConfig = servletContext.getSessionCookieConfig(); sessionCookieConfig.setMaxAge(SessionListener.MAX_INACTIVE_INTERVAL); sessionCookieConfig.setHttpOnly(true); servletContext.addListener(new SessionListener()); }
From source file:org.jboss.arquillian.spring.testsuite.beans.web.EmployeeWebRootInitializer.java
/** * {@inheritDoc}/*w w w . ja v a 2 s. c om*/ */ public void onStartup(ServletContext servletContext) throws ServletException { // creates the web root app context AnnotationConfigWebApplicationContext webRootContext = new AnnotationConfigWebApplicationContext(); webRootContext.register(WebAppConfig.class); // registers context load listener servletContext.addListener(new ContextLoaderListener(webRootContext)); // adds a dispatch servlet, the servlet will be configured from root web app context ServletRegistration.Dynamic servletConfig = servletContext.addServlet("employee", new DispatcherServlet(new AnnotationConfigWebApplicationContext())); servletConfig.setLoadOnStartup(1); servletConfig.addMapping("*.htm"); }
From source file:org.glassfish.jersey.server.spring.SpringWebApplicationInitializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { if (sc.getInitParameter(PAR_NAME_CTX_CONFIG_LOCATION) == null) { LOGGER.config(LocalizationMessages.REGISTERING_CTX_LOADER_LISTENER()); sc.setInitParameter(PAR_NAME_CTX_CONFIG_LOCATION, "classpath:applicationContext.xml"); sc.addListener("org.springframework.web.context.ContextLoaderListener"); sc.addListener("org.springframework.web.context.request.RequestContextListener"); } else {/* w w w. j a v a 2 s . c o m*/ LOGGER.config(LocalizationMessages.SKIPPING_CTX_LODAER_LISTENER_REGISTRATION()); } }
From source file:org.openwms.client.application.ApplicationInitializer.java
/** * {@inheritDoc}/*from w ww . j a v a2 s . c o m*/ * * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext) */ @Override public void onStartup(ServletContext servletContext) throws ServletException { // Load application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(WebApplicationContextConfiguration.class); // Context loader listener servletContext.addListener(new ContextLoaderListener(rootContext)); // Dispatcher servlet ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/"); }
From source file:com.jjcosare.calculator.config.WebInitializer.java
@Override public void onStartup(ServletContext container) throws ServletException { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(WebConfig.class); // Manage the lifecycle of the root application context container.addListener(new ContextLoaderListener(rootContext)); // Create the dispatcher servlet's Spring application context AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(DispatcherConfig.class); // Register and map the dispatcher servlet ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext)); dispatcher.setLoadOnStartup(1);/*w w w . j av a2 s . c o m*/ dispatcher.addMapping("/"); }
From source file:com.bentechapps.angularcrud.config.SpringApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { //Tell jersey-spring3 the context is already initialized servletContext.setInitParameter("contextConfigLocation", "NOTNULL"); AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext(); appContext.register(SpringApplication.class); servletContext.addListener(new ContextLoaderListener(appContext)); }