hchar       2005/02/05 05:49:27

  Modified:    sandbox/yajcache/src/org/apache/jcs/yajcache/soft
                        SoftRefCache.java SoftRefFileCache.java
  Added:       sandbox/yajcache/src/org/apache/jcs/yajcache/util
                        CollectionUtils.java
  Log:
  simplify via CollectionUtils
  
  Revision  Changes    Path
  1.1                  
jakarta-turbine-jcs/sandbox/yajcache/src/org/apache/jcs/yajcache/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===================================================================
  
  /*
   * Copyright 2005 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License")
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.jcs.yajcache.util;
  
  import java.util.concurrent.ConcurrentHashMap;
  
  import org.apache.jcs.yajcache.lang.annotation.*;
  
  /**
   * Collection related Utilities.
   *
   * @author Hanson Char
   */
  @CopyRightApache
  public enum CollectionUtils {
      inst;
      
      // Convenient methods originated from:
      // http://www.artima.com/forums/flat.jsp?forum=106&thread=79394
      
      public <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap() {
          return new ConcurrentHashMap<K,V>();
      }
      public <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(int 
initialCapacity) 
      {
          return new ConcurrentHashMap<K,V>(initialCapacity);
      }
      public <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap(
              int initialCapacity, float loadFactor, int concurrencyLevel)
      {
          return new ConcurrentHashMap<K,V>(initialCapacity);
      }
  }
  
  
  
  1.11      +4 -3      
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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SoftRefCache.java 3 Feb 2005 12:13:30 -0000       1.10
  +++ SoftRefCache.java 5 Feb 2005 13:49:27 -0000       1.11
  @@ -36,6 +36,7 @@
   import org.apache.jcs.yajcache.lang.annotation.*;
   import org.apache.jcs.yajcache.lang.ref.KeyedRefCollector;
   import org.apache.jcs.yajcache.lang.ref.KeyedSoftReference;
  +import org.apache.jcs.yajcache.util.CollectionUtils;
   import org.apache.jcs.yajcache.util.EqualsUtils;
   
   
  @@ -74,7 +75,7 @@
       public SoftRefCache(@NonNullable String name, @NonNullable Class<V> 
valueType, 
               int initialCapacity, float loadFactor, int concurrencyLevel) 
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>(initialCapacity, 
loadFactor, concurrencyLevel);
  +        this.map = 
CollectionUtils.inst.newConcurrentHashMap(initialCapacity, loadFactor, 
concurrencyLevel);
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  @@ -84,7 +85,7 @@
               @NonNullable Class<V> valueType, 
               int initialCapacity) 
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>(initialCapacity);
  +        this.map = 
CollectionUtils.inst.newConcurrentHashMap(initialCapacity);
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  @@ -93,7 +94,7 @@
               @NonNullable String name, 
               @NonNullable Class<V> valueType)
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>();
  +        this.map = CollectionUtils.inst.newConcurrentHashMap();
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  
  
  
  1.10      +6 -5      
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SoftRefFileCache.java     2 Feb 2005 11:25:44 -0000       1.9
  +++ SoftRefFileCache.java     5 Feb 2005 13:49:27 -0000       1.10
  @@ -35,6 +35,8 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.commons.lang.builder.ToStringBuilder;
   
  +import org.apache.jcs.yajcache.beans.CacheChangeSupport;
  +import org.apache.jcs.yajcache.beans.ICacheChangeListener;
   import org.apache.jcs.yajcache.lang.annotation.*;
   import org.apache.jcs.yajcache.config.PerCacheConfig;
   import org.apache.jcs.yajcache.beans.ICacheChangeListener;
  @@ -49,11 +51,10 @@
   import org.apache.jcs.yajcache.file.CacheFileUtils;
   import org.apache.jcs.yajcache.lang.ref.KeyedRefCollector;
   import org.apache.jcs.yajcache.lang.ref.KeyedSoftReference;
  +import org.apache.jcs.yajcache.util.CollectionUtils;
   import org.apache.jcs.yajcache.util.EqualsUtils;
   import org.apache.jcs.yajcache.util.concurrent.locks.IKeyedReadWriteLock;
   import org.apache.jcs.yajcache.util.concurrent.locks.KeyedReadWriteLock;
  -import org.apache.jcs.yajcache.beans.CacheChangeSupport;
  -import org.apache.jcs.yajcache.beans.ICacheChangeListener;
   
   
   /**
  @@ -110,7 +111,7 @@
               @NonNullable String name, @NonNullable Class<V> valueType,
               int initialCapacity,float loadFactor, int concurrencyLevel) 
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>(initialCapacity, 
loadFactor, concurrencyLevel);
  +        this.map = 
CollectionUtils.inst.newConcurrentHashMap(initialCapacity, loadFactor, 
concurrencyLevel);
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  @@ -120,7 +121,7 @@
               @NonNullable String name, @NonNullable Class<V> valueType,
               int initialCapacity) 
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>(initialCapacity);
  +        this.map = 
CollectionUtils.inst.newConcurrentHashMap(initialCapacity);
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  @@ -130,7 +131,7 @@
       public SoftRefFileCache(@NonNullable String name,
               @NonNullable Class<V> valueType) 
       {
  -        this.map = new 
ConcurrentHashMap<String,KeyedSoftReference<String,V>>();
  +        this.map = CollectionUtils.inst.newConcurrentHashMap();
           this.collector = new KeyedRefCollector<String>(refq, map);
           this.name = name;
           this.valueType = valueType;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to