Example usage for javax.servlet ServletContext addServlet

List of usage examples for javax.servlet ServletContext addServlet

Introduction

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

Prototype

public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);

Source Link

Document

Adds the servlet with the given name and class type to this servlet context.

Usage

From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java

private void registerLogoResourceServlet(final ServletContext servletContext) {
    ServletRegistration.Dynamic customResourceServletRegistration = servletContext
            .addServlet(LIGHT_ADMIN_LOGO_RESOURCE_SERVLET_NAME, logoResourceServlet(servletContext));
    customResourceServletRegistration.setLoadOnStartup(3);
    customResourceServletRegistration//from  w  w  w.j a va2 s.c om
            .addMapping(resourceServletMapping(servletContext, LIGHT_ADMIN_LOGO_SERVLET_URL));
}

From source file:edu.chalmers.dat076.moviefinder.initializer.ProjectWebApplicationInitializer.java

@Override
public void onStartup(ServletContext container) {
    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(ApplicationConfig.class);

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher",
            new DispatcherServlet(applicationContext));
    dispatcher.setLoadOnStartup(1);/*from   w w w .  j  a  v a 2 s . c o m*/
    dispatcher.addMapping("/");
}

From source file:org.lightadmin.logging.configurer.LightConfigurerWebApplicationInitializer.java

private void registerLightConfigurerDispatcher(final ServletContext servletContext,
        LoggingConfigurerSettings configuration) {
    final DispatcherServlet lightConfigurerDispatcher = new DispatcherServlet(createApplicationContext());

    ServletRegistration.Dynamic lightConfigurerDispatcherRegistration = servletContext
            .addServlet("light-configurer-dispatcher", lightConfigurerDispatcher);
    lightConfigurerDispatcherRegistration.setLoadOnStartup(2);
    lightConfigurerDispatcherRegistration
            .addMapping(dispatcherUrlMapping(configuration.getApplicationBaseUrl()));
}

From source file:org.bitcoinrt.web.config.BitcointWebAppInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
    webAppContext.register(WebConfig.class);

    final DispatcherServlet dispatcherServlet = new DispatcherServlet(webAppContext);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);/*from w ww .  j a v  a2s.c o  m*/
    dispatcher.addMapping("/site/*");

    UrlRewriteFilter urlRewriteFilter = new UrlRewriteFilter();

    servletContext.addFilter("UrlRewriteFilter", urlRewriteFilter)
            .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*");

}

From source file:org.kew.rmf.reconciliation.config.WebAppInitializer.java

private void configureSpringMvc(ServletContext servletContext, WebApplicationContext rootContext) {
    AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext();
    mvcContext.register(MvcConfig.class);

    mvcContext.setParent(rootContext);/*from ww w  .j  av a2  s .  c  o m*/
    ServletRegistration.Dynamic appServlet = servletContext.addServlet("reconciliation-service",
            new DispatcherServlet(mvcContext));
    appServlet.setLoadOnStartup(1);
    Set<String> mappingConflicts = appServlet.addMapping("/");

    if (!mappingConflicts.isEmpty()) {
        for (String s : mappingConflicts) {
            log.error("Mapping conflict: " + s);
        }
        throw new IllegalStateException("'webservice' cannot be mapped to '/'");
    }
}

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

private void registerDispatcherServlet(ServletContext servletContext) {

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

    logger.debug("after register(DispatcherConfig function");

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("zkLoader", new DHtmlLayoutServlet());

    dispatcher.setInitParameter("update-uri", "/zkau");

    dispatcher.setLoadOnStartup(1);//from  w w  w .  j av a2  s. c o  m
    dispatcher.addMapping("*.zul");

    dispatcher = servletContext.addServlet("auEngine", new DHtmlUpdateServlet());
    dispatcher.addMapping("/zkau/*");

    dispatcher = servletContext.addServlet("dspLoader", new InterpreterServlet());
    dispatcher.setInitParameter("class-resource", "true");
    dispatcher.addMapping("*.dsp");

}

From source file:gr.pskoufos.initializer.AppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(AppConfig.class);
    ctx.setServletContext(servletContext);
    servletContext.addListener(new ContextLoaderListener(ctx));
    servletContext.addListener(new RequestContextListener());
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);/*from   w ww  .ja  va 2 s  .  c  o  m*/
}

From source file:com.github.mjeanroy.junit.servers.samples.jetty.java.configuration.WebApplicationConfiguration.java

private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) {
    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setContextConfigLocation(configLocation());
    dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);/* w w  w.j a  v  a 2s .c o m*/
    dispatcher.addMapping("/*");
    dispatcher.addMapping("/");
}

From source file:com.mjeanroy.backbone_isomorphic.configuration.WebConfiguration.java

private void initSpringMvc(ServletContext servletContext, AnnotationConfigWebApplicationContext context) {
    DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
    dispatcherServlet.setContextConfigLocation(configLocation());
    dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("spring", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);//from   w  ww .  ja v  a2 s .  c  om
    dispatcher.addMapping("/api/*");
    dispatcher.addMapping("/");
}

From source file:olsps.com.healthsoftproject.config.SpringWebAppInitializer.java

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

    // Manage the lifecycle of the root application context
    container.addListener(new ContextLoaderListener(rootContext));
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher",
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);//from ww  w  .j  a  v a  2s  . c  o  m
    dispatcher.addMapping("/");

}