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:com.github.mjeanroy.junit.servers.samples.jetty.java.configuration.WebApplicationConfiguration.java

private AnnotationConfigWebApplicationContext initContext(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    return context;
}

From source file:com.github.djabry.platform.service.config.TestInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);/*www.  ja v  a2 s. co m*/
    dispatcher.addMapping("/*");

}

From source file:eu.agilejava.spring4.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  w  ww .ja  v a 2  s  . c  o m*/
    registration.addMapping("/api/*");

}

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   www  .  j  a  v  a 2  s  .  c o m
    registration.addMapping("/hello");

}

From source file:br.com.joaops.awc.AwcApplicationInitializer.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 . ja v  a2 s .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, true, MAPPING_URL);
    ServletRegistration.Dynamic dispatcher = sc.addServlet("LoversBookServlet", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);
    dispatcher.setAsyncSupported(Boolean.TRUE);
    dispatcher.addMapping(MAPPING_URL);
}

From source file:org.beast.project.template.initializer.WebxmlConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);//w ww  .j  a v a2s  .c  om
    dispatcher.addMapping(MAPPING_URL);

    ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet",
            new MessageDispatcherServlet(context));
    ws.setInitParameter("transformWsdlLocations", "true"); // Don't use this in production
    ws.addMapping("/services/*");

}

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);//  w  w  w .  j  a v a2  s .co  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.dm.platform.spring.MyWebApplicationInitializer.java

public void onStartup(ServletContext container) {
    System.out.println("MyWebApplicationInitializer[onStartup]");
    XmlWebApplicationContext ac = new XmlWebApplicationContext();
    container.addListener(new ContextLoaderListener(ac));

    //        ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet());
    //        registration.setLoadOnStartup(1);
    //        registration.addMapping("/spring/*");
}

From source file:com.mycompany.testeproject.App.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);/*w  w  w.j a  v a2s.co  m*/
    dispatcher.addMapping("/rest/*");
}

From source file:com.bitran.config.Inicializador.java

@Override
public void onStartup(ServletContext sc) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.bitran");
    sc.addListener(new ContextLoaderListener(ctx));
    Dynamic servlet = sc.addServlet("appServlet", new DispatcherServlet(ctx));
    servlet.setAsyncSupported(true);/*from  w ww. j a v  a2s.  c  om*/
    servlet.setLoadOnStartup(1);
    servlet.addMapping("*.action");
}