Example usage for javax.servlet ServletRegistration.Dynamic addMapping

List of usage examples for javax.servlet ServletRegistration.Dynamic addMapping

Introduction

In this page you can find the example usage for javax.servlet ServletRegistration.Dynamic addMapping.

Prototype

public Set<String> addMapping(String... urlPatterns);

Source Link

Document

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

Usage

From source file:io.gravitee.management.war.WebAppInitializer.java

@Override
public void onStartup(ServletContext context) throws ServletException {
    // initialize
    initialize();/*w w  w . j  ava  2s .  co  m*/
    Properties prop = propertiesLoader.load();

    // REST configuration
    ServletRegistration.Dynamic servletRegistration = context.addServlet("REST",
            ServletContainer.class.getName());
    servletRegistration.addMapping("/management/*");
    servletRegistration.setLoadOnStartup(1);
    servletRegistration.setInitParameter("javax.ws.rs.Application", GraviteeApplication.class.getName());

    // Spring configuration
    System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME,
            prop.getProperty("security.type", "basic-auth"));
    context.addListener(new ContextLoaderListener());
    context.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.setInitParameter("contextConfigLocation", RestConfiguration.class.getName());

    // Spring Security filter
    context.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class)
            .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*");
}

From source file:org.efoe.poc.springws.provider.xmlbeans.initializer.WebXml.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  . j  a v  a  2s  . c  o m*/
    dispatcher.addMapping(MAPPING_URL);

    ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet",
            new MessageDispatcherServlet(context));
    ws.setInitParameter("transformWsdlLocations", "true");
    ws.addMapping("/services/*");
}

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

}

From source file:org.statefulj.demo.ddd.config.MVCInitializer.java

@Override
protected void registerDispatcherServlet(ServletContext servletContext) {
    String servletName = getServletName();

    WebApplicationContext servletAppContext = createServletApplicationContext();

    DispatcherServlet dispatcherServlet = new DispatcherServlet(servletAppContext);

    // throw NoHandlerFoundException to Controller when a User requests a non-existent page
    ////w w  w . j  a  va  2s .  c  o m
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

    ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet);

    registration.setLoadOnStartup(1);
    registration.addMapping(getServletMappings());
    registration.setAsyncSupported(isAsyncSupported());

    Filter[] filters = getServletFilters();
    if (!ObjectUtils.isEmpty(filters)) {
        for (Filter filter : filters) {
            registerServletFilter(servletContext, filter);
        }
    }

    customizeRegistration(registration);
}

From source file:com.gopivotal.cloudfoundry.test.ApplicationInitializer.java

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

    ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher",
            new DispatcherServlet(webContext));
    dispatcherServlet.setLoadOnStartup(1);
    dispatcherServlet.addMapping("/");
}

From source file:com.pojur.config.AppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    //        WebApplicationContext context = getContext();
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(ServiceConfig.class, JPAConfig.class);
    servletContext.addListener(new ContextLoaderListener(rootContext));

    AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext();
    dispatcherServlet.register(WebMvcConfig.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(dispatcherServlet));
    dispatcher.setLoadOnStartup(1);//from w w w.  j  av  a2  s. c o m
    dispatcher.addMapping("/");
}

From source file:org.consultjr.mvc.core.config.ApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));
    servletContext.addListener(new ApplicationSessionListener());
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);//from   www.j  a va2  s .com
    dispatcher.addMapping("/");
}

From source file:$.SpringAppInitializer.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);//from w  w w .  ja v a2  s .c  om
        dispatcher.addMapping(MAPPING_URL);
    }

From source file:org.jboss.arquillian.spring.testsuite.beans.web.EmployeeWebInitializer.java

/**
 * {@inheritDoc}// w ww  .j a v a  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: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);//w ww  .  java 2s  . c  o  m
    dispatcher.addMapping("/api/*");
}