ResourceCacheManager.java :  » Google-tech » jrest4guice » org » jrest4guice » rest » commons » cache » Java Open Source

Java Open Source » Google tech » jrest4guice 
jrest4guice » org » jrest4guice » rest » commons » cache » ResourceCacheManager.java
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);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.