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

}

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);// w  ww  . j  a v a2s . co  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:com.gantzgulch.sharing.configuration.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
    appContext.getEnvironment().setActiveProfiles("production");
    appContext.scan("com.gantzgulch.sharing");

    ContextLoaderListener contextListener = new ContextLoaderListener(appContext);
    servletContext.addListener(contextListener);

    DelegatingFilterProxy filterProxy = new DelegatingFilterProxy("springSecurityFilterChain");
    FilterRegistration.Dynamic filter = servletContext.addFilter("securityFilter", filterProxy);
    filter.addMappingForUrlPatterns(null, false, "/*");

    AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
    webContext.register(MvcAppConfig.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("sharing",
            new DispatcherServlet(webContext));
    dispatcher.setLoadOnStartup(1);//from  w w  w  .j  a v a2  s  .c o  m
    dispatcher.addMapping("*.htm");
}

From source file:ch.javaee.basicMvc.WebInitializer.java

@Override
public void onStartup(ServletContext container) throws ServletException {

    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(AppConfiguration.class);

    // Manage the lifecycle of the root application context
    container.addListener(new ContextLoaderListener(rootContext));

    // Create the dispatcher servlet's Spring application context
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(DispatcherConfig.class);

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher",
            new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);/*  w w  w .java2s . c o  m*/
    dispatcher.addMapping("/");

}

From source file:com.swordcode.webcore.security.testui.TestAppInitializer.java

@Override
public void onStartup(ServletContext container) throws ServletException {
    // Use Spring AnnotationConfigWebApplicationContext to avoid using any xml files.
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(TestAppConfig.class);
    container.addListener(new ContextLoaderListener(rootContext));

    ServletRegistration.Dynamic vaadinRoot = container.addServlet("vaadin", new SecurityTestUI.Servlet());
    vaadinRoot.setLoadOnStartup(1);/*from  www .j  a v  a 2  s . c  o  m*/
    vaadinRoot.setAsyncSupported(true);
    vaadinRoot.addMapping("/*");

    //      FilterRegistration.Dynamic jpaFilter = container.addFilter("springJPA", OpenEntityManagerInViewFilter.class);
    //      jpaFilte

    //      Filter f = new OpenEntityManagerInViewFilter();
    //      ServletRegistration.Dynamic filter = container.addFilter("/*", f);//org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.class);
}

From source file:org.openwms.client.application.ApplicationInitializer.java

/**
 * {@inheritDoc}/* w  w w  . j av a  2  s  .  c  om*/
 * 
 * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext)
 */
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    // Load application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(WebApplicationContextConfiguration.class);

    // Context loader listener
    servletContext.addListener(new ContextLoaderListener(rootContext));

    // Dispatcher servlet
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
}

From source file:org.jbr.taskmgr.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    // Create the dispatcher servlet's Spring application context
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.setParent(containerContext);
    dispatcherContext.register(WebMvcConfig.class);
    dispatcherContext.registerShutdownHook();

    // Register and map the dispatcher servlet
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);/*  w  ww  . ja v  a  2 s. com*/
    dispatcher.addMapping("/");
}

From source file:net.rgielen.actionframeworks.springmvc.ApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(ApplicationConfig.class);
    servletContext.addListener(new ContextLoaderListener(context));

    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding("UTF-8");
    characterEncodingFilter.setForceEncoding(true);

    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);

    FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding",
            characterEncodingFilter);/*from w w w.  j a v  a 2  s .com*/
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, false, "/*");

    ServletRegistration.Dynamic registration = servletContext.addServlet("dispatcher",
            new DispatcherServlet(context));
    registration.setLoadOnStartup(1);
    registration.addMapping("/");

}

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);/*ww w. j av a  2s  . c o m*/
    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:com.videohub.configuration.VideoHubInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    LOGGER.trace("Starting videohub app");

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(WebConfiguration.class);

    servletContext.addListener(new ContextLoaderListener(rootContext));

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

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_NAME,
            new DispatcherServlet(dispatcherContext));

    dispatcher.setLoadOnStartup(1);/*from   w  ww .  j  av  a  2 s.co  m*/
    dispatcher.addMapping(DISPATCHER_MAPPING);
}