chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r921774 - in /incubator/chemistry/trunk/opencmis: opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/ opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/...
Date Thu, 11 Mar 2010 10:21:19 GMT
Author: fmui
Date: Thu Mar 11 10:21:18 2010
New Revision: 921774

URL: http://svn.apache.org/viewvc?rev=921774&view=rev
Log:
first step to make provider layer thread-safe (CMIS-155)

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderHelper.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/RepositoryServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/SessionImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/Session.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/CmisAtomPubSpi.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/PolicyServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/AclServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/CmisWebServicesSpi.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/DiscoveryServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/MultiFilingServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/NavigationServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/ObjectServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PolicyServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PortProvider.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RelationshipServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RepositoryServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/VersioningServiceImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-commons/opencmis-commons-impl/src/main/java/org/apache/opencmis/commons/impl/dataobjects/ProviderObjectFactoryImpl.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/cache/impl/CacheImpl.java Thu Mar 11 10:21:18 2010
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -47,6 +48,8 @@ public class CacheImpl implements Cache 
 
   private CacheLevel fRoot;
 
+  private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
   /**
    * Constructor.
    */
@@ -75,22 +78,28 @@ public class CacheImpl implements Cache 
       throw new IllegalArgumentException("Cache config must not be empty!");
     }
 
-    fLevels = new ArrayList<Class<?>>();
-    fLevelParameters = new ArrayList<Map<String, String>>();
+    fLock.writeLock().lock();
+    try {
+      fLevels = new ArrayList<Class<?>>();
+      fLevelParameters = new ArrayList<Map<String, String>>();
 
-    // build level lists
-    for (String config : cacheLevelConfig) {
-      int x = config.indexOf(' ');
-      if (x == -1) {
-        addLevel(config, null);
-      }
-      else {
-        addLevel(config.substring(0, x), config.substring(x + 1));
+      // build level lists
+      for (String config : cacheLevelConfig) {
+        int x = config.indexOf(' ');
+        if (x == -1) {
+          addLevel(config, null);
+        }
+        else {
+          addLevel(config.substring(0, x), config.substring(x + 1));
+        }
       }
-    }
 
-    // create root
-    fRoot = createCacheLevel(0);
+      // create root
+      fRoot = createCacheLevel(0);
+    }
+    finally {
+      fLock.writeLock().unlock();
+    }
   }
 
   private void addLevel(String className, String parameters) {
@@ -147,23 +156,33 @@ public class CacheImpl implements Cache 
       throw new IllegalArgumentException("Wrong number of keys!");
     }
 
-    CacheLevel cacheLevel = fRoot;
+    Object result = null;
 
-    // follow the branch
-    for (int i = 0; i < keys.length - 1; i++) {
-      Object level = cacheLevel.get(keys[i]);
-
-      // does the branch exist?
-      if (level == null) {
-        return null;
+    fLock.readLock().lock();
+    try {
+      CacheLevel cacheLevel = fRoot;
+
+      // follow the branch
+      for (int i = 0; i < keys.length - 1; i++) {
+        Object level = cacheLevel.get(keys[i]);
+
+        // does the branch exist?
+        if (level == null) {
+          return null;
+        }
+
+        // next level
+        cacheLevel = (CacheLevel) level;
       }
 
-      // next level
-      cacheLevel = (CacheLevel) level;
+      // get the value
+      result = cacheLevel.get(keys[keys.length - 1]);
+    }
+    finally {
+      fLock.readLock().unlock();
     }
 
-    // get the value and return
-    return cacheLevel.get(keys[keys.length - 1]);
+    return result;
   }
 
   /*
@@ -182,26 +201,32 @@ public class CacheImpl implements Cache 
       throw new IllegalArgumentException("Wrong number of keys!");
     }
 
-    CacheLevel cacheLevel = fRoot;
+    fLock.writeLock().lock();
+    try {
+      CacheLevel cacheLevel = fRoot;
 
-    // follow the branch
-    for (int i = 0; i < keys.length - 1; i++) {
-      Object level = cacheLevel.get(keys[i]);
-
-      // does the branch exist?
-      if (level == null) {
-        level = createCacheLevel(i + 1);
-        cacheLevel.put(level, keys[i]);
-      }
+      // follow the branch
+      for (int i = 0; i < keys.length - 1; i++) {
+        Object level = cacheLevel.get(keys[i]);
+
+        // does the branch exist?
+        if (level == null) {
+          level = createCacheLevel(i + 1);
+          cacheLevel.put(level, keys[i]);
+        }
 
-      // next level
-      cacheLevel = (CacheLevel) level;
-    }
+        // next level
+        cacheLevel = (CacheLevel) level;
+      }
 
-    cacheLevel.put(value, keys[keys.length - 1]);
+      cacheLevel.put(value, keys[keys.length - 1]);
 
-    if (log.isDebugEnabled()) {
-      log.debug(fName + ": put [" + getFormattedKeys(keys) + "] = " + value);
+      if (log.isDebugEnabled()) {
+        log.debug(fName + ": put [" + getFormattedKeys(keys) + "] = " + value);
+      }
+    }
+    finally {
+      fLock.writeLock().unlock();
     }
   }
 
@@ -215,25 +240,31 @@ public class CacheImpl implements Cache 
       return;
     }
 
-    CacheLevel cacheLevel = fRoot;
+    fLock.writeLock().lock();
+    try {
+      CacheLevel cacheLevel = fRoot;
 
-    // follow the branch
-    for (int i = 0; i < keys.length - 1; i++) {
-      Object level = cacheLevel.get(keys[i]);
-
-      // does the branch exist?
-      if (level == null) {
-        return;
-      }
+      // follow the branch
+      for (int i = 0; i < keys.length - 1; i++) {
+        Object level = cacheLevel.get(keys[i]);
+
+        // does the branch exist?
+        if (level == null) {
+          return;
+        }
 
-      // next level
-      cacheLevel = (CacheLevel) level;
-    }
+        // next level
+        cacheLevel = (CacheLevel) level;
+      }
 
-    cacheLevel.remove(keys[keys.length - 1]);
+      cacheLevel.remove(keys[keys.length - 1]);
 
-    if (log.isDebugEnabled()) {
-      log.debug(fName + ": removed [" + getFormattedKeys(keys) + "]");
+      if (log.isDebugEnabled()) {
+        log.debug(fName + ": removed [" + getFormattedKeys(keys) + "]");
+      }
+    }
+    finally {
+      fLock.writeLock().unlock();
     }
   }
 
@@ -247,19 +278,25 @@ public class CacheImpl implements Cache 
       return -1;
     }
 
-    CacheLevel cacheLevel = fRoot;
+    fLock.readLock().lock();
+    try {
+      CacheLevel cacheLevel = fRoot;
+
+      // follow the branch
+      for (int i = 0; i < keys.length - 1; i++) {
+        Object level = cacheLevel.get(keys[i]);
+
+        // does the branch exist?
+        if (level == null) {
+          return i;
+        }
 
-    // follow the branch
-    for (int i = 0; i < keys.length - 1; i++) {
-      Object level = cacheLevel.get(keys[i]);
-
-      // does the branch exist?
-      if (level == null) {
-        return i;
+        // next level
+        cacheLevel = (CacheLevel) level;
       }
-
-      // next level
-      cacheLevel = (CacheLevel) level;
+    }
+    finally {
+      fLock.readLock().unlock();
     }
 
     return keys.length;

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderHelper.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderHelper.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderHelper.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderHelper.java Thu Mar 11 10:21:18 2010
@@ -62,31 +62,43 @@ public final class CmisProviderHelper {
       return spi;
     }
 
-    // ok, we have to create it...
+    session.writeLock();
     try {
-      String spiFactoryName = (String) session.get(SessionParameter.BINDING_SPI_CLASS);
-      Class<?> spiFactoryClass = Class.forName(spiFactoryName);
-      Object spiFactory = spiFactoryClass.newInstance();
-
-      if (!(spiFactory instanceof CmisSpiFactory)) {
-        throw new CmisRuntimeException("Not a CMISSPIFactory class!");
+      // try again
+      spi = (CmisSpi) session.get(SPI_OBJECT);
+      if (spi != null) {
+        return spi;
       }
 
-      spi = ((CmisSpiFactory) spiFactory).getSpiInstance(session);
-      if (spi == null) {
-        throw new CmisRuntimeException("SPI factory returned null!");
+      // ok, we have to create it...
+      try {
+        String spiFactoryName = (String) session.get(SessionParameter.BINDING_SPI_CLASS);
+        Class<?> spiFactoryClass = Class.forName(spiFactoryName);
+        Object spiFactory = spiFactoryClass.newInstance();
+
+        if (!(spiFactory instanceof CmisSpiFactory)) {
+          throw new CmisRuntimeException("Not a CMISSPIFactory class!");
+        }
+
+        spi = ((CmisSpiFactory) spiFactory).getSpiInstance(session);
+        if (spi == null) {
+          throw new CmisRuntimeException("SPI factory returned null!");
+        }
       }
+      catch (CmisBaseException e) {
+        throw e;
+      }
+      catch (Exception e) {
+        throw new CmisRuntimeException("SPI cannot be initialized: " + e.getMessage(), e);
+      }
+
+      // we have a SPI object -> put it into the session
+      session.put(SPI_OBJECT, spi, true);
     }
-    catch (CmisBaseException e) {
-      throw e;
-    }
-    catch (Exception e) {
-      throw new CmisRuntimeException("SPI cannot be initialized: " + e.getMessage(), e);
+    finally {
+      session.writeUnlock();
     }
 
-    // we have a SPI object -> put it into the session
-    session.put(SPI_OBJECT, spi, true);
-
     return spi;
   }
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/CmisProviderImpl.java Thu Mar 11 10:21:18 2010
@@ -48,8 +48,8 @@ public class CmisProviderImpl implements
   private static final long serialVersionUID = 1L;
 
   private Session fSession;
-  private transient ProviderObjectFactory fObjectFactory;
-  private transient RepositoryService fRepositoryService;
+  private ProviderObjectFactory fObjectFactory;
+  private RepositoryService fRepositoryService;
 
   /**
    * Constructor.
@@ -99,6 +99,12 @@ public class CmisProviderImpl implements
 
     // initialize the SPI
     CmisProviderHelper.getSPI(fSession);
+
+    // set up object factory
+    fObjectFactory = new ProviderObjectFactoryImpl();
+
+    // set up repository service
+    fRepositoryService = new RepositoryServiceImpl(fSession);
   }
 
   /*
@@ -107,10 +113,6 @@ public class CmisProviderImpl implements
    * @see org.apache.opencmis.client.provider.CMISProvider#getRepositoryService()
    */
   public RepositoryService getRepositoryService() {
-    if (fRepositoryService == null) {
-      fRepositoryService = new RepositoryServiceImpl(fSession);
-    }
-
     return fRepositoryService;
   }
 
@@ -200,10 +202,6 @@ public class CmisProviderImpl implements
    * @see org.apache.opencmis.client.provider.CMISProvider#getObjectFactory()
    */
   public ProviderObjectFactory getObjectFactory() {
-    if (fObjectFactory == null) {
-      fObjectFactory = new ProviderObjectFactoryImpl();
-    }
-
     return fObjectFactory;
   }
 
@@ -213,11 +211,17 @@ public class CmisProviderImpl implements
    * @see org.apache.opencmis.client.provider.CMISProvider#clearAllCaches()
    */
   public void clearAllCaches() {
-    fSession.put(CmisProviderHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(fSession));
-    fSession.put(CmisProviderHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(fSession));
+    fSession.writeLock();
+    try {
+      fSession.put(CmisProviderHelper.REPOSITORY_INFO_CACHE, new RepositoryInfoCache(fSession));
+      fSession.put(CmisProviderHelper.TYPE_DEFINTION_CACHE, new TypeDefinitionCache(fSession));
 
-    CmisSpi spi = CmisProviderHelper.getSPI(fSession);
-    spi.clearAllCaches();
+      CmisSpi spi = CmisProviderHelper.getSPI(fSession);
+      spi.clearAllCaches();
+    }
+    finally {
+      fSession.writeUnlock();
+    }
   }
 
   /*
@@ -230,15 +234,21 @@ public class CmisProviderImpl implements
       return;
     }
 
-    RepositoryInfoCache repInfoCache = (RepositoryInfoCache) fSession
-        .get(CmisProviderHelper.REPOSITORY_INFO_CACHE);
-    repInfoCache.remove(repositoryId);
-
-    TypeDefinitionCache typeDefCache = (TypeDefinitionCache) fSession
-        .get(CmisProviderHelper.TYPE_DEFINTION_CACHE);
-    typeDefCache.remove(repositoryId);
+    fSession.writeLock();
+    try {
+      RepositoryInfoCache repInfoCache = (RepositoryInfoCache) fSession
+          .get(CmisProviderHelper.REPOSITORY_INFO_CACHE);
+      repInfoCache.remove(repositoryId);
+
+      TypeDefinitionCache typeDefCache = (TypeDefinitionCache) fSession
+          .get(CmisProviderHelper.TYPE_DEFINTION_CACHE);
+      typeDefCache.remove(repositoryId);
 
-    CmisSpi spi = CmisProviderHelper.getSPI(fSession);
-    spi.clearRepositoryCache(repositoryId);
+      CmisSpi spi = CmisProviderHelper.getSPI(fSession);
+      spi.clearRepositoryCache(repositoryId);
+    }
+    finally {
+      fSession.writeUnlock();
+    }
   }
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/RepositoryServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/RepositoryServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/RepositoryServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -19,14 +19,15 @@
 
 package org.apache.opencmis.client.provider.impl;
 
+import java.io.Serializable;
 import java.math.BigInteger;
 import java.util.List;
 
 import org.apache.opencmis.client.provider.spi.CmisSpi;
 import org.apache.opencmis.client.provider.spi.Session;
 import org.apache.opencmis.commons.api.ExtensionsData;
-import org.apache.opencmis.commons.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.api.TypeDefinition;
+import org.apache.opencmis.commons.api.TypeDefinitionContainer;
 import org.apache.opencmis.commons.api.TypeDefinitionList;
 import org.apache.opencmis.commons.provider.RepositoryInfoData;
 import org.apache.opencmis.commons.provider.RepositoryService;
@@ -39,9 +40,11 @@ import org.apache.opencmis.commons.provi
  * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
  * 
  */
-public class RepositoryServiceImpl implements RepositoryService {
+public class RepositoryServiceImpl implements RepositoryService, Serializable {
+
+  private static final long serialVersionUID = 1L;
 
-  private Session fSession;
+  private final Session fSession;
 
   /**
    * Constructor.
@@ -86,8 +89,8 @@ public class RepositoryServiceImpl imple
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.RepositoryService#getRepositoryInfos(org.apache.opencmis.client.provider
-   * .ExtensionsData)
+   * org.apache.opencmis.client.provider.RepositoryService#getRepositoryInfos(org.apache.opencmis
+   * .client.provider .ExtensionsData)
    */
   public List<RepositoryInfoData> getRepositoryInfos(ExtensionsData extension) {
     List<RepositoryInfoData> result = null;

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/SessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/SessionImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/SessionImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/impl/SessionImpl.java Thu Mar 11 10:21:18 2010
@@ -21,6 +21,7 @@ package org.apache.opencmis.client.provi
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.opencmis.client.provider.spi.Session;
 
@@ -36,6 +37,8 @@ public class SessionImpl implements Sess
 
   private Map<String, Object> fData;
 
+  private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
   /**
    * Constructor.
    */
@@ -49,7 +52,15 @@ public class SessionImpl implements Sess
    * @see org.apache.opencmis.client.provider.spi.Session#get(java.lang.String)
    */
   public Object get(String key) {
-    Object value = fData.get(key);
+    Object value = null;
+
+    fLock.readLock().lock();
+    try {
+      value = fData.get(key);
+    }
+    finally {
+      fLock.readLock().unlock();
+    }
 
     if (value instanceof TransientWrapper) {
       return ((TransientWrapper) value).getObject();
@@ -94,16 +105,24 @@ public class SessionImpl implements Sess
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.Session#put(java.lang.String, java.io.Serializable)
+   * @see org.apache.opencmis.client.provider.spi.Session#put(java.lang.String,
+   * java.io.Serializable)
    */
   public void put(String key, Serializable obj) {
-    fData.put(key, obj);
+    fLock.writeLock().lock();
+    try {
+      fData.put(key, obj);
+    }
+    finally {
+      fLock.writeLock().unlock();
+    }
   }
 
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.spi.Session#put(java.lang.String, java.lang.Object, boolean)
+   * @see org.apache.opencmis.client.provider.spi.Session#put(java.lang.String, java.lang.Object,
+   * boolean)
    */
   public void put(String key, Object obj, boolean isTransient) {
     Object value = (isTransient ? new TransientWrapper(obj) : obj);
@@ -111,7 +130,13 @@ public class SessionImpl implements Sess
       throw new IllegalArgumentException("Object must be serializable!");
     }
 
-    fData.put(key, value);
+    fLock.writeLock().lock();
+    try {
+      fData.put(key, value);
+    }
+    finally {
+      fLock.writeLock().unlock();
+    }
   }
 
   /*
@@ -120,7 +145,49 @@ public class SessionImpl implements Sess
    * @see org.apache.opencmis.client.provider.spi.Session#remove(java.lang.String)
    */
   public void remove(String key) {
-    fData.remove(key);
+    fLock.writeLock().lock();
+    try {
+      fData.remove(key);
+    }
+    finally {
+      fLock.writeLock().unlock();
+    }
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.spi.Session#readLock()
+   */
+  public void readLock() {
+    fLock.readLock().lock();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.spi.Session#readUnlock()
+   */
+  public void readUnlock() {
+    fLock.readLock().unlock();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.spi.Session#writeLock()
+   */
+  public void writeLock() {
+    fLock.writeLock().lock();
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.provider.spi.Session#writeUnlock()
+   */
+  public void writeUnlock() {
+    fLock.writeLock().unlock();
   }
 
   @Override

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/Session.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/Session.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/Session.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/Session.java Thu Mar 11 10:21:18 2010
@@ -57,4 +57,24 @@ public interface Session extends Seriali
    * Removes a session value.
    */
   void remove(String key);
+
+  /**
+   * Acquires a read lock.
+   */
+  void readLock();
+
+  /**
+   * Releases a read lock.
+   */
+  void readUnlock();
+
+  /**
+   * Acquires a write lock.
+   */
+  void writeLock();
+
+  /**
+   * Releases a write lock.
+   */
+  void writeUnlock();
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/CmisAtomPubSpi.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/CmisAtomPubSpi.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/CmisAtomPubSpi.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/CmisAtomPubSpi.java Thu Mar 11 10:21:18 2010
@@ -63,8 +63,8 @@ public class CmisAtomPubSpi implements C
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.CMISSPIFactory#getSPIInstance(org.apache.opencmis.client.provider
-   * .spi.Session)
+   * org.apache.opencmis.client.provider.spi.CMISSPIFactory#getSPIInstance(org.apache.opencmis.client
+   * .provider .spi.Session)
    */
   public CmisSpi getSpiInstance(Session session) {
     if (log.isDebugEnabled()) {
@@ -73,8 +73,17 @@ public class CmisAtomPubSpi implements C
 
     fSession = session;
 
-    return this;
+    fRepositoryService = new RepositoryServiceImpl(fSession);
+    fNavigationService = new NavigationServiceImpl(fSession);
+    fObjectService = new ObjectServiceImpl(fSession);
+    fVersioningService = new VersioningServiceImpl(fSession);
+    fDiscoveryService = new DiscoveryServiceImpl(fSession);
+    fMultiFilingService = new MultiFilingServiceImpl(fSession);
+    fRelationshipService = new RelationshipServiceImpl(fSession);
+    fPolicyService = new PolicyServiceImpl(fSession);
+    fACLService = new AclServiceImpl(fSession);
 
+    return this;
   }
 
   /*
@@ -83,10 +92,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getRepositoryService()
    */
   public RepositoryService getRepositoryService() {
-    if (fRepositoryService == null) {
-      fRepositoryService = new RepositoryServiceImpl(fSession);
-    }
-
     return fRepositoryService;
   }
 
@@ -96,10 +101,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getNavigationService()
    */
   public NavigationService getNavigationService() {
-    if (fNavigationService == null) {
-      fNavigationService = new NavigationServiceImpl(fSession);
-    }
-
     return fNavigationService;
   }
 
@@ -109,10 +110,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getObjectService()
    */
   public ObjectService getObjectService() {
-    if (fObjectService == null) {
-      fObjectService = new ObjectServiceImpl(fSession);
-    }
-
     return fObjectService;
   }
 
@@ -122,10 +119,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getDiscoveryService()
    */
   public DiscoveryService getDiscoveryService() {
-    if (fDiscoveryService == null) {
-      fDiscoveryService = new DiscoveryServiceImpl(fSession);
-    }
-
     return fDiscoveryService;
   }
 
@@ -135,10 +128,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getVersioningService()
    */
   public VersioningService getVersioningService() {
-    if (fVersioningService == null) {
-      fVersioningService = new VersioningServiceImpl(fSession);
-    }
-
     return fVersioningService;
   }
 
@@ -148,10 +137,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getMultiFilingService()
    */
   public MultiFilingService getMultiFilingService() {
-    if (fMultiFilingService == null) {
-      fMultiFilingService = new MultiFilingServiceImpl(fSession);
-    }
-
     return fMultiFilingService;
   }
 
@@ -161,10 +146,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getRelationshipService()
    */
   public RelationshipService getRelationshipService() {
-    if (fRelationshipService == null) {
-      fRelationshipService = new RelationshipServiceImpl(fSession);
-    }
-
     return fRelationshipService;
   }
 
@@ -174,10 +155,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getPolicyService()
    */
   public PolicyService getPolicyService() {
-    if (fPolicyService == null) {
-      fPolicyService = new PolicyServiceImpl(fSession);
-    }
-
     return fPolicyService;
   }
 
@@ -187,10 +164,6 @@ public class CmisAtomPubSpi implements C
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getACLService()
    */
   public AclService getAclService() {
-    if (fACLService == null) {
-      fACLService = new AclServiceImpl(fSession);
-    }
-
     return fACLService;
   }
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/PolicyServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/PolicyServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/PolicyServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -32,7 +32,6 @@ import org.apache.opencmis.client.provid
 import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.api.ExtensionsData;
 import org.apache.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.opencmis.commons.impl.Constants;
 import org.apache.opencmis.commons.impl.UrlBuilder;
 import org.apache.opencmis.commons.impl.jaxb.CmisObjectType;

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/AclServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/AclServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/AclServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/AclServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -38,7 +38,7 @@ import org.apache.opencmis.commons.provi
  */
 public class AclServiceImpl extends AbstractWebServicesService implements AclService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/CmisWebServicesSpi.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/CmisWebServicesSpi.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/CmisWebServicesSpi.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/CmisWebServicesSpi.java Thu Mar 11 10:21:18 2010
@@ -66,8 +66,8 @@ public class CmisWebServicesSpi implemen
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.spi.CMISSPIFactory#getSPIInstance(org.apache.opencmis.client.provider
-   * .spi.Session)
+   * org.apache.opencmis.client.provider.spi.CMISSPIFactory#getSPIInstance(org.apache.opencmis.client
+   * .provider .spi.Session)
    */
   public CmisSpi getSpiInstance(Session session) {
     if (log.isDebugEnabled()) {
@@ -77,6 +77,16 @@ public class CmisWebServicesSpi implemen
     fSession = session;
     fPortProvider = new PortProvider(fSession);
 
+    fRepositoryService = new RepositoryServiceImpl(fSession, fPortProvider);
+    fNavigationService = new NavigationServiceImpl(fSession, fPortProvider);
+    fObjectService = new ObjectServiceImpl(fSession, fPortProvider);
+    fVersioningService = new VersioningServiceImpl(fSession, fPortProvider);
+    fDiscoveryService = new DiscoveryServiceImpl(fSession, fPortProvider);
+    fMultiFilingService = new MultiFilingServiceImpl(fSession, fPortProvider);
+    fRelationshipService = new RelationshipServiceImpl(fSession, fPortProvider);
+    fPolicyService = new PolicyServiceImpl(fSession, fPortProvider);
+    fACLService = new AclServiceImpl(fSession, fPortProvider);
+
     return this;
   }
 
@@ -86,10 +96,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getRepositoryService()
    */
   public RepositoryService getRepositoryService() {
-    if (fRepositoryService == null) {
-      fRepositoryService = new RepositoryServiceImpl(fSession, fPortProvider);
-    }
-
     return fRepositoryService;
   }
 
@@ -99,10 +105,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getNavigationService()
    */
   public NavigationService getNavigationService() {
-    if (fNavigationService == null) {
-      fNavigationService = new NavigationServiceImpl(fSession, fPortProvider);
-    }
-
     return fNavigationService;
   }
 
@@ -112,10 +114,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getObjectService()
    */
   public ObjectService getObjectService() {
-    if (fObjectService == null) {
-      fObjectService = new ObjectServiceImpl(fSession, fPortProvider);
-    }
-
     return fObjectService;
   }
 
@@ -125,10 +123,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getDiscoveryService()
    */
   public DiscoveryService getDiscoveryService() {
-    if (fDiscoveryService == null) {
-      fDiscoveryService = new DiscoveryServiceImpl(fSession, fPortProvider);
-    }
-
     return fDiscoveryService;
   }
 
@@ -138,10 +132,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getVersioningService()
    */
   public VersioningService getVersioningService() {
-    if (fVersioningService == null) {
-      fVersioningService = new VersioningServiceImpl(fSession, fPortProvider);
-    }
-
     return fVersioningService;
   }
 
@@ -151,10 +141,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getMultiFilingService()
    */
   public MultiFilingService getMultiFilingService() {
-    if (fMultiFilingService == null) {
-      fMultiFilingService = new MultiFilingServiceImpl(fSession, fPortProvider);
-    }
-
     return fMultiFilingService;
   }
 
@@ -164,10 +150,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getRelationshipService()
    */
   public RelationshipService getRelationshipService() {
-    if (fRelationshipService == null) {
-      fRelationshipService = new RelationshipServiceImpl(fSession, fPortProvider);
-    }
-
     return fRelationshipService;
   }
 
@@ -177,10 +159,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getPolicyService()
    */
   public PolicyService getPolicyService() {
-    if (fPolicyService == null) {
-      fPolicyService = new PolicyServiceImpl(fSession, fPortProvider);
-    }
-
     return fPolicyService;
   }
 
@@ -190,10 +168,6 @@ public class CmisWebServicesSpi implemen
    * @see org.apache.opencmis.client.provider.spi.CMISSPI#getACLService()
    */
   public AclService getAclService() {
-    if (fACLService == null) {
-      fACLService = new AclServiceImpl(fSession, fPortProvider);
-    }
-
     return fACLService;
   }
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/DiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/DiscoveryServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/DiscoveryServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/DiscoveryServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -44,7 +44,7 @@ import org.apache.opencmis.commons.provi
  */
 public class DiscoveryServiceImpl extends AbstractWebServicesService implements DiscoveryService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.
@@ -58,8 +58,9 @@ public class DiscoveryServiceImpl extend
    * (non-Javadoc)
    * 
    * @see org.apache.opencmis.client.provider.DiscoveryService#getContentChanges(java.lang.String,
-   * org.apache.opencmis.client.provider.Holder, java.lang.Boolean, java.lang.String, java.lang.Boolean,
-   * java.lang.Boolean, java.math.BigInteger, org.apache.opencmis.client.provider.ExtensionsData)
+   * org.apache.opencmis.client.provider.Holder, java.lang.Boolean, java.lang.String,
+   * java.lang.Boolean, java.lang.Boolean, java.math.BigInteger,
+   * org.apache.opencmis.client.provider.ExtensionsData)
    */
   public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken,
       Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeACL,
@@ -88,10 +89,10 @@ public class DiscoveryServiceImpl extend
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.DiscoveryService#query(java.lang.String, java.lang.String,
-   * java.lang.Boolean, java.lang.Boolean, org.apache.opencmis.commons.enums.IncludeRelationships,
-   * java.lang.String, java.math.BigInteger, java.math.BigInteger,
-   * org.apache.opencmis.client.provider.ExtensionsData)
+   * @see org.apache.opencmis.client.provider.DiscoveryService#query(java.lang.String,
+   * java.lang.String, java.lang.Boolean, java.lang.Boolean,
+   * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.math.BigInteger,
+   * java.math.BigInteger, org.apache.opencmis.client.provider.ExtensionsData)
    */
   public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
       Boolean includeAllowableActions, IncludeRelationships includeRelationships,

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/MultiFilingServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/MultiFilingServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/MultiFilingServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/MultiFilingServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -38,7 +38,7 @@ import org.apache.opencmis.commons.provi
 public class MultiFilingServiceImpl extends AbstractWebServicesService implements
     MultiFilingService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/NavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/NavigationServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/NavigationServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/NavigationServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -48,7 +48,7 @@ import org.apache.opencmis.commons.provi
  */
 public class NavigationServiceImpl extends AbstractWebServicesService implements NavigationService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/ObjectServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/ObjectServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/ObjectServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -59,7 +59,7 @@ import org.apache.opencmis.commons.provi
  */
 public class ObjectServiceImpl extends AbstractWebServicesService implements ObjectService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PolicyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PolicyServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PolicyServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PolicyServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -43,7 +43,7 @@ import org.apache.opencmis.commons.provi
  */
 public class PolicyServiceImpl extends AbstractWebServicesService implements PolicyService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PortProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PortProvider.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PortProvider.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/PortProvider.java Thu Mar 11 10:21:18 2010
@@ -19,6 +19,7 @@
 package org.apache.opencmis.client.provider.spi.webservices;
 
 import java.net.URL;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -86,7 +87,7 @@ public class PortProvider {
 
   private static final int CHUNK_SIZE = 64 * 1024;
 
-  private Session fSession;
+  private final Session fSession;
 
   /**
    * Constructor.
@@ -169,15 +170,48 @@ public class PortProvider {
 
     // does the port map exist?
     if (portMap == null) {
-      // create and store map
-      portMap = new HashMap<String, Object>();
-      fSession.put(SpiSessionParameter.PORTS, portMap, true);
+      fSession.writeLock();
+      try {
+        // try again
+        portMap = (Map<String, Object>) fSession.get(SpiSessionParameter.PORTS);
+        if (portMap == null) {
+          portMap = Collections.synchronizedMap(new HashMap<String, Object>());
+          fSession.put(SpiSessionParameter.PORTS, portMap, true);
+        }
+
+        if (portMap.containsKey(portKey)) {
+          return portMap.get(portKey);
+        }
+
+        // create object
+        Object portObject = initPortObject(portKey);
+        portMap.put(portKey, portObject);
+
+        return portObject;
+      }
+      finally {
+        fSession.writeUnlock();
+      }
     }
 
     // is the port in the port map?
     if (!portMap.containsKey(portKey)) {
-      // create and add port object
-      portMap.put(portKey, initPortObject(portKey));
+      fSession.writeLock();
+      try {
+        // try again
+        if (portMap.containsKey(portKey)) {
+          return portMap.get(portKey);
+        }
+
+        // create object
+        Object portObject = initPortObject(portKey);
+        portMap.put(portKey, portObject);
+
+        return portObject;
+      }
+      finally {
+        fSession.writeUnlock();
+      }
     }
 
     return portMap.get(portKey);

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RelationshipServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RelationshipServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RelationshipServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RelationshipServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -41,7 +41,7 @@ import org.apache.opencmis.commons.provi
 public class RelationshipServiceImpl extends AbstractWebServicesService implements
     RelationshipService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RepositoryServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RepositoryServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/RepositoryServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -46,7 +46,7 @@ import org.apache.opencmis.commons.provi
  */
 public class RepositoryServiceImpl extends AbstractWebServicesService implements RepositoryService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/VersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/VersioningServiceImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/VersioningServiceImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/webservices/VersioningServiceImpl.java Thu Mar 11 10:21:18 2010
@@ -51,7 +51,7 @@ import org.apache.opencmis.commons.provi
  */
 public class VersioningServiceImpl extends AbstractWebServicesService implements VersioningService {
 
-  private PortProvider fPortProvider;
+  private final PortProvider fPortProvider;
 
   /**
    * Constructor.

Modified: incubator/chemistry/trunk/opencmis/opencmis-commons/opencmis-commons-impl/src/main/java/org/apache/opencmis/commons/impl/dataobjects/ProviderObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-commons/opencmis-commons-impl/src/main/java/org/apache/opencmis/commons/impl/dataobjects/ProviderObjectFactoryImpl.java?rev=921774&r1=921773&r2=921774&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-commons/opencmis-commons-impl/src/main/java/org/apache/opencmis/commons/impl/dataobjects/ProviderObjectFactoryImpl.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-commons/opencmis-commons-impl/src/main/java/org/apache/opencmis/commons/impl/dataobjects/ProviderObjectFactoryImpl.java Thu Mar 11 10:21:18 2010
@@ -19,6 +19,7 @@
 package org.apache.opencmis.commons.impl.dataobjects;
 
 import java.io.InputStream;
+import java.io.Serializable;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.GregorianCalendar;
@@ -58,7 +59,9 @@ import org.apache.opencmis.commons.provi
  * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
  * 
  */
-public class ProviderObjectFactoryImpl implements ProviderObjectFactory {
+public class ProviderObjectFactoryImpl implements ProviderObjectFactory, Serializable {
+
+  private static final long serialVersionUID = 1L;
 
   public ProviderObjectFactoryImpl() {
   }
@@ -67,8 +70,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createAccessControlEntry(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createAccessControlEntry(java.lang
+   * .String, java.util.List)
    */
   public AccessControlEntry createAccessControlEntry(String principal, List<String> permissions) {
     return new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principal), permissions);
@@ -77,7 +80,9 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createAccessControlList(java.util.List)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createAccessControlList(java.util
+   * .List)
    */
   public AccessControlList createAccessControlList(List<AccessControlEntry> aces) {
     return new AccessControlListImpl(aces);
@@ -87,8 +92,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createContentStream(java.math.BigInteger,
-   * java.lang.String, java.lang.String, java.io.InputStream)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createContentStream(java.math.BigInteger
+   * , java.lang.String, java.lang.String, java.io.InputStream)
    */
   public ContentStreamData createContentStream(BigInteger length, String mimetype, String filename,
       InputStream stream) {
@@ -98,7 +103,8 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertiesData(java.util.List)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertiesData(java.util.List)
    */
   public PropertiesData createPropertiesData(List<PropertyData<?>> properties) {
     return new PropertiesDataImpl(properties);
@@ -108,8 +114,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyBooleanData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyBooleanData(java.lang
+   * .String, java.util.List)
    */
   public PropertyBooleanData createPropertyBooleanData(String id, List<Boolean> values) {
     return new PropertyBooleanDataImpl(id, values);
@@ -119,8 +125,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyBooleanData(java.lang.String,
-   * java.lang.Boolean)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyBooleanData(java.lang
+   * .String, java.lang.Boolean)
    */
   public PropertyBooleanData createPropertyBooleanData(String id, Boolean value) {
     return new PropertyBooleanDataImpl(id, value);
@@ -130,8 +136,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDateTimeData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDateTimeData(java.lang
+   * .String, java.util.List)
    */
   public PropertyDateTimeData createPropertyDateTimeData(String id, List<GregorianCalendar> values) {
     return new PropertyDateTimeDataImpl(id, values);
@@ -141,8 +147,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDateTimeData(java.lang.String,
-   * java.util.GregorianCalendar)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDateTimeData(java.lang
+   * .String, java.util.GregorianCalendar)
    */
   public PropertyDateTimeData createPropertyDateTimeData(String id, GregorianCalendar value) {
     return new PropertyDateTimeDataImpl(id, value);
@@ -152,8 +158,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDecimalData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDecimalData(java.lang
+   * .String, java.util.List)
    */
   public PropertyDecimalData createPropertyDecimalData(String id, List<BigDecimal> values) {
     return new PropertyDecimalDataImpl(id, values);
@@ -163,8 +169,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDecimalData(java.lang.String,
-   * java.math.BigDecimal)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyDecimalData(java.lang
+   * .String, java.math.BigDecimal)
    */
   public PropertyDecimalData createPropertyDecimalData(String id, BigDecimal value) {
     return new PropertyDecimalDataImpl(id, value);
@@ -174,8 +180,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyHtmlData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyHtmlData(java.lang.
+   * String, java.util.List)
    */
   public PropertyHtmlData createPropertyHtmlData(String id, List<String> values) {
     return new PropertyHtmlDataImpl(id, values);
@@ -185,8 +191,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyHtmlData(java.lang.String,
-   * java.lang.String)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyHtmlData(java.lang.
+   * String, java.lang.String)
    */
   public PropertyHtmlData createPropertyHtmlData(String id, String value) {
     return new PropertyHtmlDataImpl(id, value);
@@ -195,8 +201,9 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIdData(java.lang.String,
-   * java.util.List)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIdData(java.lang.String
+   * , java.util.List)
    */
   public PropertyIdData createPropertyIdData(String id, List<String> values) {
     return new PropertyIdDataImpl(id, values);
@@ -205,8 +212,9 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIdData(java.lang.String,
-   * java.lang.String)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIdData(java.lang.String
+   * , java.lang.String)
    */
   public PropertyIdData createPropertyIdData(String id, String value) {
     return new PropertyIdDataImpl(id, value);
@@ -216,8 +224,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIntegerData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIntegerData(java.lang
+   * .String, java.util.List)
    */
   public PropertyIntegerData createPropertyIntegerData(String id, List<BigInteger> values) {
     return new PropertyIntegerDataImpl(id, values);
@@ -227,8 +235,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIntegerData(java.lang.String,
-   * java.math.BigInteger)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyIntegerData(java.lang
+   * .String, java.math.BigInteger)
    */
   public PropertyIntegerData createPropertyIntegerData(String id, BigInteger value) {
     return new PropertyIntegerDataImpl(id, value);
@@ -238,8 +246,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyStringData(java.lang.String,
-   * java.util.List)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyStringData(java.lang
+   * .String, java.util.List)
    */
   public PropertyStringData createPropertyStringData(String id, List<String> values) {
     return new PropertyStringDataImpl(id, values);
@@ -249,8 +257,8 @@ public class ProviderObjectFactoryImpl i
    * (non-Javadoc)
    * 
    * @see
-   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyStringData(java.lang.String,
-   * java.lang.String)
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyStringData(java.lang
+   * .String, java.lang.String)
    */
   public PropertyStringData createPropertyStringData(String id, String value) {
     return new PropertyStringDataImpl(id, value);
@@ -259,8 +267,9 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyUriData(java.lang.String,
-   * java.util.List)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyUriData(java.lang.String
+   * , java.util.List)
    */
   public PropertyUriData createPropertyUriData(String id, List<String> values) {
     return new PropertyUriDataImpl(id, values);
@@ -269,8 +278,9 @@ public class ProviderObjectFactoryImpl i
   /*
    * (non-Javadoc)
    * 
-   * @see org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyUriData(java.lang.String,
-   * java.lang.String)
+   * @see
+   * org.apache.opencmis.client.provider.ProviderObjectFactory#createPropertyUriData(java.lang.String
+   * , java.lang.String)
    */
   public PropertyUriData createPropertyUriData(String id, String value) {
     return new PropertyUriDataImpl(id, value);



Mime
View raw message