package org.jrest4guice.rest.commons.cache;
import javax.servlet.http.HttpServletRequest;
import org.jrest4guice.guice.GuiceContext;
import com.google.inject.Singleton;
@Singleton
public class ResourceCacheManager {
/**
*
*/
private static String cacheStorePath = "cache";
/**
*
*/
private ResourceCacheProvider resourceCacheProvider = new DefaultResourceCacheProvider();
public String getCacheStorePath() {
return cacheStorePath;
}
/**
*
* @param cacheStorePath
*/
public static void setCacheStorePath(String cacheStorePath) {
ResourceCacheManager.cacheStorePath = cacheStorePath;
}
/**
*
* @param resourceCacheProvider
*/
public void setResourceCacheProvider(ResourceCacheProvider resourceCacheProvider) {
this.resourceCacheProvider = resourceCacheProvider;
}
/**
*
* @param uri
* @param mimeType
* @param content
* @param request
*/
public void cacheStaticResource(String uri, String mimeType, byte[] content,HttpServletRequest request) {
this.resourceCacheProvider.cacheStaticResource(uri, mimeType, content, request);
}
/**
*
* @param url
* @param mimeType
* @param request
* @return
*/
public String findStaticCacheResource(String url, String mimeType,HttpServletRequest request) {
return this.resourceCacheProvider.findStaticCacheResource(url, mimeType, request);
}
public void clearStaticResouceCache(String resourceId,HttpServletRequest request){
this.resourceCacheProvider.clearStaticResouceCache(resourceId, request);
}
/**
*
* @return
*/
public static ResourceCacheManager getInstance(){
return GuiceContext.getInstance().getBean(ResourceCacheManager.class);
}
}
|