Package org.springframework.web.servlet.resource

Examples of org.springframework.web.servlet.resource.ResourceHttpRequestHandler


  @Test
  public void resourceChainWithoutCaching() throws Exception {
    this.registration.resourceChain(false);

    ResourceHttpRequestHandler handler = getHandler("/resources/**");
    List<ResourceResolver> resolvers = handler.getResourceResolvers();
    assertThat(resolvers, Matchers.hasSize(1));
    assertThat(resolvers.get(0), Matchers.instanceOf(PathResourceResolver.class));

    List<ResourceTransformer> transformers = handler.getResourceTransformers();
    assertThat(transformers, Matchers.hasSize(0));
  }
View Full Code Here


        .addContentVersionStrategy("/**");

    this.registration.resourceChain(true).addResolver(versionResolver)
        .addTransformer(new AppCacheManifestTransformer());

    ResourceHttpRequestHandler handler = getHandler("/resources/**");
    List<ResourceResolver> resolvers = handler.getResourceResolvers();
    assertThat(resolvers.toString(), resolvers, Matchers.hasSize(3));
    assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class));
    assertThat(resolvers.get(1), Matchers.sameInstance(versionResolver));
    assertThat(resolvers.get(2), Matchers.instanceOf(PathResourceResolver.class));

    List<ResourceTransformer> transformers = handler.getResourceTransformers();
    assertThat(transformers, Matchers.hasSize(3));
    assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class));
    assertThat(transformers.get(1), Matchers.instanceOf(CssLinkResourceTransformer.class));
    assertThat(transformers.get(2), Matchers.instanceOf(AppCacheManifestTransformer.class));
  }
View Full Code Here

          .addResolver(pathResourceResolver)
          .addTransformer(cachingTransformer)
          .addTransformer(appCacheTransformer)
          .addTransformer(cssLinkTransformer);

    ResourceHttpRequestHandler handler = getHandler("/resources/**");
    List<ResourceResolver> resolvers = handler.getResourceResolvers();
    assertThat(resolvers.toString(), resolvers, Matchers.hasSize(3));
    assertThat(resolvers.get(0), Matchers.sameInstance(cachingResolver));
    assertThat(resolvers.get(1), Matchers.sameInstance(versionResolver));
    assertThat(resolvers.get(2), Matchers.sameInstance(pathResourceResolver));

    List<ResourceTransformer> transformers = handler.getResourceTransformers();
    assertThat(transformers, Matchers.hasSize(3));
    assertThat(transformers.get(0), Matchers.sameInstance(cachingTransformer));
    assertThat(transformers.get(1), Matchers.sameInstance(appCacheTransformer));
    assertThat(transformers.get(2), Matchers.sameInstance(cssLinkTransformer));
  }
View Full Code Here

    ResourceHttpRequestHandler appHandler;

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        appHandler = new ResourceHttpRequestHandler();

        ServletContextResource composerRoot = new ServletContextResource(config.getServletContext(), "/composer/**");
        appHandler.setApplicationContext(getWebApplicationContext());
        appHandler.setLocations((List)Arrays.asList(composerRoot));

View Full Code Here

        this.resourceLoader = resourceLoader;
      }

      @Bean
      public ResourceHttpRequestHandler faviconRequestHandler() {
        ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();
        requestHandler.setLocations(getLocations());
        return requestHandler;
      }
View Full Code Here

      Field locationsField = ReflectionUtils.findField(
          ResourceHttpRequestHandler.class, "locations");
      locationsField.setAccessible(true);
      for (Map.Entry<String, Object> entry : ((SimpleUrlHandlerMapping) mapping)
          .getHandlerMap().entrySet()) {
        ResourceHttpRequestHandler handler = (ResourceHttpRequestHandler) entry
            .getValue();
        mappingLocations.put(entry.getKey(),
            (List<Resource>) locationsField.get(handler));
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.servlet.resource.ResourceHttpRequestHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.