Example usage for javax.servlet DispatcherType REQUEST

List of usage examples for javax.servlet DispatcherType REQUEST

Introduction

In this page you can find the example usage for javax.servlet DispatcherType REQUEST.

Prototype

DispatcherType REQUEST

To view the source code for javax.servlet DispatcherType REQUEST.

Click Source Link

Usage

From source file:com.sentinel.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    LOG.trace("Method: onStartup called.");

    EnumSet<DispatcherType> dispatch = EnumSet.of(DispatcherType.REQUEST);
    super.onStartup(servletContext);
    DelegatingFilterProxy filter = new DelegatingFilterProxy("springSecurityFilterChain");
    filter.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher");
    servletContext.addFilter("springSecurityFilterChain", filter).addMappingForUrlPatterns(dispatch, false,
            "/*");

    LOG.trace("Method: onStartup finished.");
}

From source file:io.undertow.servlet.test.defaultservlet.WelcomeFileTestCase.java

@BeforeClass
public static void setup() throws ServletException {

    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();

    DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE)
            .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext")
            .setDeploymentName("servletContext.war")
            .setResourceManager(new TestResourceLoader(WelcomeFileTestCase.class))
            .addWelcomePages("doesnotexist.html", "index.html", "default", "servletPath/servletFile.xhtml")
            .addServlet(// w w w  .  ja v  a 2 s. c o  m
                    new ServletInfo("DefaultTestServlet", PathTestServlet.class).addMapping("/path/default"))

            .addServlet(new ServletInfo("ServletPath", PathTestServlet.class).addMapping("/foo/servletPath/*"))

            .addFilter(new FilterInfo("Filter", NoOpFilter.class))
            .addFilterUrlMapping("Filter", "/*", DispatcherType.REQUEST)
            .addFilterUrlMapping("Filter", "/", DispatcherType.REQUEST);

    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());

    builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE)
            .setClassLoader(ServletPathMappingTestCase.class.getClassLoader())
            .setContextPath("/servletContext2").setDeploymentName("servletContext2.war")
            .setResourceManager(new TestResourceLoader(WelcomeFileTestCase.class))
            .addWelcomePages("doesnotexist.html", "index.do")
            .addServlet(new ServletInfo("*.do", PathTestServlet.class).addMapping("*.do"));

    manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}

From source file:io.github.microcks.config.WebConfiguration.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    log.info("Starting web application configuration, using profiles: {}",
            Arrays.toString(env.getActiveProfiles()));
    EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD,
            DispatcherType.ASYNC);/*from w  ww . j  av  a  2 s.c  o  m*/
    initCORSFilter(servletContext, disps);
    if (env.acceptsProfiles(ConfigurationConstants.PROFILE_PRODUCTION)) {
        //initStaticResourcesFilter(servletContext, disps);
    }
    log.info("Web application fully configured");
}

From source file:com.jiwhiz.web.config.WebConfigurer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    log.info("Web application configuration, using profiles: {}", Arrays.toString(env.getActiveProfiles()));
    EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD,
            DispatcherType.ASYNC);/*  ww w .j  av  a2 s  . c  o  m*/
    if (env.acceptsProfiles("prod")) {
        initCachingHttpHeadersFilter(servletContext, disps);
        initStaticResourcesProductionFilter(servletContext, disps);
    }
    log.info("Web application fully configured");
}

From source file:org.openmrs.web.WebComponentRegistrar.java

@Override
public void setServletContext(ServletContext servletContext) {

    try {/*from w  w w .  ja va2 s  . c o m*/
        ServletRegistration openmrsServletReg = servletContext.getServletRegistration("openmrs");
        addMappings(openmrsServletReg, "*.htm", "*.form", "*.list", "*.json", "*.field", "*.portlet", "*.page",
                "*.action");

        addMappings(servletContext.getServletRegistration("jsp"), "*.withjstl");

        ServletRegistration servletReg = servletContext.addServlet("logoutServlet", new LogoutServlet());
        servletReg.addMapping("/logout");

        Dynamic filter = servletContext.addFilter("forcePasswordChangeFilter", new ForcePasswordChangeFilter());
        filter.setInitParameter("changePasswordForm", "/admin/users/changePassword.form");
        filter.setInitParameter("excludeURL", "changePasswordForm,logout,.js,.css,.gif,.jpg,.jpeg,.png");
        filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

        filter = servletContext.addFilter("adminPageFilter", new AdminPageFilter());
        filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/admin");

        servletContext.addListener(new SessionListener());
        /*
         * EfficientShutdownServletContextAttributeListener is used instead of
         * EfficientShutdownServletContextListener since the latter implements ServletContextListener,
         * which is not supported by ServletContext.addListener.
        */
        servletContext.addListener(new EfficientShutdownServletContextAttributeListener());
    } catch (Exception ex) {
        //TODO not yet looked into what caused this to fail.
    }
}

From source file:io.undertow.servlet.test.security.login.ServletLoginTestCase.java

@BeforeClass
public static void setup() throws ServletException {

    final PathHandler path = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();

    ServletInfo s = new ServletInfo("servlet", SendUsernameServlet.class).addMapping("/*");

    ServletIdentityManager identityManager = new ServletIdentityManager();
    identityManager.addUser("user1", "password1", "role1");
    identityManager.addUser("user2", "password2", "role2");
    identityManager.addUser("user3", "password3", "role3");

    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader())
            .setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE)
            .setDeploymentName("servletContext.war").setIdentityManager(identityManager)
            .setLoginConfig(new LoginConfig("BASIC", "Test Realm")).addServlet(s)
            .addFilter(new FilterInfo("LoginFilter", LoginFilter.class))
            .addFilterServletNameMapping("LoginFilter", "servlet", DispatcherType.REQUEST);

    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();//from w w w .j  av a2s  .  c  om
    path.addPrefixPath(builder.getContextPath(), manager.start());

    DefaultServer.setRootHandler(path);
}

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  av a  2  s  .  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:com.test.config.BackendConsoleWebConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext();
    webCtx.register(BackendConsoleMVCConfig.class);
    webCtx.register(BackendConsoleConfig.class);

    servletContext.addListener(new ContextLoaderListener(webCtx));

    /* Spring Delegating Dispatcher Servlet */
    Servlet dispatcherServlet = new DispatcherServlet(webCtx);
    ServletRegistration.Dynamic dispatcherServletReg = servletContext.addServlet("dispatcherServlet",
            dispatcherServlet);/*  w w  w . j  ava2 s  .  co m*/
    dispatcherServletReg.setLoadOnStartup(1);
    dispatcherServletReg.setInitParameter("contextConfigLocation", "");
    dispatcherServletReg.addMapping("/");

    /* Spring Security Delegating Filter */
    FilterRegistration springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain",
            DelegatingFilterProxy.class);
    springSecurityFilterChainReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.ASYNC), false,
            dispatcherServletReg.getName());
}

From source file:io.undertow.servlet.test.defaultservlet.DefaultServletTestCase.java

@BeforeClass
public static void setup() throws ServletException {

    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();

    DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE)
            .setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext")
            .setDeploymentName("servletContext.war")
            .setResourceManager(new TestResourceLoader(DefaultServletTestCase.class));

    builder.addServlet(/*from  ww w.  ja  v  a 2 s .co  m*/
            new ServletInfo("DefaultTestServlet", PathTestServlet.class).addMapping("/path/default"));

    builder.addServlet(new ServletInfo("default", DefaultServlet.class)
            .addInitParam("directory-listing", "true").addMapping("/*"));

    //see UNDERTOW-458
    builder.addFilter(new FilterInfo("date-header", GetDateFilter.class));
    builder.addFilterUrlMapping("date-header", "/*", DispatcherType.REQUEST);

    builder.addFilter(new FilterInfo("Filter", HelloFilter.class));
    builder.addFilterUrlMapping("Filter", "/filterpath/*", DispatcherType.REQUEST);

    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());

    DefaultServer.setRootHandler(root);
}

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 va  2  s . c om
    characterEncoding.addMappingForUrlPatterns(dispatcherTypes, false, "/*");

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

}