本文整理汇总了Java中org.springframework.web.servlet.resource.ResourceResolver类的典型用法代码示例。如果您正苦于以下问题:Java ResourceResolver类的具体用法?Java ResourceResolver怎么用?Java ResourceResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceResolver类属于org.springframework.web.servlet.resource包,在下文中一共展示了ResourceResolver类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: resourceChain
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void resourceChain() throws Exception {
ResourceResolver mockResolver = Mockito.mock(ResourceResolver.class);
ResourceTransformer mockTransformer = Mockito.mock(ResourceTransformer.class);
this.registration.resourceChain(true).addResolver(mockResolver).addTransformer(mockTransformer);
ResourceHttpRequestHandler handler = getHandler("/resources/**");
List<ResourceResolver> resolvers = handler.getResourceResolvers();
assertThat(resolvers.toString(), resolvers, Matchers.hasSize(4));
assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class));
CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0);
assertThat(cachingResolver.getCache(), Matchers.instanceOf(ConcurrentMapCache.class));
assertThat(resolvers.get(1), Matchers.equalTo(mockResolver));
assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class));
assertThat(resolvers.get(3), Matchers.instanceOf(PathResourceResolver.class));
List<ResourceTransformer> transformers = handler.getResourceTransformers();
assertThat(transformers, Matchers.hasSize(2));
assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class));
assertThat(transformers.get(1), Matchers.equalTo(mockTransformer));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:ResourceHandlerRegistryTests.java
示例2: resourceChainWithVersionResolver
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void resourceChainWithVersionResolver() throws Exception {
VersionResourceResolver versionResolver = new VersionResourceResolver()
.addFixedVersionStrategy("fixed", "/**/*.js")
.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(4));
assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class));
assertThat(resolvers.get(1), Matchers.sameInstance(versionResolver));
assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class));
assertThat(resolvers.get(3), 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));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:ResourceHandlerRegistryTests.java
示例3: resolveUrlPath
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Override
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
ResourceResolver resolver = getNext();
if (resolver == null) {
return null;
}
try {
String returnPath = resolver.resolveUrlPath(resourcePath, locations, this);
if (LOG.isTraceEnabled()) {
LOG.trace("The return path for " + resourcePath + " from resolver " + resolver + " is " + returnPath);
}
return returnPath;
} finally {
this.index--;
}
}
开发者ID:takbani,项目名称:blcdemo,代码行数:17,代码来源:BroadleafDefaultResourceResolverChain.java
示例4: addResolver
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
/**
* Add a resource resolver to the chain.
* @param resolver the resolver to add
* @return the current instance for chained method invocation
*/
public ResourceChainRegistration addResolver(ResourceResolver resolver) {
Assert.notNull(resolver, "The provided ResourceResolver should not be null");
this.resolvers.add(resolver);
if (resolver instanceof VersionResourceResolver) {
this.hasVersionResolver = true;
}
else if (resolver instanceof PathResourceResolver) {
this.hasPathResolver = true;
}
return this;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:ResourceChainRegistration.java
示例5: getResourceResolvers
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
protected List<ResourceResolver> getResourceResolvers() {
if (!this.hasPathResolver) {
List<ResourceResolver> result = new ArrayList<ResourceResolver>(this.resolvers);
if (isWebJarsAssetLocatorPresent) {
result.add(new WebJarsResourceResolver());
}
result.add(new PathResourceResolver());
return result;
}
return this.resolvers;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:ResourceChainRegistration.java
示例6: testResourcesWithResolversTransformers
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void testResourcesWithResolversTransformers() throws Exception {
loadBeanDefinitions("mvc-config-resources-chain.xml", 11);
SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(mapping);
assertNotNull(mapping.getUrlMap().get("/resources/**"));
ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"),
ResourceHttpRequestHandler.class);
assertNotNull(handler);
List<ResourceResolver> resolvers = handler.getResourceResolvers();
assertThat(resolvers, Matchers.hasSize(4));
assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class));
assertThat(resolvers.get(1), Matchers.instanceOf(VersionResourceResolver.class));
assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class));
assertThat(resolvers.get(3), Matchers.instanceOf(PathResourceResolver.class));
CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0);
assertThat(cachingResolver.getCache(), Matchers.instanceOf(ConcurrentMapCache.class));
assertEquals("test-resource-cache", cachingResolver.getCache().getName());
VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(1);
assertThat(versionResolver.getStrategyMap().get("/**/*.js"),
Matchers.instanceOf(FixedVersionStrategy.class));
assertThat(versionResolver.getStrategyMap().get("/**"),
Matchers.instanceOf(ContentVersionStrategy.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));
CachingResourceTransformer cachingTransformer = (CachingResourceTransformer) transformers.get(0);
assertThat(cachingTransformer.getCache(), Matchers.instanceOf(ConcurrentMapCache.class));
assertEquals("test-resource-cache", cachingTransformer.getCache().getName());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:MvcNamespaceTests.java
示例7: testResourcesWithResolversTransformersCustom
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void testResourcesWithResolversTransformersCustom() throws Exception {
loadBeanDefinitions("mvc-config-resources-chain-no-auto.xml", 12);
SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(mapping);
assertNotNull(mapping.getUrlMap().get("/resources/**"));
ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"),
ResourceHttpRequestHandler.class);
assertNotNull(handler);
assertThat(handler.getCacheControl().getHeaderValue(),
Matchers.equalTo(CacheControl.maxAge(1, TimeUnit.HOURS)
.sMaxAge(30, TimeUnit.MINUTES).cachePublic().getHeaderValue()));
List<ResourceResolver> resolvers = handler.getResourceResolvers();
assertThat(resolvers, Matchers.hasSize(3));
assertThat(resolvers.get(0), Matchers.instanceOf(VersionResourceResolver.class));
assertThat(resolvers.get(1), Matchers.instanceOf(GzipResourceResolver.class));
assertThat(resolvers.get(2), Matchers.instanceOf(PathResourceResolver.class));
VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(0);
assertThat(versionResolver.getStrategyMap().get("/**/*.js"),
Matchers.instanceOf(FixedVersionStrategy.class));
assertThat(versionResolver.getStrategyMap().get("/**"),
Matchers.instanceOf(ContentVersionStrategy.class));
List<ResourceTransformer> transformers = handler.getResourceTransformers();
assertThat(transformers, Matchers.hasSize(2));
assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class));
assertThat(transformers.get(1), Matchers.instanceOf(AppCacheManifestTransformer.class));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:MvcNamespaceTests.java
示例8: resourceChainWithoutCaching
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void resourceChainWithoutCaching() throws Exception {
this.registration.resourceChain(false);
ResourceHttpRequestHandler handler = getHandler("/resources/**");
List<ResourceResolver> resolvers = handler.getResourceResolvers();
assertThat(resolvers, Matchers.hasSize(2));
assertThat(resolvers.get(0), Matchers.instanceOf(WebJarsResourceResolver.class));
assertThat(resolvers.get(1), Matchers.instanceOf(PathResourceResolver.class));
List<ResourceTransformer> transformers = handler.getResourceTransformers();
assertThat(transformers, Matchers.hasSize(0));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:ResourceHandlerRegistryTests.java
示例9: resourceChainWithOverrides
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Test
public void resourceChainWithOverrides() throws Exception {
CachingResourceResolver cachingResolver = Mockito.mock(CachingResourceResolver.class);
VersionResourceResolver versionResolver = Mockito.mock(VersionResourceResolver.class);
PathResourceResolver pathResourceResolver = new PathResourceResolver();
CachingResourceTransformer cachingTransformer = Mockito.mock(CachingResourceTransformer.class);
AppCacheManifestTransformer appCacheTransformer = Mockito.mock(AppCacheManifestTransformer.class);
CssLinkResourceTransformer cssLinkTransformer = new CssLinkResourceTransformer();
this.registration.setCachePeriod(3600)
.resourceChain(false)
.addResolver(cachingResolver)
.addResolver(versionResolver)
.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));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:ResourceHandlerRegistryTests.java
示例10: getResourceResolvers
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
protected List<ResourceResolver> getResourceResolvers(String mapping) {
SimpleUrlHandlerMapping handler = (SimpleUrlHandlerMapping) this.context
.getBean("resourceHandlerMapping");
ResourceHttpRequestHandler resourceHandler = (ResourceHttpRequestHandler) handler
.getHandlerMap().get(mapping);
return resourceHandler.getResourceResolvers();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:WebMvcAutoConfigurationTests.java
示例11: resolveResource
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
@Override
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
ResourceResolver resolver = getNext();
if (resolver == null) {
return null;
}
try {
return resolver.resolveResource(request, requestPath, locations, this);
} finally {
this.index--;
}
}
开发者ID:takbani,项目名称:blcdemo,代码行数:13,代码来源:BroadleafDefaultResourceResolverChain.java
示例12: getNext
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
private ResourceResolver getNext() {
Assert.state(this.index <= this.resolvers.size(),
"Current index exceeds the number of configured ResourceResolver's");
if (this.index == (this.resolvers.size() - 1)) {
return null;
}
this.index++;
return this.resolvers.get(this.index);
}
开发者ID:takbani,项目名称:blcdemo,代码行数:13,代码来源:BroadleafDefaultResourceResolverChain.java
示例13: BroadleafDefaultResourceResolverChain
import org.springframework.web.servlet.resource.ResourceResolver; //导入依赖的package包/类
public BroadleafDefaultResourceResolverChain(List<? extends ResourceResolver> resolvers) {
if (resolvers != null) {
this.resolvers.addAll(resolvers);
}
}
开发者ID:takbani,项目名称:blcdemo,代码行数:6,代码来源:BroadleafDefaultResourceResolverChain.java
注:本文中的org.springframework.web.servlet.resource.ResourceResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论