You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by hc...@apache.org on 2005/02/01 11:33:45 UTC

cvs commit: jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/soft SoftRefCache.java SoftRefFileCache.java

hchar       2005/02/01 02:33:45

  Modified:    sandbox/yajcache/src/org/apache/jcs/yajcache/core
                        SafeCacheWrapper.java
               sandbox/yajcache/src/org/apache/jcs/yajcache/soft
                        SoftRefCache.java SoftRefFileCache.java
  Log:
  cache knows it's own type
  
  Revision  Changes    Path
  1.2       +17 -0     jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/core/SafeCacheWrapper.java
  
  Index: SafeCacheWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/core/SafeCacheWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SafeCacheWrapper.java	30 Jan 2005 11:36:10 -0000	1.1
  +++ SafeCacheWrapper.java	1 Feb 2005 10:33:45 -0000	1.2
  @@ -37,6 +37,8 @@
       /** Underlying cache. */
       private final @NonNullable ICache<V> cache;
       
  +    private final CacheType cacheType;
  +    
       /** 
        * Constructs a safe cache by wrapping an underlying cache. 
        * @param cache underlying cache.
  @@ -44,6 +46,17 @@
       public SafeCacheWrapper(@NonNullable ICache<V> cache)
       {
           this.cache = cache;
  +        
  +        switch(cache.getCacheType()) {
  +            case SOFT_REFERENCE:
  +                this.cacheType = CacheType.SOFT_REFERENCE_SAFE;
  +                break;
  +            case SOFT_REFERENCE_FILE:
  +                this.cacheType = CacheType.SOFT_REFERENCE_FILE_SAFE;
  +                break;
  +            default:
  +                throw new AssertionError(this);
  +        }
       }
       
       // ICache implementation by delegating to the underlying cache.
  @@ -136,6 +149,10 @@
           }
           return val;
       }
  +    @Implements(ICache.class)
  +    public CacheType getCacheType() {
  +        return this.cacheType;
  +    }
       @Override public String toString() {
           return new ToStringBuilder(this)
               .append(this.cache)
  
  
  
  1.9       +5 -0      jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/soft/SoftRefCache.java
  
  Index: SoftRefCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/soft/SoftRefCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SoftRefCache.java	29 Jan 2005 12:37:01 -0000	1.8
  +++ SoftRefCache.java	1 Feb 2005 10:33:45 -0000	1.9
  @@ -31,6 +31,7 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.jcs.yajcache.config.PerCacheConfig;
   import org.apache.jcs.yajcache.core.CacheEntry;
  +import org.apache.jcs.yajcache.core.CacheType;
   import org.apache.jcs.yajcache.core.ICache;
   import org.apache.jcs.yajcache.lang.annotation.*;
   import org.apache.jcs.yajcache.lang.ref.KeyedRefCollector;
  @@ -295,6 +296,10 @@
       void setConfig(@NonNullable PerCacheConfig config) {
           this.config = config;
       }
  +    @Implements(ICache.class)
  +    public CacheType getCacheType() {
  +        return CacheType.SOFT_REFERENCE;
  +    }
       @Override public String toString() {
           return new ToStringBuilder(this)
               .append("\n").append("name", this.getName())
  
  
  
  1.8       +12 -2     jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/soft/SoftRefFileCache.java
  
  Index: SoftRefFileCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/soft/SoftRefFileCache.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SoftRefFileCache.java	29 Jan 2005 13:31:44 -0000	1.7
  +++ SoftRefFileCache.java	1 Feb 2005 10:33:45 -0000	1.8
  @@ -39,6 +39,7 @@
   import org.apache.jcs.yajcache.core.ICacheChangeListener;
   import org.apache.jcs.yajcache.core.CacheChangeSupport;
   import org.apache.jcs.yajcache.core.CacheEntry;
  +import org.apache.jcs.yajcache.core.CacheType;
   import org.apache.jcs.yajcache.core.ICache;
   import org.apache.jcs.yajcache.file.CacheFileContent;
   import org.apache.jcs.yajcache.file.CacheFileContentType;
  @@ -134,12 +135,12 @@
           this.valueType = valueType;
           CacheFileUtils.inst.mkCacheDirs(this.name);
       }
  -    
  +    @TODO("Check file system")
       public boolean isEmpty() {
           this.collector.run();
           return map.isEmpty();
       }
  -    
  +    @TODO("Check file system")
       public int size() {
           this.collector.run();
           return map.size();
  @@ -386,15 +387,18 @@
       public V remove(@NonNullable Object key) {
           return key == null ? null : this.remove(key.toString());
       }
  +    @TODO("Clear file system")
       public void clear() {
   //        this.collector.run();
           map.clear();
           this.cacheChangeSupport.fireCacheClear();
       }
  +    @TODO("Get from file system")
       public @NonNullable Set<String> keySet() {
   //        this.collector.run();
           return map.keySet();
       }
  +    @TODO("Get from file system")
       public @NonNullable Set<Map.Entry<String,V>> entrySet() {
   //        this.collector.run();
           Set<Map.Entry<String,KeyedSoftReference<String,V>>> fromSet = map.entrySet();
  @@ -411,6 +415,7 @@
           }
           return toSet;
       }
  +    @TODO("Get from file system")
       public @NonNullable Collection<V> values() {
   //        this.collector.run();
           Collection<KeyedSoftReference<String,V>> fromSet = map.values();
  @@ -428,6 +433,7 @@
       public boolean containsKey(@NonNullable Object key) {
           return this.get(key.toString()) != null;
       }
  +    @TODO("Get from file system")
       public boolean containsValue(@NonNullable Object value) {
   //        this.collector.run();
           Collection<KeyedSoftReference<String,V>> fromSet = map.values();
  @@ -460,6 +466,10 @@
       public void setConfig(PerCacheConfig config) {
           this.config = config;
       }
  +    @Implements(ICache.class)
  +    public CacheType getCacheType() {
  +        return CacheType.SOFT_REFERENCE_FILE;
  +    }
       @Override public String toString() {
           return new ToStringBuilder(this)
               .append("\n").append("name", this.getName())
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org