chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1570876 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/or...
Date Sat, 22 Feb 2014 18:34:58 GMT
Author: fmui
Date: Sat Feb 22 18:34:57 2014
New Revision: 1570876

URL: http://svn.apache.org/r1570876
Log:
CMIS-752: added ability to provide a custom Type Definition Cache implementation

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/TypeDefinitionCache.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java
Removed:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCache.java
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/cache/Cache.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ClientTypeCacheImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.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/repository/RepositoryImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.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=1570876&r1=1570875&r2=1570876&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 Sat Feb 22 18:34:57 2014
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 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.spi.AuthenticationProvider;
@@ -41,7 +42,9 @@ public class CmisBindingFactory {
     /** Default CMIS local binding SPI implementation. */
     public static final String BINDING_SPI_LOCAL = "org.apache.chemistry.opencmis.client.bindings.spi.local.CmisLocalSpi";
 
-    /** Default HTTP invoker clas.s */
+    /** Default type definition cache class */
+    public static final String DEFAULT_TYPE_DEFINITION_CACHE_CLASS = "org.apache.chemistry.opencmis.client.bindings.impl.TypeDefinitionCacheImpl";
+    /** Default HTTP invoker class */
     public static final String DEFAULT_HTTP_INVOKER = "org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker";
     /** Standard authentication provider class. */
     public static final String STANDARD_AUTHENTICATION_PROVIDER = "org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider";
@@ -87,7 +90,7 @@ public class CmisBindingFactory {
      * the session parameters.
      */
     public CmisBinding createCmisBinding(Map<String, String> sessionParameters) {
-        return createCmisBinding(sessionParameters, null);
+        return createCmisBinding(sessionParameters, null, null);
     }
 
     /**
@@ -95,19 +98,19 @@ public class CmisBindingFactory {
      * the session parameters.
      */
     public CmisBinding createCmisBinding(Map<String, String> sessionParameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         checkSessionParameters(sessionParameters, true);
 
         addDefaultParameters(sessionParameters);
 
-        return new CmisBindingImpl(sessionParameters, authenticationProvider);
+        return new CmisBindingImpl(sessionParameters, authenticationProvider, typeDefCache);
     }
 
     /**
      * Creates a default CMIS AtomPub binding instance.
      */
     public CmisBinding createCmisAtomPubBinding(Map<String, String> sessionParameters) {
-        return createCmisAtomPubBinding(sessionParameters, null);
+        return createCmisAtomPubBinding(sessionParameters, null, null);
     }
 
     /**
@@ -115,7 +118,7 @@ public class CmisBindingFactory {
      * authentication provider.
      */
     public CmisBinding createCmisAtomPubBinding(Map<String, String> sessionParameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         checkSessionParameters(sessionParameters, false);
 
         sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_ATOMPUB);
@@ -127,6 +130,11 @@ public class CmisBindingFactory {
                 sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
             }
         }
+        if (typeDefCache == null) {
+            if (!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
+                sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+            }
+        }
         if (!sessionParameters.containsKey(SessionParameter.AUTH_HTTP_BASIC)) {
             sessionParameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
         }
@@ -135,14 +143,14 @@ public class CmisBindingFactory {
 
         check(sessionParameters, SessionParameter.ATOMPUB_URL);
 
-        return new CmisBindingImpl(sessionParameters, authenticationProvider);
+        return new CmisBindingImpl(sessionParameters, authenticationProvider, typeDefCache);
     }
 
     /**
      * Creates a default CMIS Web Services binding instance.
      */
     public CmisBinding createCmisWebServicesBinding(Map<String, String> sessionParameters) {
-        return createCmisWebServicesBinding(sessionParameters, null);
+        return createCmisWebServicesBinding(sessionParameters, null, null);
     }
 
     /**
@@ -150,7 +158,7 @@ public class CmisBindingFactory {
      * authentication provider.
      */
     public CmisBinding createCmisWebServicesBinding(Map<String, String> sessionParameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         checkSessionParameters(sessionParameters, false);
 
         sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_WEBSERVICES);
@@ -162,6 +170,11 @@ public class CmisBindingFactory {
                 sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
             }
         }
+        if (typeDefCache == null) {
+            if (!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
+                sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+            }
+        }
         if (!sessionParameters.containsKey(SessionParameter.AUTH_SOAP_USERNAMETOKEN)) {
             sessionParameters.put(SessionParameter.AUTH_SOAP_USERNAMETOKEN, "true");
         }
@@ -189,14 +202,14 @@ public class CmisBindingFactory {
         check(sessionParameters, SessionParameter.WEBSERVICES_VERSIONING_SERVICE,
                 SessionParameter.WEBSERVICES_VERSIONING_SERVICE_ENDPOINT);
 
-        return new CmisBindingImpl(sessionParameters, authenticationProvider);
+        return new CmisBindingImpl(sessionParameters, authenticationProvider, typeDefCache);
     }
 
     /**
      * Creates a default CMIS Browser binding instance.
      */
     public CmisBinding createCmisBrowserBinding(Map<String, String> sessionParameters) {
-        return createCmisBrowserBinding(sessionParameters, null);
+        return createCmisBrowserBinding(sessionParameters, null, null);
     }
 
     /**
@@ -204,7 +217,7 @@ public class CmisBindingFactory {
      * authentication provider.
      */
     public CmisBinding createCmisBrowserBinding(Map<String, String> sessionParameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         checkSessionParameters(sessionParameters, false);
 
         sessionParameters.put(SessionParameter.BINDING_SPI_CLASS, BINDING_SPI_BROWSER);
@@ -216,6 +229,11 @@ public class CmisBindingFactory {
                 sessionParameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, STANDARD_AUTHENTICATION_PROVIDER);
             }
         }
+        if (typeDefCache == null) {
+            if (!sessionParameters.containsKey(SessionParameter.TYPE_DEFINITION_CACHE_CLASS)) {
+                sessionParameters.put(SessionParameter.TYPE_DEFINITION_CACHE_CLASS, DEFAULT_TYPE_DEFINITION_CACHE_CLASS);
+            }
+        }
         if (!sessionParameters.containsKey(SessionParameter.BROWSER_SUCCINCT)) {
             sessionParameters.put(SessionParameter.BROWSER_SUCCINCT, "true");
         }
@@ -227,16 +245,28 @@ public class CmisBindingFactory {
 
         check(sessionParameters, SessionParameter.BROWSER_URL);
 
-        return new CmisBindingImpl(sessionParameters, authenticationProvider);
+        return new CmisBindingImpl(sessionParameters, authenticationProvider, typeDefCache);
     }
 
     /**
      * Creates a default CMIS local binding instance.
      */
     public CmisBinding createCmisLocalBinding(Map<String, String> sessionParameters) {
+        return createCmisLocalBinding(sessionParameters, null);
+    }
+
+    /**
+     * Creates a default CMIS local binding instance.
+     */
+    public CmisBinding createCmisLocalBinding(Map<String, String> sessionParameters, TypeDefinitionCache typeDefCache) {
         checkSessionParameters(sessionParameters, false);
 
         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);
+            }
+        }
         addDefaultParameters(sessionParameters);
 
         check(sessionParameters, SessionParameter.LOCAL_FACTORY);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/Cache.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/cache/Cache.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/Cache.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/Cache.java Sat Feb 22 18:34:57 2014
@@ -76,6 +76,11 @@ public interface Cache extends Serializa
     void remove(String... keys);
 
     /**
+     * Removes all entries from the cache.
+     */
+    void removeAll();
+    
+    /**
      * Checks if a given key is in the cache.
      * 
      * @param keys

Added: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/TypeDefinitionCache.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/cache/TypeDefinitionCache.java?rev=1570876&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/TypeDefinitionCache.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/TypeDefinitionCache.java Sat Feb 22 18:34:57 2014
@@ -0,0 +1,82 @@
+/*
+ * 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.client.bindings.cache;
+
+import java.io.Serializable;
+
+import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+
+/**
+ * A cache for type definition objects.
+ * <p>
+ * Implementations of this interface have to be tread-safe.
+ */
+public interface TypeDefinitionCache extends Serializable {
+
+    /**
+     * Initializes the cache.
+     */
+    void initialize(BindingSession session);
+
+    /**
+     * Adds a type definition object to the cache.
+     * 
+     * @param repositoryId
+     *            the repository id
+     * @param typeDefinition
+     *            the type definition object
+     */
+    void put(String repositoryId, TypeDefinition typeDefinition);
+
+    /**
+     * Retrieves a type definition object from the cache.
+     * 
+     * @param repositoryId
+     *            the repository id
+     * @param typeId
+     *            the type id
+     * @return the type definition object or <code>null</code> if the object is
+     *         not in the cache
+     */
+    TypeDefinition get(String repositoryId, String typeId);
+
+    /**
+     * Removes a type definition object from the cache.
+     * 
+     * @param repositoryId
+     *            the repository id
+     * @param typeId
+     *            the type id
+     */
+    void remove(String repositoryId, String typeId);
+
+    /**
+     * Removes all type definition objects of a repository from the cache.
+     * 
+     * @param repositoryId
+     *            the repository id
+     */
+    void remove(String repositoryId);
+
+    /**
+     * Removes all cache entries.
+     */
+    void removeAll();
+}
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.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/cache/impl/CacheImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/CacheImpl.java Sat Feb 22 18:34:57 2014
@@ -237,6 +237,19 @@ public class CacheImpl implements Cache 
         }
     }
 
+    public void removeAll() {
+        lock.writeLock().lock();
+        try {
+            root = createCacheLevel(0);
+
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("{}: removed all", name);
+            }
+        } finally {
+            lock.writeLock().unlock();
+        }
+    }
+
     public int check(String... keys) {
         if (keys == null) {
             return -1;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.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/CmisBindingImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java Sat Feb 22 18:34:57 2014
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.cl
 import java.io.Serializable;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
 import org.apache.chemistry.opencmis.client.bindings.spi.SessionAwareAuthenticationProvider;
@@ -59,7 +60,7 @@ public final class CmisBindingImpl imple
      *            the session parameters
      */
     public CmisBindingImpl(Map<String, String> sessionParameters) {
-        this(sessionParameters, null);
+        this(sessionParameters, null, null);
     }
 
     /**
@@ -70,7 +71,8 @@ public final class CmisBindingImpl imple
      * @param authenticationProvider
      *            an authentication provider instance
      */
-    public CmisBindingImpl(final Map<String, String> sessionParameters, AuthenticationProvider authenticationProvider) {
+    public CmisBindingImpl(final Map<String, String> sessionParameters, AuthenticationProvider authenticationProvider,
+            TypeDefinitionCache typeDefCache) {
         // some checks first
         if (sessionParameters == null) {
             throw new IllegalArgumentException("Session parameters must be set!");
@@ -137,6 +139,12 @@ public final class CmisBindingImpl imple
             }
         }
 
+        // add type definition cache to session
+        if (typeDefCache != null) {
+            session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, typeDefCache);
+            typeDefCache.initialize(session);
+        }
+
         // set up caches
         clearAllCaches();
 
@@ -229,7 +237,8 @@ public final class CmisBindingImpl imple
         session.writeLock();
         try {
             session.put(CmisBindingsHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(session));
-            session.put(CmisBindingsHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(session));
+            TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session);
+            typeDefCache.removeAll();
 
             CmisSpi spi = CmisBindingsHelper.getSPI(session);
             spi.clearAllCaches();
@@ -251,8 +260,7 @@ public final class CmisBindingImpl imple
                     .get(CmisBindingsHelper.REPOSITORY_INFO_CACHE);
             repInfoCache.remove(repositoryId);
 
-            TypeDefinitionCache typeDefCache = (TypeDefinitionCache) session
-                    .get(CmisBindingsHelper.TYPE_DEFINTION_CACHE);
+            TypeDefinitionCache typeDefCache = CmisBindingsHelper.getTypeDefinitionCache(session);
             typeDefCache.remove(repositoryId);
 
             CmisSpi spi = CmisBindingsHelper.getSPI(session);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.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/CmisBindingsHelper.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java Sat Feb 22 18:34:57 2014
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.cl
 
 import java.lang.reflect.Constructor;
 
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpInvoker;
@@ -174,6 +175,39 @@ public final class CmisBindingsHelper {
     public static TypeDefinitionCache getTypeDefinitionCache(BindingSession session) {
         assert session != null;
 
-        return (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
+        TypeDefinitionCache cache = (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
+
+        if (cache != null) {
+            return cache;
+        }
+
+        session.writeLock();
+        try {
+            // try again
+            cache = (TypeDefinitionCache) session.get(TYPE_DEFINTION_CACHE);
+            if (cache != null) {
+                return cache;
+            }
+
+            // ok, we have to create it...
+            try {
+                String cacheName = (String) session.get(SessionParameter.TYPE_DEFINITION_CACHE_CLASS);
+                cache = (TypeDefinitionCache) ClassLoaderUtil.loadClass(cacheName).newInstance();
+                cache.initialize(session);
+            } catch (CmisBaseException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new CmisRuntimeException("Type definition cache cannot be initialized: " + e.getMessage(), e);
+            }
+
+            // we have a cache object -> put it into the session
+            session.put(TYPE_DEFINTION_CACHE, cache);
+        } finally {
+            session.writeUnlock();
+        }
+
+        assert cache != null;
+
+        return cache;
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.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/RepositoryServiceImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/RepositoryServiceImpl.java Sat Feb 22 18:34:57 2014
@@ -23,6 +23,7 @@ import java.io.Serializable;
 import java.math.BigInteger;
 import java.util.List;
 
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;

Added: 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=1570876&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/TypeDefinitionCacheImpl.java Sat Feb 22 18:34:57 2014
@@ -0,0 +1,98 @@
+/*
+ * 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.client.bindings.impl;
+
+import org.apache.chemistry.opencmis.client.bindings.cache.Cache;
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
+import org.apache.chemistry.opencmis.client.bindings.cache.impl.CacheImpl;
+import org.apache.chemistry.opencmis.client.bindings.cache.impl.LruCacheLevelImpl;
+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.definitions.TypeDefinition;
+
+/**
+ * A cache for type definition objects.
+ */
+public class TypeDefinitionCacheImpl implements TypeDefinitionCache {
+
+    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;
+
+    /**
+     * Constructor.
+     */
+    public TypeDefinitionCacheImpl() {
+
+    }
+
+    public void initialize(BindingSession session) {
+        assert session != null;
+
+        int repCount = session.get(SessionParameter.CACHE_SIZE_REPOSITORIES, CACHE_SIZE_REPOSITORIES);
+        if (repCount < 1) {
+            repCount = CACHE_SIZE_REPOSITORIES;
+        }
+
+        int typeCount = session.get(SessionParameter.CACHE_SIZE_TYPES, CACHE_SIZE_TYPES);
+        if (typeCount < 1) {
+            typeCount = CACHE_SIZE_TYPES;
+        }
+
+        cache = new CacheImpl("Type Definition Cache");
+        cache.initialize(new String[] {
+                MapCacheLevelImpl.class.getName() + " " + MapCacheLevelImpl.CAPACITY + "=" + repCount, // repository
+                LruCacheLevelImpl.class.getName() + " " + LruCacheLevelImpl.MAX_ENTRIES + "=" + typeCount // type
+        });
+    }
+
+    public void put(String repositoryId, TypeDefinition typeDefinition) {
+        if ((typeDefinition == null) || (typeDefinition.getId() == null)) {
+            return;
+        }
+
+        cache.put(typeDefinition, repositoryId, typeDefinition.getId());
+    }
+
+    public TypeDefinition get(String repositoryId, String typeId) {
+        return (TypeDefinition) cache.get(repositoryId, typeId);
+    }
+
+    public void remove(String repositoryId, String typeId) {
+        cache.remove(repositoryId, typeId);
+    }
+
+    public void remove(String repositoryId) {
+        cache.remove(repositoryId);
+    }
+
+    public void removeAll() {
+        cache.removeAll();
+    }
+
+    @Override
+    public String toString() {
+        return cache.toString();
+    }
+
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ClientTypeCacheImpl.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/browser/ClientTypeCacheImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ClientTypeCacheImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ClientTypeCacheImpl.java Sat Feb 22 18:34:57 2014
@@ -18,8 +18,8 @@
  */
 package org.apache.chemistry.opencmis.client.bindings.spi.browser;
 
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
-import org.apache.chemistry.opencmis.client.bindings.impl.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.impl.TypeCache;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.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/CmisBindingHelper.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/CmisBindingHelper.java Sat Feb 22 18:34:57 2014
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.cl
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
@@ -39,7 +40,7 @@ public final class CmisBindingHelper {
      * Creates a {@link CmisBinding} object.
      */
     public static CmisBinding createBinding(Map<String, String> parameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         if (parameters == null || parameters.isEmpty()) {
             throw new CmisRuntimeException("Session parameter not set!");
         }
@@ -52,15 +53,15 @@ public final class CmisBindingHelper {
 
         switch (bt) {
         case ATOMPUB:
-            return createAtomPubBinding(parameters, authenticationProvider);
+            return createAtomPubBinding(parameters, authenticationProvider, typeDefCache);
         case WEBSERVICES:
-            return createWebServiceBinding(parameters, authenticationProvider);
+            return createWebServiceBinding(parameters, authenticationProvider, typeDefCache);
         case BROWSER:
-            return createCmisBrowserBinding(parameters, authenticationProvider);
+            return createCmisBrowserBinding(parameters, authenticationProvider, typeDefCache);
         case LOCAL:
-            return createLocalBinding(parameters);
+            return createLocalBinding(parameters, typeDefCache);
         case CUSTOM:
-            return createCustomBinding(parameters, authenticationProvider);
+            return createCustomBinding(parameters, authenticationProvider, typeDefCache);
         default:
             throw new CmisRuntimeException("Ambiguous session parameter: " + parameters);
         }
@@ -70,9 +71,9 @@ public final class CmisBindingHelper {
      * Creates a binding with custom parameters.
      */
     private static CmisBinding createCustomBinding(Map<String, String> parameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisBinding(parameters, authenticationProvider);
+        CmisBinding binding = factory.createCmisBinding(parameters, authenticationProvider, typeDefCache);
 
         return binding;
     }
@@ -81,9 +82,9 @@ public final class CmisBindingHelper {
      * Creates a Web Services binding.
      */
     private static CmisBinding createWebServiceBinding(Map<String, String> parameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisWebServicesBinding(parameters, authenticationProvider);
+        CmisBinding binding = factory.createCmisWebServicesBinding(parameters, authenticationProvider, typeDefCache);
 
         return binding;
     }
@@ -92,9 +93,9 @@ public final class CmisBindingHelper {
      * Creates an AtomPub binding.
      */
     private static CmisBinding createAtomPubBinding(Map<String, String> parameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisAtomPubBinding(parameters, authenticationProvider);
+        CmisBinding binding = factory.createCmisAtomPubBinding(parameters, authenticationProvider, typeDefCache);
 
         return binding;
     }
@@ -103,9 +104,9 @@ public final class CmisBindingHelper {
      * Creates an Browser binding.
      */
     private static CmisBinding createCmisBrowserBinding(Map<String, String> parameters,
-            AuthenticationProvider authenticationProvider) {
+            AuthenticationProvider authenticationProvider, TypeDefinitionCache typeDefCache) {
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisBrowserBinding(parameters, authenticationProvider);
+        CmisBinding binding = factory.createCmisBrowserBinding(parameters, authenticationProvider, typeDefCache);
 
         return binding;
     }
@@ -113,9 +114,9 @@ public final class CmisBindingHelper {
     /**
      * Creates a local binding.
      */
-    private static CmisBinding createLocalBinding(Map<String, String> parameters) {
+    private static CmisBinding createLocalBinding(Map<String, String> parameters, TypeDefinitionCache typeDefCache) {
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisLocalBinding(parameters);
+        CmisBinding binding = factory.createCmisLocalBinding(parameters, typeDefCache);
 
         return binding;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.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/SessionFactoryImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionFactoryImpl.java Sat Feb 22 18:34:57 2014
@@ -27,6 +27,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Repository;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.api.SessionFactory;
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
 import org.apache.chemistry.opencmis.client.runtime.repository.RepositoryImpl;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
@@ -64,7 +65,16 @@ public class SessionFactoryImpl implemen
     }
 
     public Session createSession(Map<String, String> parameters) {
-        return createSession(parameters, null, null, null);
+        return createSession(parameters, null, null, null, null);
+    }
+
+    /**
+     * @deprecated Use
+     *             {@link #createSession(Map, ObjectFactory, AuthenticationProvider, Cache)}
+     */
+    public Session createSession(Map<String, String> parameters, ObjectFactory objectFactory,
+            AuthenticationProvider authenticationProvider, Cache cache) {
+        return createSession(parameters, objectFactory, authenticationProvider, cache, null);
     }
 
     /**
@@ -81,6 +91,8 @@ public class SessionFactoryImpl implemen
      *            an authentication provider instance
      * @param cache
      *            a cache instance
+     * @param typeDefCache
+     *            a type definition cache instance
      * @return a {@link Session} connected to the CMIS repository
      * @throws CmisBaseException
      *             if the connection could not be established
@@ -88,15 +100,24 @@ public class SessionFactoryImpl implemen
      * @see SessionParameter
      */
     public Session createSession(Map<String, String> parameters, ObjectFactory objectFactory,
-            AuthenticationProvider authenticationProvider, Cache cache) {
-        SessionImpl session = new SessionImpl(parameters, objectFactory, authenticationProvider, cache);
+            AuthenticationProvider authenticationProvider, Cache cache, TypeDefinitionCache typeDefCache) {
+        SessionImpl session = new SessionImpl(parameters, objectFactory, authenticationProvider, cache, typeDefCache);
         session.connect();
 
         return session;
     }
 
     public List<Repository> getRepositories(Map<String, String> parameters) {
-        return getRepositories(parameters, null, null, null);
+        return getRepositories(parameters, null, null, null, null);
+    }
+
+    /**
+     * @deprecated Use
+     *             {@link #getRepositories(Map, ObjectFactory, AuthenticationProvider, Cache, TypeDefinitionCache)}
+     */
+    public List<Repository> getRepositories(Map<String, String> parameters, ObjectFactory objectFactory,
+            AuthenticationProvider authenticationProvider, Cache cache) {
+        return getRepositories(parameters, objectFactory, authenticationProvider, cache, null);
     }
 
     /**
@@ -106,15 +127,15 @@ public class SessionFactoryImpl implemen
      * {@code SessionParameter.REPOSITORY_ID} should not be set.
      */
     public List<Repository> getRepositories(Map<String, String> parameters, ObjectFactory objectFactory,
-            AuthenticationProvider authenticationProvider, Cache cache) {
-        CmisBinding binding = CmisBindingHelper.createBinding(parameters, authenticationProvider);
+            AuthenticationProvider authenticationProvider, Cache cache, TypeDefinitionCache typeDefCache) {
+        CmisBinding binding = CmisBindingHelper.createBinding(parameters, authenticationProvider, typeDefCache);
 
         List<RepositoryInfo> repositoryInfos = binding.getRepositoryService().getRepositoryInfos(null);
 
         List<Repository> result = new ArrayList<Repository>();
         for (RepositoryInfo data : repositoryInfos) {
             result.add(new RepositoryImpl(data, parameters, this, objectFactory, binding.getAuthenticationProvider(),
-                    cache));
+                    cache, typeDefCache));
         }
 
         return result;

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=1570876&r1=1570875&r2=1570876&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 Sat Feb 22 18:34:57 2014
@@ -47,6 +47,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.SecondaryType;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.api.Tree;
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
 import org.apache.chemistry.opencmis.client.runtime.cache.CacheImpl;
 import org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl;
@@ -149,6 +150,11 @@ public class SessionImpl implements Sess
     private final boolean cachePathOmit;
 
     /*
+     * Type cache.
+     */
+    private TypeDefinitionCache typeDefCache;
+
+    /*
      * Repository info (serializable)
      */
     private RepositoryInfo repositoryInfo;
@@ -162,7 +168,7 @@ public class SessionImpl implements Sess
      * Constructor.
      */
     public SessionImpl(Map<String, String> parameters, ObjectFactory objectFactory,
-            AuthenticationProvider authenticationProvider, Cache cache) {
+            AuthenticationProvider authenticationProvider, Cache cache, TypeDefinitionCache typeDefCache) {
         if (parameters == null) {
             throw new IllegalArgumentException("No parameters provided!");
         }
@@ -173,6 +179,7 @@ public class SessionImpl implements Sess
         this.objectFactory = (objectFactory == null ? createObjectFactory() : objectFactory);
         this.authenticationProvider = authenticationProvider;
         this.cache = (cache == null ? createCache() : cache);
+        this.typeDefCache = typeDefCache;
 
         cachePathOmit = Boolean.parseBoolean(parameters.get(SessionParameter.CACHE_PATH_OMIT));
     }
@@ -790,7 +797,7 @@ public class SessionImpl implements Sess
     public void connect() {
         lock.writeLock().lock();
         try {
-            this.binding = CmisBindingHelper.createBinding(parameters, authenticationProvider);
+            this.binding = CmisBindingHelper.createBinding(parameters, authenticationProvider, typeDefCache);
 
             /* get initial repository id from session parameter */
             String repositoryId = parameters.get(SessionParameter.REPOSITORY_ID);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.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/repository/RepositoryImpl.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/RepositoryImpl.java Sat Feb 22 18:34:57 2014
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.chemistry.opencmis.client.api.ObjectFactory;
 import org.apache.chemistry.opencmis.client.api.Repository;
 import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.bindings.cache.TypeDefinitionCache;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
 import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
@@ -40,12 +41,14 @@ public class RepositoryImpl extends Repo
     private final ObjectFactory objectFactory;
     private final AuthenticationProvider authenticationProvider;
     private final Cache cache;
+    private final TypeDefinitionCache typeDefCache;
 
     /**
      * Constructor.
      */
     public RepositoryImpl(RepositoryInfo data, Map<String, String> parameters, SessionFactoryImpl sessionFactory,
-            ObjectFactory objectFactory, AuthenticationProvider authenticationProvider, Cache cache) {
+            ObjectFactory objectFactory, AuthenticationProvider authenticationProvider, Cache cache,
+            TypeDefinitionCache typeDefCache) {
         super(data);
 
         assert sessionFactory != null;
@@ -57,10 +60,11 @@ public class RepositoryImpl extends Repo
         this.objectFactory = objectFactory;
         this.authenticationProvider = authenticationProvider;
         this.cache = cache;
+        this.typeDefCache = typeDefCache;
     }
 
     @SuppressWarnings("unchecked")
     public <T extends Session> T createSession() {
-        return (T) sessionFactory.createSession(parameters, objectFactory, authenticationProvider, cache);
+        return (T) sessionFactory.createSession(parameters, objectFactory, authenticationProvider, cache, typeDefCache);
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java?rev=1570876&r1=1570875&r2=1570876&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementTest.java Sat Feb 22 18:34:57 2014
@@ -32,7 +32,7 @@ public class QueryStatementTest {
 
     @Test
     public void testStaticQueries() {
-        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null);
+        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null, null);
         String query;
         QueryStatement st;
 
@@ -52,7 +52,7 @@ public class QueryStatementTest {
 
     @Test
     public void testWherePlacholder() {
-        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null);
+        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null, null);
         String query;
         QueryStatement st;
 
@@ -81,41 +81,36 @@ public class QueryStatementTest {
 
         // contains
 
-        // *, ? and - are treated as text search operators: 1st level escaping: none, 2nd level escaping: none
-        // \*, \? and \- are used as literals, 1st level escaping: none, 2nd level escaping: \\*, \\?, \\-
-        // ' and " are used as literals, 1st level escaping: \', \", 2nd level escaping:  \\\', \\\",
-        // \ plus any other character, 1st level escaping \\ plus character, 2nd level: \\\\ plus character
+        // *, ? and - are treated as text search operators: 1st level escaping:
+        // none, 2nd level escaping: none
+        // \*, \? and \- are used as literals, 1st level escaping: none, 2nd
+        // level escaping: \\*, \\?, \\-
+        // ' and " are used as literals, 1st level escaping: \', \", 2nd level
+        // escaping: \\\', \\\",
+        // \ plus any other character, 1st level escaping \\ plus character, 2nd
+        // level: \\\\ plus character
 
         query = "SELECT * FROM cmis:document WHERE CONTAINS(?)";
         st = new QueryStatementImpl(session, query);
         st.setStringContains(1, "John's");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('John\\\\\\'s')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('John\\\\\\'s')", st.toQueryString());
         st.setStringContains(1, "foo -bar");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo -bar')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo -bar')", st.toQueryString());
         st.setStringContains(1, "foo*");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo*')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo*')", st.toQueryString());
         st.setStringContains(1, "foo?");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo?')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo?')", st.toQueryString());
         st.setStringContains(1, "foo\\-bar");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\-bar')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\-bar')", st.toQueryString());
         st.setStringContains(1, "foo\\*");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\*')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\*')", st.toQueryString());
         st.setStringContains(1, "foo\\?");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\?')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('foo\\\\?')", st.toQueryString());
         st.setStringContains(1, "\"Cool\"");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('\\\\\\\"Cool\\\\\\\"')",
-                st.toQueryString());
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('\\\\\\\"Cool\\\\\\\"')", st.toQueryString());
         st.setStringContains(1, "c:\\MyDcuments");
-        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('c:\\\\MyDcuments')",
-                st.toQueryString());
-       
+        assertEquals("SELECT * FROM cmis:document WHERE CONTAINS('c:\\\\MyDcuments')", st.toQueryString());
+
         // ids
         query = "SELECT * FROM cmis:document WHERE abc:id = ?";
         st = new QueryStatementImpl(session, query);
@@ -170,11 +165,11 @@ public class QueryStatementTest {
         assertEquals("SELECT * FROM cmis:document WHERE abc:dateTime "
                 + "IN (TIMESTAMP '2012-02-02T03:04:05.000Z',TIMESTAMP '2012-02-02T03:04:05.000Z')", st.toQueryString());
     }
-    
-//    @Test
+
+    // @Test
     public void testQueryApiEscaping() {
         // contains
-        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null);
+        Session session = new SessionImpl(new HashMap<String, String>(), null, null, null, null);
 
         String query = "SELECT * FROM cmis:document WHERE CONTAINS(?)";
         String ss = "a\\xc";
@@ -182,10 +177,10 @@ public class QueryStatementTest {
         System.out.println(ss);
         QueryStatement st = new QueryStatementImpl(session, query);
         st.setStringContains(1, "John's");
-        System.out.println("setStringContains: "+ st.toQueryString());
+        System.out.println("setStringContains: " + st.toQueryString());
         String expected = "SELECT * FROM cmis:document WHERE CONTAINS('John\\\'s')";
         System.out.println("Expected: " + expected);
-        
+
         assertEquals(expected, st.toQueryString());
 
     }

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=1570876&r1=1570875&r2=1570876&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 Sat Feb 22 18:34:57 2014
@@ -217,6 +217,15 @@ package org.apache.chemistry.opencmis.co
  * <td>org.apache.chemistry.opencmis.client.runtime.cache.CacheImpl</td>
  * </tr>
  * <tr>
+ * <td>{@link #TYPE_DEFINITION_CACHE_CLASS}</td>
+ * <td>Type definition cache implementation class</td>
+ * <td>all</td>
+ * <td>class name</td>
+ * <td>no</td>
+ * <td>
+ * org.apache.chemistry.opencmis.client.bindings.impl.TypeDefinitionCacheImpl</td>
+ * </tr>
+ * <tr>
  * <td>{@link #CACHE_SIZE_OBJECTS}</td>
  * <td>Object cache size</td>
  * <td>all</td>
@@ -625,6 +634,7 @@ public final class SessionParameter {
 
     public static final String OBJECT_FACTORY_CLASS = "org.apache.chemistry.opencmis.objectfactory.classname";
     public static final String CACHE_CLASS = "org.apache.chemistry.opencmis.cache.classname";
+    public static final String TYPE_DEFINITION_CACHE_CLASS = "org.apache.chemistry.opencmis.cache.types.classname";
 
     public static final String REPOSITORY_ID = "org.apache.chemistry.opencmis.session.repository.id";
 }



Mime
View raw message