remm        2002/06/10 17:31:43

  Modified:    catalina/src/share/org/apache/naming/resources
                        ProxyDirContext.java
  Log:
  - Switch to use a LRUMap from Collections 2.0.
  - Note: The cacheSize attribute must be on the BaseDirContext (ProxyDirContext
    is a only a wrapper which adds caching).
  - Patch submitted by Robert Herrmann <bob at jadn.com>
  
  Revision  Changes    Path
  1.12      +21 -8     
jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java
  
  Index: ProxyDirContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ProxyDirContext.java      27 Feb 2002 01:17:00 -0000      1.11
  +++ ProxyDirContext.java      11 Jun 2002 00:31:43 -0000      1.12
  @@ -64,11 +64,14 @@
   
   package org.apache.naming.resources;
   
  -import java.util.Hashtable;
  +import java.util.Collections;
   import java.util.Date;
  +import java.util.Hashtable;
  +import java.util.Map;
   import java.io.InputStream;
   import java.io.IOException;
   import java.io.ByteArrayInputStream;
  +
   import javax.naming.Context;
   import javax.naming.Name;
   import javax.naming.NameParser;
  @@ -79,8 +82,11 @@
   import javax.naming.directory.Attribute;
   import javax.naming.directory.ModificationItem;
   import javax.naming.directory.SearchControls;
  +
   import org.apache.naming.StringManager;
   
  +import org.apache.commons.collections.LRUMap;
  +
   /**
    * Proxy Directory Context implementation.
    *
  @@ -111,7 +117,7 @@
               // Initialize parameters based on the associated dir context, like
               // the caching policy.
               if (((BaseDirContext) dirContext).isCached()) {
  -                cache = new Hashtable();
  +                cache = Collections.synchronizedMap(new LRUMap(cacheSize));
                   cacheTTL = ((BaseDirContext) dirContext).getCacheTTL();
                   cacheObjectMaxSize = 
                       ((BaseDirContext) dirContext).getCacheObjectMaxSize();
  @@ -132,6 +138,7 @@
           this.dirContext = dirContext;
           this.vPath = vPath;
           this.cache = proxyDirContext.cache;
  +        this.cacheSize = proxyDirContext.cacheSize;
           this.cacheTTL = proxyDirContext.cacheTTL;
           this.cacheObjectMaxSize = proxyDirContext.cacheObjectMaxSize;
           this.hostName = proxyDirContext.hostName;
  @@ -182,7 +189,13 @@
        * Cache.
        * Path -> Cache entry.
        */
  -    protected Hashtable cache = null;
  +    protected Map cache = null;
  +
  +
  +    /**
  +     * Cache size
  +     */
  +    protected int cacheSize = 1000;
   
   
       /**
  @@ -676,7 +689,7 @@
        */
       public Name composeName(Name name, Name prefix)
           throws NamingException {
  -     prefix = (Name) name.clone();
  +        prefix = (Name) name.clone();
        return prefix.addAll(name);
       }
   
  
  
  

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

Reply via email to