List of usage examples for org.springframework.web.context ContextLoaderListener ContextLoaderListener
public ContextLoaderListener(WebApplicationContext context)
From source file:org.osgp.adapter.protocol.dlms.application.config.ProtocolAdapterDlmsInitializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { try {/*from w w w . java2 s .c om*/ // Force the timezone of application to UTC (required for // Hibernate/JDBC) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final Context initialContext = new InitialContext(); final String logLocation = (String) initialContext .lookup("java:comp/env/osp/osgpAdapterProtocolDlms/log-config"); LogbackConfigurer.initLogging(logLocation); final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); servletContext.addListener(new ContextLoaderListener(rootContext)); } catch (final NamingException e) { throw new ServletException("naming exception", e); } catch (final FileNotFoundException e) { throw new ServletException("Logging file not found", e); } catch (final JoranException e) { throw new ServletException("Logback exception", e); } }
From source file:com.alliander.osgp.adapter.protocol.oslp.application.config.OsgpProtocolAdapterOslpInitializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { try {// w ww.j a va 2 s.c o m // Force the timezone of application to UTC (required for // Hibernate/JDBC) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final Context initialContext = new InitialContext(); final String logLocation = (String) initialContext .lookup("java:comp/env/osp/osgpAdapterProtocolOslp/log-config"); LogbackConfigurer.initLogging(logLocation); final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); servletContext.addListener(new ContextLoaderListener(rootContext)); } catch (final NamingException e) { throw new ServletException("naming exception", e); } catch (final FileNotFoundException e) { throw new ServletException("Logging file not found", e); } catch (final JoranException e) { throw new ServletException("Logback exception", e); } }
From source file:nl.avans.ivh5a1.proftaak.config.ApplicationConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);/*from www . java2 s . c o m*/ dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); // FilterRegistration.Dynamic sitemesh = servletContext.addFilter("sitemesh", new ConfigurableSiteMeshFilter()); // EnumSet<DispatcherType> sitemeshDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); // sitemesh.addMappingForUrlPatterns(sitemeshDispatcherTypes, true, "*.jsp"); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:br.com.joaops.smt.SmtApplicationInitializer.java
@Override public void onStartup(ServletContext sc) throws ServletException { WebApplicationContext context = getContext(); sc.addListener(new ContextLoaderListener(context)); sc.addFilter("CharacterEncodingFilter", getCharacterEncodingFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL);/*from w w w. j av a2s . c o m*/ sc.addFilter("RequestContextFilter", getRequestContextFilter()).addMappingForUrlPatterns(null, true, MAPPING_URL); sc.addFilter("OpenEntityManagerInViewFilter", getOpenEntityManagerInViewFilter()) .addMappingForUrlPatterns(null, true, MAPPING_URL); sc.addFilter("securityFilter", getDelegatingFilterProxy()).addMappingForUrlPatterns(null, false, MAPPING_URL); //Deixar como false, para que no d erro no multi tenant! Onde o mtodo SecurityContextHolder.getContext().getAuthentication() sempre retornava nulo depois do login ServletRegistration.Dynamic dispatcher = sc.addServlet("LoversBookServlet", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1); dispatcher.setAsyncSupported(Boolean.TRUE); dispatcher.addMapping(MAPPING_URL); }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.application.config.OsgpProtocolAdapterOslpInitializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { try {/*from www . ja v a2 s . c o m*/ // Force the timezone of application to UTC (required for // Hibernate/JDBC) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final Context initialContext = new InitialContext(); final String logLocation = (String) initialContext .lookup("java:comp/env/osp/osgpAdapterProtocolOslpElster/log-config"); LogbackConfigurer.initLogging(logLocation); final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); servletContext.addListener(new ContextLoaderListener(rootContext)); } catch (final NamingException e) { throw new ServletException("naming exception", e); } catch (final FileNotFoundException e) { throw new ServletException("Logging file not found", e); } catch (final JoranException e) { throw new ServletException("Logback exception", e); } }
From source file:com.alliander.osgp.adapter.protocol.iec61850.application.config.OsgpProtocolAdapterIec61850Initializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { try {//from www . j a va 2 s . c o m // Force the timezone of application to UTC (required for // Hibernate/JDBC) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final Context initialContext = new InitialContext(); final String logLocation = (String) initialContext .lookup("java:comp/env/osp/osgpAdapterProtocolIec61850/log-config"); LogbackConfigurer.initLogging(logLocation); final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); servletContext.addListener(new ContextLoaderListener(rootContext)); } catch (final NamingException e) { throw new ServletException("naming exception", e); } catch (final FileNotFoundException e) { throw new ServletException("Logging file not found", e); } catch (final JoranException e) { throw new ServletException("Logback exception", e); } }
From source file:org.jboss.arquillian.spring.testsuite.beans.web.EmployeeWebInitializer.java
/** * {@inheritDoc}/* www.j a va 2 s.c o 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:com.controller.config.MainWebApplicationInitizer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.scan("com.controller.config"); servletContext.addListener(new ContextLoaderListener(rootContext)); ServletRegistration.Dynamic dispather = servletContext.addServlet("CXFServlet", CXFServlet.class); dispather.addMapping("/rest/*"); }
From source file:eu.agilejava.mvc.config.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { WebApplicationContext context = createWebAppContext(); servletContext.addListener(new ContextLoaderListener(context)); ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher", new DispatcherServlet(context)); registration.setLoadOnStartup(1);//from ww w . j a va2 s . c o m registration.addMapping("/hello"); }
From source file:org.jbr.commons.container.http.StandardWebAppInitializer.java
protected void createContextLoaderListener(final ServletContext servletContext, final WebApplicationContext rootContext) { servletContext.addListener(new ContextLoaderListener(rootContext)); }