Example usage for javax.servlet ServletContext addListener

List of usage examples for javax.servlet ServletContext addListener

Introduction

In this page you can find the example usage for javax.servlet ServletContext addListener.

Prototype

public void addListener(Class<? extends EventListener> listenerClass);

Source Link

Document

Adds a listener of the given class type to this ServletContext.

Usage

From source file:br.com.semanticwot.cd.conf.ServletSpringMVC.java

@Override
public void onStartup(ServletContext servletContext) // Define qual  o contexto ativo no momento
        throws ServletException {
    super.onStartup(servletContext);
    servletContext.addListener(RequestContextListener.class);
    servletContext.setInitParameter(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME, "dev");

}

From source file:com.opencart.config.Initializer.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(SpringConfigurations.class);
    sc.addListener(new ContextLoaderListener(ctx));

    ctx.setServletContext(sc);/*w w  w .  ja va2 s  . c om*/

    Dynamic servlet = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);

}

From source file:com.gosmarter.it.eis.config.ExcelERPWebApplicationInitializer.java

private void registerListener(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = createContext(configurationClasses);

    servletContext.addListener(new RequestContextListener());
    servletContext.addListener(new ContextLoaderListener(rootContext));
    servletContext.addListener(new HttpSessionListener());
    servletContext.addListener(new WebDbInitializer());
}

From source file:com.devnexus.ting.web.WebAppInitializer.java

@Override
protected void registerContextLoaderListener(ServletContext servletContext) {
    servletContext.addListener(HttpSessionEventPublisher.class);
    super.registerContextLoaderListener(servletContext);
}

From source file:com.m1kah.spring.config.SpringInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(AppConfig.class);

    servletContext.addListener(new ContextLoaderListener(rootContext));
}

From source file:jp.classmethod.aws.petrucci.SpringInitializer.java

@Override
@SuppressWarnings("unused")
public void onStartup(ServletContext container) throws ServletException {
    XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
    rootContext.setConfigLocations(new String[] { "classpath*:applicationContext.xml" });
    container.addListener(new ContextLoaderListener(rootContext));
}

From source file:at.ac.tuwien.infosys.configuration.WebAppInitializer.java

@Override
public void onStartup(final ServletContext context) throws ServletException {

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();

    root.scan("at.ac.tuwien.infosys");

    context.addListener(new ContextLoaderListener(root));

    final ServletRegistration.Dynamic appServlet = context.addServlet("appServlet",
            new DispatcherServlet(new GenericWebApplicationContext()));
    appServlet.setAsyncSupported(true);//from  ww  w.  j av  a2 s  .  co m
    appServlet.setLoadOnStartup(1);
    appServlet.addMapping("/*");
}

From source file:org.teavm.flavour.example.server.ApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ApplicationConfiguration.class);
    servletContext.addListener(new ContextLoaderListener(rootContext));
    initJersey(servletContext);//from  ww  w  . j  av  a2  s .  c  o m
}

From source file:fi.m1kah.web.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(AppConfig.class);

    servletContext.addListener(new ContextLoaderListener(rootContext));

    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(DispatcherConfig.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);/* ww w  .jav  a 2  s.c o m*/
    dispatcher.addMapping("/api/*");
}

From source file:com.miserablemind.butter.bootstrap.AppInitializer.java

/**
 * Implements {@link WebApplicationInitializer} onStartup to initialize the system.
 * It registers and configures {@link RootContext}, {@link WebSecurityContext}, and app specific contexts.
 * It also initializes the {@link Log4jConfigListener}.
 *
 * @param container ServletContext//from   ww  w  .j a  v a  2s  .c o  m
 */
@Override
public void onStartup(ServletContext container) {

    //Make the logger read settings from main properties file
    container.setInitParameter("log4jConfigLocation", "classpath:system.properties");
    container.addListener(new Log4jConfigListener());

    //Root Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(RootContext.class);
    container.addListener(new ContextLoaderListener(rootContext));

    //Spring Security context
    AnnotationConfigWebApplicationContext securityContext = new AnnotationConfigWebApplicationContext();
    securityContext.register(WebSecurityContext.class);
    DelegatingFilterProxy filterProxy = new DelegatingFilterProxy("springSecurityFilterChain");
    container.addFilter("springSecurityFilterChain", filterProxy).addMappingForUrlPatterns(null, false, "*");

    //Dispatcher Servlet context
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(ButterAppMVCContext.class);

    //Register and map the dispatcher servlet
    DispatcherServlet dispatcherServlet = new DispatcherServlet(dispatcherContext);
    ServletRegistration.Dynamic dispatcher = container.addServlet("mvc-dispatcher", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");

}