Example usage for javax.servlet DispatcherType ASYNC

List of usage examples for javax.servlet DispatcherType ASYNC

Introduction

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

Prototype

DispatcherType ASYNC

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

Click Source Link

Usage

From source file:org.zalando.logbook.servlet.RequestBuilders.java

static RequestBuilder async(final MvcResult result) {
    final RequestBuilder builder = asyncDispatch(result);

    return context -> {
        final MockHttpServletRequest request = builder.buildRequest(context);
        // this is missing in MockMvcRequestBuilders#asyncDispatch
        request.setDispatcherType(DispatcherType.ASYNC);
        return request;
    };/*from w  w  w  . ja  va2 s  . co  m*/
}

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);
    initCORSFilter(servletContext, disps);
    if (env.acceptsProfiles(ConfigurationConstants.PROFILE_PRODUCTION)) {
        //initStaticResourcesFilter(servletContext, disps);
    }/*from   ww w . ja  v  a  2 s. c o  m*/
    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);
    if (env.acceptsProfiles("prod")) {
        initCachingHttpHeadersFilter(servletContext, disps);
        initStaticResourcesProductionFilter(servletContext, disps);
    }//from  w w w.  j  av  a  2 s .c  om
    log.info("Web application fully configured");
}

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);//from  w  w  w .  ja v a 2s.  c om
    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:fr.treeptik.cloudunit.initializer.ApplicationConfig.java

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

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);/*  ww w .j  a  v a 2  s  .c o m*/
    dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
    dispatcher.setAsyncSupported(true);

    FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain",
            new DelegatingFilterProxy());
    EnumSet<DispatcherType> securityDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD,
            DispatcherType.ASYNC);

    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/user/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/file/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/logs/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/messages/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/application/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/server/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/snapshot/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/module/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/admin/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/image/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/nopublic/*");

    security.setAsyncSupported(true);

    servletContext.addListener(new ContextLoaderListener(rootContext));
}

From source file:cn.org.once.cstack.initializer.ApplicationConfig.java

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

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

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
            new DispatcherServlet(rootContext));
    dispatcher.setLoadOnStartup(1);/*from   w w  w  .ja va2s.  c om*/
    dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
    dispatcher.setAsyncSupported(true);

    FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain",
            new DelegatingFilterProxy());
    EnumSet<DispatcherType> securityDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD,
            DispatcherType.ASYNC);

    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/user/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/file/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/logs/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/messages/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/application/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/server/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/snapshot/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/module/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/admin/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/image/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/scripting/*");
    security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/gitlab/*");

    security.setAsyncSupported(true);

    servletContext.addListener(new ContextLoaderListener(rootContext));

}

From source file:io.jmnarloch.spring.request.correlation.support.RequestCorrelationConfiguration.java

@Bean
public FilterRegistrationBean requestCorrelationFilterBean(RequestCorrelationFilter correlationFilter) {

    final FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
    filterRegistration.setFilter(correlationFilter);
    filterRegistration.setMatchAfter(false);
    filterRegistration.setDispatcherTypes(
            EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC));
    filterRegistration.setAsyncSupported(true);
    filterRegistration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return filterRegistration;
}

From source file:com.boylesoftware.web.Router.java

/**
 * Route request./*  w  w  w  .j a  va 2 s .  c o  m*/
 *
 * @param webapp The application.
 * @param request The HTTP request.
 * @param response The HTTP response.
 *
 * @return {@code true} if the router took care of the request processing
 * and no further action is required, {@code false} if the router did not
 * process the request because it does not have a route for it.
 *
 * @throws ServletException If an error happens.
 * @throws IOException If an I/O error happens reading the request or
 * sending the response.
 */
boolean route(final AbstractWebApplication webapp, final HttpServletRequest request,
        final HttpServletResponse response) throws ServletException, IOException {

    if (this.log.isDebugEnabled())
        this.log.debug("received " + request.getDispatcherType() + " " + request.getMethod() + " "
                + request.getRequestURI() + " (" + request.getClass().getName() + ")");

    // execute corresponding logic
    return (request.getDispatcherType() == DispatcherType.ASYNC ? this.doAsync(webapp, request, response)
            : this.doRequest(webapp, request, response));
}

From source file:fi.helsinki.opintoni.config.WebConfigurer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    log.info("Web application configuration, using profiles: {}", Arrays.toString(env.getActiveProfiles()));
    EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD,
            DispatcherType.ASYNC);
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_QA,
            Constants.SPRING_PROFILE_DEMO, Constants.SPRING_PROFILE_PRODUCTION)) {
        initMetrics(servletContext, dispatcherTypes);

        // Forces browser to send cookies with HTTPS connection only
        servletContext.getSessionCookieConfig().setSecure(true);
    }/*from  w  w w.  j  a  v  a 2s .com*/

    servletContext.getSessionCookieConfig().setName(Constants.SESSION_COOKIE_NAME);
    servletContext.getSessionCookieConfig().setDomain(appConfiguration.get("cookieDomain"));

    log.info("Web application fully configured");
}

From source file:net.bull.javamelody.JavaMelodyAutoConfiguration.java

/**
 * Registers the JavaMelody {@link MonitoringFilter}. The filter can be overridden completely by creating a custom
 * {@link FilterRegistrationBean} with the name "javamelody-registration" in the application context.
 * @param properties JavaMelodyConfigurationProperties
 * @param servletContext ServletContext//from   w w  w .j a v a  2s.  c  om
 * @return FilterRegistrationBean
 */
@Bean(name = REGISTRATION_BEAN_NAME)
@ConditionalOnMissingBean(name = REGISTRATION_BEAN_NAME)
public FilterRegistrationBean monitoringFilter(JavaMelodyConfigurationProperties properties,
        ServletContext servletContext) {
    final FilterRegistrationBean registrationBean = new FilterRegistrationBean();

    // Create the monitoring filter and set its configuration parameters.
    final MonitoringFilter filter = new MonitoringFilter();
    filter.setApplicationType("Spring Boot");

    // Wrap the monitoring filter in the registration bean.
    registrationBean.setFilter(filter);
    registrationBean.setAsyncSupported(true);
    registrationBean.setName("javamelody");
    registrationBean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);

    // Set the initialization parameter for the monitoring filter.
    for (final Entry<String, String> parameter : properties.getInitParameters().entrySet()) {
        registrationBean.addInitParameter(parameter.getKey(), parameter.getValue());
    }

    // Set the URL patterns to activate the monitoring filter for.
    registrationBean.addUrlPatterns("/*");

    final FilterRegistration filterRegistration = servletContext.getFilterRegistration("javamelody");
    if (filterRegistration != null) {
        // if webapp deployed as war in a container with MonitoringFilter already added by web-fragment.xml,
        // do not try to add it again
        registrationBean.setEnabled(false);
        for (final Map.Entry<String, String> entry : registrationBean.getInitParameters().entrySet()) {
            filterRegistration.setInitParameter(entry.getKey(), entry.getValue());
        }
    }
    return registrationBean;
}