Author: fmui
Date: Thu Nov 20 16:42:35 2014
New Revision: 1640764

URL: http://svn.apache.org/r1640764
Log:
CMIS-868: reworked object type caching

Added:
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java
   (with props)
Modified:
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/CmisBindingFactory.java
 Thu Nov 20 16:42:35 2014
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingImpl;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
 
@@ -132,7 +133,8 @@ public class CmisBindingFactory {
         }
         if (typeDefCache == null) {
             if 
(!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
-                
sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+                sessionParameters
+                        .put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
             }
         }
         if (!sessionParameters.containsKey(SessionParameter.AUTH_HTTP_BASIC)) {
@@ -172,7 +174,8 @@ public class CmisBindingFactory {
         }
         if (typeDefCache == null) {
             if 
(!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
-                
sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+                sessionParameters
+                        .put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
             }
         }
         if 
(!sessionParameters.containsKey(SessionParameter.AUTH_SOAP_USERNAMETOKEN)) {
@@ -231,7 +234,8 @@ public class CmisBindingFactory {
         }
         if (typeDefCache == null) {
             if 
(!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
-                
sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+                sessionParameters
+                        .put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
             }
         }
         if (!sessionParameters.containsKey(SessionParameter.BROWSER_SUCCINCT)) 
{
@@ -264,7 +268,8 @@ public class CmisBindingFactory {
         sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, 
BINDING_SPI_LOCAL);
         if (typeDefCache == null) {
             if 
(!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
-                
sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+                sessionParameters
+                        .put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, 
DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
             }
         }
         addDefaultParameters(sessionParameters);
@@ -332,9 +337,10 @@ public class CmisBindingFactory {
     private static Map<String, String> createNewDefaultParameters() {
         Map<String, String> result = new HashMap<String, String>();
 
-        result.put(SessionParameter.CACHE_SIZE_REPOSITORIES, "10");
-        result.put(SessionParameter.CACHE_SIZE_TYPES, "100");
-        result.put(SessionParameter.CACHE_SIZE_LINKS, "400");
+        result.put(SessionParameter.CACHE_SIZE_REPOSITORIES,
+                
String.valueOf(SessionParameterDefaults.CACHE_SIZE_REPOSITORIES));
+        result.put(SessionParameter.CACHE_SIZE_TYPES, 
String.valueOf(SessionParameterDefaults.CACHE_SIZE_TYPES));
+        result.put(SessionParameter.CACHE_SIZE_LINKS, 
String.valueOf(SessionParameterDefaults.CACHE_SIZE_LINKS));
 
         return result;
     }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryInfoCache.java
 Thu Nov 20 16:42:35 2014
@@ -26,6 +26,7 @@ import org.apache.chemistry.opencmis.cli
 import 
org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 
 /**
@@ -35,8 +36,6 @@ public class RepositoryInfoCache impleme
 
     private static final long serialVersionUID = 1L;
 
-    private static final int CACHE_SIZE_REPOSITORIES = 10;
-
     private final Cache cache;
 
     /**
@@ -47,10 +46,11 @@ public class RepositoryInfoCache impleme
      */
     public RepositoryInfoCache(BindingSession session) {
         assert session != null;
-        
-        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, 
CACHE_SIZE_REPOSITORIES);
+
+        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES,
+                SessionParameterDefaults.CACHE_SIZE_REPOSITORIES);
         if (repCount < 1) {
-            repCount = CACHE_SIZE_REPOSITORIES;
+            repCount = SessionParameterDefaults.CACHE_SIZE_REPOSITORIES;
         }
 
         cache = new CacheImpl("Repository Info Cache");

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java
 Thu Nov 20 16:42:35 2014
@@ -25,6 +25,7 @@ import org.apache.chemistry.opencmis.cli
 import 
org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 
 /**
@@ -34,9 +35,6 @@ public class TypeDefinitionCacheImpl imp
 
     private static final long serialVersionUID = 1L;
 
-    private static final int CACHE_SIZE_REPOSITORIES = 10;
-    private static final int CACHE_SIZE_TYPES = 100;
-
     private Cache cache;
 
     /**
@@ -49,14 +47,15 @@ public class TypeDefinitionCacheImpl imp
     public void initialize(BindingSession session) {
         assert session != null;
 
-        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, 
CACHE_SIZE_REPOSITORIES);
+        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES,
+                SessionParameterDefaults.CACHE_SIZE_REPOSITORIES);
         if (repCount < 1) {
-            repCount = CACHE_SIZE_REPOSITORIES;
+            repCount = SessionParameterDefaults.CACHE_SIZE_REPOSITORIES;
         }
 
-        int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, 
CACHE_SIZE_TYPES);
+        int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, 
SessionParameterDefaults.CACHE_SIZE_TYPES);
         if (typeCount < 1) {
-            typeCount = CACHE_SIZE_TYPES;
+            typeCount = SessionParameterDefaults.CACHE_SIZE_TYPES;
         }
 
         cache = new CacheImpl("Type Definition Cache");

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/LinkCache.java
 Thu Nov 20 16:42:35 2014
@@ -30,6 +30,7 @@ import org.apache.chemistry.opencmis.cli
 import 
org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
@@ -58,10 +59,6 @@ public class LinkCache implements Serial
         KNOWN_LINKS.add(AtomPubParser.LINK_REL_CONTENT);
     }
 
-    private static final int CACHE_SIZE_REPOSITORIES = 10;
-    private static final int CACHE_SIZE_TYPES = 100;
-    private static final int CACHE_SIZE_OBJECTS = 400;
-
     private final Cache linkCache;
     private final Cache typeLinkCache;
     private final Cache collectionLinkCache;
@@ -72,19 +69,20 @@ public class LinkCache implements Serial
      * Constructor.
      */
     public LinkCache(BindingSession session) {
-        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, 
CACHE_SIZE_REPOSITORIES);
+        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES,
+                SessionParameterDefaults.CACHE_SIZE_REPOSITORIES);
         if (repCount < 1) {
-            repCount = CACHE_SIZE_REPOSITORIES;
+            repCount = SessionParameterDefaults.CACHE_SIZE_REPOSITORIES;
         }
 
-        int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, 
CACHE_SIZE_TYPES);
+        int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, 
SessionParameterDefaults.CACHE_SIZE_TYPES);
         if (typeCount < 1) {
-            typeCount = CACHE_SIZE_TYPES;
+            typeCount = SessionParameterDefaults.CACHE_SIZE_TYPES;
         }
 
-        int objCount = session.get(SessionParameter.CACHE_SIZE_LINKS, 
CACHE_SIZE_OBJECTS);
+        int objCount = session.get(SessionParameter.CACHE_SIZE_LINKS, 
SessionParameterDefaults.CACHE_SIZE_LINKS);
         if (objCount < 1) {
-            objCount = CACHE_SIZE_OBJECTS;
+            objCount = SessionParameterDefaults.CACHE_SIZE_LINKS;
         }
 
         linkCache = new CacheImpl("Link Cache");

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
 Thu Nov 20 16:42:35 2014
@@ -26,8 +26,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -61,6 +60,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.util.OperationContextUtils;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import 
org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
@@ -120,7 +120,7 @@ public class SessionImpl implements Sess
     // private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
     private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
-    private transient IdentityHashMap<TypeDefinition, ObjectType> 
objectTypeCache;
+    private transient LinkedHashMap<String, ObjectType> objectTypeCache;
 
     /*
      * default session context (serializable)
@@ -275,7 +275,7 @@ public class SessionImpl implements Sess
             cache = createCache();
 
             // clear object type cache
-            objectTypeCache = new IdentityHashMap<TypeDefinition, 
ObjectType>();
+            objectTypeCache = null;
 
             // clear provider cache
             getBinding().clearAllCaches();
@@ -770,7 +770,7 @@ public class SessionImpl implements Sess
         TypeDefinition typeDefinition = 
getBinding().getRepositoryService().getTypeDefinition(getRepositoryId(),
                 typeId, null);
 
-        return convertTypeDefinition(typeDefinition);
+        return convertAndCacheTypeDefinition(typeDefinition, true);
     }
 
     public ObjectType getTypeDefinition(String typeId, boolean useCache) {
@@ -783,7 +783,7 @@ public class SessionImpl implements Sess
         ExtendedRepositoryService extRepSrv = (ExtendedRepositoryService) 
service;
         TypeDefinition typeDefinition = 
extRepSrv.getTypeDefinition(getRepositoryId(), typeId, null, useCache);
 
-        return convertTypeDefinition(typeDefinition);
+        return convertAndCacheTypeDefinition(typeDefinition, useCache);
     }
 
     public List<Tree<ObjectType>> getTypeDescendants(String typeId, int depth, 
boolean includePropertyDefinitions) {
@@ -810,24 +810,56 @@ public class SessionImpl implements Sess
         return result;
     }
 
+    private ObjectType convertTypeDefinition(TypeDefinition typeDefinition) {
+        return objectFactory.convertTypeDefinition(typeDefinition);
+    }
+
     /**
-     * Converts a type definition into an object type. If the object type is
-     * cached, it returns the cached object. Otherwise it creates an object 
type
-     * object and puts it into the cache.
+     * Converts a type definition into an object type and caches the result.
+     * 
+     * The cache should only be used for type definitions that have been 
fetched
+     * with getTypeDefinition() because the high level cache should roughly
+     * correspond to the low level type cache. The type definitions returned by
+     * getTypeChildren() and getTypeDescendants() are not cached in the low
+     * level cache and therefore shouldn't be cached here.
      */
-    private ObjectType convertTypeDefinition(TypeDefinition typeDefinition) {
+    private ObjectType convertAndCacheTypeDefinition(TypeDefinition 
typeDefinition, boolean useCache) {
+        ObjectType result = null;
+
         lock.writeLock().lock();
         try {
-            ObjectType result = null;
             if (objectTypeCache == null) {
-                objectTypeCache = new IdentityHashMap<TypeDefinition, 
ObjectType>();
-            } else {
-                result = objectTypeCache.get(typeDefinition);
+                int cacheSize;
+                try {
+                    cacheSize = 
Integer.valueOf(parameters.get(SessionParameter.CACHE_SIZE_TYPES));
+                    if (cacheSize < 0) {
+                        cacheSize = SessionParameterDefaults.CACHE_SIZE_TYPES;
+                    }
+                } catch (NumberFormatException nfe) {
+                    cacheSize = SessionParameterDefaults.CACHE_SIZE_TYPES;
+                }
+
+                final int maxEntries = cacheSize;
+
+                objectTypeCache = new LinkedHashMap<String, 
ObjectType>(maxEntries + 1, 0.70f, true) {
+                    private static final long serialVersionUID = 1L;
+
+                    @Override
+                    public boolean removeEldestEntry(Map.Entry<String, 
ObjectType> eldest) {
+                        return size() > maxEntries;
+                    }
+                };
             }
 
-            if (result == null) {
+            if (!useCache) {
                 result = objectFactory.convertTypeDefinition(typeDefinition);
-                objectTypeCache.put(typeDefinition, result);
+                objectTypeCache.put(result.getId(), result);
+            } else {
+                result = objectTypeCache.get(typeDefinition.getId());
+                if (result == null) {
+                    result = 
objectFactory.convertTypeDefinition(typeDefinition);
+                    objectTypeCache.put(result.getId(), result);
+                }
             }
 
             return result;
@@ -836,6 +868,20 @@ public class SessionImpl implements Sess
         }
     }
 
+    /**
+     * Removes the object type object with the given type ID from the cache.
+     */
+    private void removeFromObjectTypeCache(String typeId) {
+        lock.writeLock().lock();
+        try {
+            if (objectTypeCache != null) {
+                objectTypeCache.remove(typeId);
+            }
+        } finally {
+            lock.writeLock().unlock();
+        }
+    }
+
     public ObjectType createType(TypeDefinition type) {
         if (repositoryInfo.getCmisVersion() == CmisVersion.CMIS_1_0) {
             throw new CmisNotSupportedException("This method is not supported 
for CMIS 1.0 repositories.");
@@ -866,29 +912,6 @@ public class SessionImpl implements Sess
         removeFromObjectTypeCache(typeId);
     }
 
-    /**
-     * Removes the object type object with the given type ID from the cache.
-     */
-    private void removeFromObjectTypeCache(String typeId) {
-        lock.writeLock().lock();
-        try {
-            if (objectTypeCache == null) {
-                return;
-            }
-
-            Iterator<TypeDefinition> iter = 
objectTypeCache.keySet().iterator();
-            while (iter.hasNext()) {
-                TypeDefinition typeDef = iter.next();
-                if (typeDef.getId().equals(typeId)) {
-                    iter.remove();
-                    break;
-                }
-            }
-        } finally {
-            lock.writeLock().unlock();
-        }
-    }
-
     public ItemIterable<QueryResult> query(final String statement, final 
boolean searchAllVersions) {
         return query(statement, searchAllVersions, getDefaultContext());
     }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java
 Thu Nov 20 16:42:35 2014
@@ -32,6 +32,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.SessionParameterDefaults;
 
 /**
  * Synchronized cache implementation. The cache is limited to a specific size 
of
@@ -71,17 +72,17 @@ public class CacheImpl implements Cache 
                     cacheSize = 0;
                 }
             } catch (Exception e) {
-                cacheSize = 1000;
+                cacheSize = SessionParameterDefaults.CACHE_SIZE_OBJECTS;
             }
 
             // cache time-to-live
             try {
                 cacheTtl = 
Integer.valueOf(parameters.get(SessionParameter.CACHE_TTL_OBJECTS));
                 if (cacheTtl < 0) {
-                    cacheTtl = 2 * 60 * 60 * 1000;
+                    cacheTtl = SessionParameterDefaults.CACHE_TTL_OBJECTS;
                 }
             } catch (Exception e) {
-                cacheTtl = 2 * 60 * 60 * 1000;
+                cacheTtl = SessionParameterDefaults.CACHE_TTL_OBJECTS;
             }
 
             // path-to-id size
@@ -91,17 +92,17 @@ public class CacheImpl implements Cache 
                     pathToIdSize = 0;
                 }
             } catch (Exception e) {
-                pathToIdSize = 1000;
+                pathToIdSize = SessionParameterDefaults.CACHE_SIZE_PATHTOID;
             }
 
             // path-to-id time-to-live
             try {
                 pathToIdTtl = 
Integer.valueOf(parameters.get(SessionParameter.CACHE_TTL_PATHTOID));
                 if (pathToIdTtl < 0) {
-                    pathToIdTtl = 30 * 60 * 1000;
+                    pathToIdTtl = SessionParameterDefaults.CACHE_TTL_PATHTOID;
                 }
             } catch (Exception e) {
-                pathToIdTtl = 30 * 60 * 1000;
+                pathToIdTtl = SessionParameterDefaults.CACHE_TTL_PATHTOID;
             }
 
             initializeInternals();

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1640764&r1=1640763&r2=1640764&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
 Thu Nov 20 16:42:35 2014
@@ -258,6 +258,14 @@ package org.apache.chemistry.opencmis.co
  * <td>1000</td>
  * </tr>
  * <tr>
+ * <td>{@link #CACHE_TTL_PATHTOID}</td>
+ * <td>Path-to-id cache time-to-live</td>
+ * <td>all</td>
+ * <td>time in milliseconds</td>
+ * <td>no</td>
+ * <td>180000 (30 minutes)</td>
+ * </tr>
+ * <tr>
  * <td>{@link #CACHE_PATH_OMIT}</td>
  * <td>Turn off path-to-id cache</td>
  * <td>all</td>

Added: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java?rev=1640764&view=auto
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java
 (added)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java
 Thu Nov 20 16:42:35 2014
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.chemistry.opencmis.commons;
+
+public class SessionParameterDefaults {
+
+    // utility class
+    private SessionParameterDefaults() {
+    }
+
+    public static final int CACHE_SIZE_OBJECTS = 1000;
+    public static final int CACHE_TTL_OBJECTS = 2 * 60 * 60 * 1000;
+    public static final int CACHE_SIZE_PATHTOID = 1000;
+    public static final int CACHE_TTL_PATHTOID = 30 * 60 * 1000;
+
+    public static final int CACHE_SIZE_REPOSITORIES = 10;
+    public static final int CACHE_SIZE_TYPES = 100;
+    public static final int CACHE_SIZE_LINKS = 400;
+}

Propchange: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameterDefaults.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to