Java 类org.springframework.web.filter.ShallowEtagHeaderFilter 实例源码

项目:dhis2-core    文件:DhisWebSpringTest.java   
@Before
public void setup() throws Exception
{
    userService = _userService;
    CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
    characterEncodingFilter.setEncoding( "UTF-8" );
    characterEncodingFilter.setForceEncoding( true );
    mvc = MockMvcBuilders.webAppContextSetup( webApplicationContext )
        .addFilters( characterEncodingFilter, new ShallowEtagHeaderFilter(), filterChainProxy )
        .apply( documentationConfiguration( this.restDocumentation ) )
        .build();

    executeStartupRoutines();

    setUpTest();
}
项目:AgileAlligators    文件:FredSpringWebTest.java   
@Before
public void setup() throws Exception
{
    objectMapper = new ObjectMapperFactoryBean().getObject();

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

    mvc = MockMvcBuilders.webAppContextSetup( wac )
        .addFilters( characterEncodingFilter, new ShallowEtagHeaderFilter(), filterChainProxy )
        .build();

    executeStartupRoutines();

    setUpTest();
}
项目:ait-platform    文件:AitTomcatCustomizer.java   
@Bean
public FilterRegistrationBean shallowEtagHeaderFilter() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new ShallowEtagHeaderFilter());
    registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
    return registration;
}
项目:judge    文件:RegistrationBeanConfiguration.java   
@Bean
public FilterRegistrationBean shallowEtagHeaderFilter() {
    ShallowEtagHeaderFilter filter = new ShallowEtagHeaderFilter();
    filter.setWriteWeakETag(true);
    FilterRegistrationBean bean = new FilterRegistrationBean(filter);
    bean.addUrlPatterns("/api/*", "/admin/*");
    return bean;
}
项目:spring4-understanding    文件:StreamingResponseBodyReturnValueHandler.java   
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
        ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

    if (returnValue == null) {
        mavContainer.setRequestHandled(true);
        return;
    }

    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    ServerHttpResponse outputMessage = new ServletServerHttpResponse(response);

    if (ResponseEntity.class.isAssignableFrom(returnValue.getClass())) {
        ResponseEntity<?> responseEntity = (ResponseEntity<?>) returnValue;
        outputMessage.setStatusCode(responseEntity.getStatusCode());
        outputMessage.getHeaders().putAll(responseEntity.getHeaders());

        returnValue = responseEntity.getBody();
        if (returnValue == null) {
            mavContainer.setRequestHandled(true);
            return;
        }
    }

    ServletRequest request = webRequest.getNativeRequest(ServletRequest.class);
    ShallowEtagHeaderFilter.disableContentCaching(request);

    Assert.isInstanceOf(StreamingResponseBody.class, returnValue);
    StreamingResponseBody streamingBody = (StreamingResponseBody) returnValue;

    Callable<Void> callable = new StreamingResponseBodyTask(outputMessage.getBody(), streamingBody);
    WebAsyncUtils.getAsyncManager(webRequest).startCallableProcessing(callable, mavContainer);
}
项目:SMSC    文件:AppConfiguration.java   
/**
 * Define filter to enable etag.
 *
 * @return filter
 */
@Bean
public FilterRegistrationBean shallowEtagBean() {
    FilterRegistrationBean frb = new FilterRegistrationBean();
    frb.setFilter(new ShallowEtagHeaderFilter());
    frb.addUrlPatterns("/", "/admin", "/admin/*");
    frb.setOrder(2);

    return frb;
}
项目:lavagna    文件:DispatcherServletInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);

    // initialize cookie
    if(StringUtils.isNotEmpty(System.getProperty(CookieNames.PROPERTY_NAME))) {
        CookieNames.updatePrefix(System.getProperty(CookieNames.PROPERTY_NAME));
    }
    //

    //definition order = execution order, the first executed filter is HSTSFilter
    addFilter(servletContext, "HSTSFilter", HSTSFilter.class, "/*");

    addFilter(servletContext, "CSFRFilter", CSFRFilter.class, "/*");

    addFilter(servletContext, "RememberMeFilter", RememberMeFilter.class, "/*");

    addFilter(servletContext, "AnonymousUserFilter", AnonymousUserFilter.class, "/*");

    addFilter(servletContext, "SecurityFilter", SecurityFilter.class, "/*");

    addFilter(servletContext, "ETagFilter", ShallowEtagHeaderFilter.class, "*.js", "*.css",//
               "/", "/project/*", "/admin/*", "/me/",//
               "*.html", "*.woff", "*.eot", "*.svg", "*.ttf");

    addFilter(servletContext, "GzipFilter", GzipFilter.class, "*.js", "*.css",//
               "/", "/project/*", "/admin/*", "/me/",//
               "/api/self", "/api/board/*", "/api/project/*");


    servletContext.setSessionTrackingModes(Collections.singleton(SessionTrackingMode.COOKIE));
    servletContext.getSessionCookieConfig().setHttpOnly(true);
    servletContext.getSessionCookieConfig().setName(CookieNames.getSessionCookieName());
}
项目:bearchoke    文件:AbstractWebApplicationInitializer.java   
protected void createFilters(ServletContext ctx) {
        CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");

        SimpleCORSFilter corsFilter = new SimpleCORSFilter();
        corsFilter.setCorsAllowCredentials("true");
        corsFilter.setCorsAllowMethods("GET, POST, PUT, PATCH, DELETE, OPTIONS");
        corsFilter.setCorsAllowHeaders("content-type, x-requested-with, origin, accept, authorization, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsExposeHeaders("content-type, cookie, x-requested-with, origin, accept, username, password, x-app-type, x-app-version, x-auth-token, soapaction");
        corsFilter.setCorsMaxAge("3600");

        ctx.addFilter("springSessionRepositoryFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("simpleCORSFilter", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
//        ctx.addFilter("SimpleCorsFilter", corsFilter).addMappingForUrlPatterns(
//                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("JsonHttpRequestFilter", new JsonHttpRequestFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/api/authenticate");
        ctx.addFilter("springSecurityFilterChain", DelegatingFilterProxy.class).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("CharacterEncodingFilter", characterEncodingFilter).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HiddenHttpMethodFilter", new HiddenHttpMethodFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("HttpPutFormContentFilter", new HttpPutFormContentFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);
        ctx.addFilter("ShallowEtagHeaderFilter", new ShallowEtagHeaderFilter()).addMappingForUrlPatterns(
                EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, FILTER_MAPPING);

    }
项目:spring4-understanding    文件:ResponseBodyEmitterReturnValueHandler.java   
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType,
        ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

    if (returnValue == null) {
        mavContainer.setRequestHandled(true);
        return;
    }

    HttpServletResponse response = webRequest.getNativeResponse(HttpServletResponse.class);
    ServerHttpResponse outputMessage = new ServletServerHttpResponse(response);

    if (ResponseEntity.class.isAssignableFrom(returnValue.getClass())) {
        ResponseEntity<?> responseEntity = (ResponseEntity<?>) returnValue;
        outputMessage.setStatusCode(responseEntity.getStatusCode());
        outputMessage.getHeaders().putAll(responseEntity.getHeaders());
        returnValue = responseEntity.getBody();
        if (returnValue == null) {
            mavContainer.setRequestHandled(true);
            return;
        }
    }

    ServletRequest request = webRequest.getNativeRequest(ServletRequest.class);
    ShallowEtagHeaderFilter.disableContentCaching(request);

    Assert.isInstanceOf(ResponseBodyEmitter.class, returnValue);
    ResponseBodyEmitter emitter = (ResponseBodyEmitter) returnValue;
    emitter.extendResponse(outputMessage);

    // Commit the response and wrap to ignore further header changes
    outputMessage.getBody();
    outputMessage.flush();
    outputMessage = new StreamingServletServerHttpResponse(outputMessage);

    DeferredResult<?> deferredResult = new DeferredResult<Object>(emitter.getTimeout());
    WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);

    HttpMessageConvertingHandler handler = new HttpMessageConvertingHandler(outputMessage, deferredResult);
    emitter.initialize(handler);
}
项目:spring4-understanding    文件:AbstractHttpSockJsSession.java   
private void disableShallowEtagHeaderFilter(ServerHttpRequest request) {
    if (request instanceof ServletServerHttpRequest) {
        ServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();
        ShallowEtagHeaderFilter.disableContentCaching(servletRequest);
    }
}
项目:vector-tiles-boot    文件:WebConfig.java   
@Bean
public Filter shallowEtagHeaderFilter()
{
    return new ShallowEtagHeaderFilter();
}
项目:udemy_microservices_with_spring_cloud    文件:MicroservicesBootApplication.java   
@Bean
public Filter shallowEtagHeaderFilter() {
  return new ShallowEtagHeaderFilter();
}
项目:spring-rest-todos    文件:Application.java   
@Bean
public ShallowEtagHeaderFilter etagFilter() {
    return new ShallowEtagHeaderFilter();
}
项目:ontrack    文件:WebConfig.java   
/**
 * ETag support
 */
@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
    return new ShallowEtagHeaderFilter();
}
项目:molgenis    文件:MolgenisWebAppInitializer.java   
/**
 * A Molgenis common web application initializer
 */
protected void onStartup(ServletContext servletContext, Class<?> appConfig, int maxFileSize)
{
    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.register(appConfig);

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

    // Register and map the dispatcher servlet
    DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext);
    dispatcherServlet.setDispatchOptionsRequest(true);
    // instead of throwing a 404 when a handler is not found allow for custom handling
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

    ServletRegistration.Dynamic dispatcherServletRegistration = servletContext.addServlet("dispatcher",
            dispatcherServlet);
    if (dispatcherServletRegistration == null)
    {
        LOG.warn("ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'");
    }
    else
    {
        final long maxSize = (long) maxFileSize * MB;
        dispatcherServletRegistration.addMapping("/");
        dispatcherServletRegistration.setMultipartConfig(
                new MultipartConfigElement(null, maxSize, maxSize, FILE_SIZE_THRESHOLD));
    }

    // add filters
    Dynamic browserDetectionFiler = servletContext.addFilter("browserDetectionFilter",
            BrowserDetectionFilter.class);
    browserDetectionFiler.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");

    Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class);
    etagFilter.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "dispatcher");

    Dynamic corsFilter = servletContext.addFilter("corsFilter", CorsFilter.class);
    corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/api/*");
    corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/fdp/*");

    // enable use of request scoped beans in FrontController
    servletContext.addListener(new RequestContextListener());

    servletContext.addListener(HttpSessionEventPublisher.class);
}
项目:Sound.je    文件:SpringConfig.java   
/**
 * Etag filter filter.
 *
 * @return the filter
 */
@Bean(name = "etagFilter")
public Filter etagFilter() {
    return new ShallowEtagHeaderFilter();
}