[exo-jcr-commits] exo-jcr SVN: r1527 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jan 21 08:59:14 EST 2010


Author: areshetnyak
Date: 2010-01-21 08:59:14 -0500 (Thu, 21 Jan 2010)
New Revision: 1527

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332 : Add constructor with TransactionManager

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java	2010-01-21 13:35:02 UTC (rev 1526)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java	2010-01-21 13:59:14 UTC (rev 1527)
@@ -171,11 +171,30 @@
     * @param dataManager - workspace persistent data manager
     * @param config - workspace entry
     * @param context InitialContextInitializer, needed to reload context after JBoss cache creation
+    * @param transactionService 
+    *          the transaction service
     * @throws RepositoryConfigurationException
     */
    public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
-      InitialContextInitializer context, TransactionService transactionService) throws RepositoryConfigurationException
+            InitialContextInitializer context, TransactionService transactionService)
+            throws RepositoryConfigurationException
    {
+      this(dataManager, config, context, transactionService.getTransactionManager());
+   }
+   
+   /**
+    * Constructor.
+    * 
+    * @param dataManager - workspace persistent data manager
+    * @param config - workspace entry
+    * @param context InitialContextInitializer, needed to reload context after JBoss cache creation
+    * @param transactionManager 
+    *          the transaction manager
+    * @throws RepositoryConfigurationException
+    */
+   public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+      InitialContextInitializer context, TransactionManager transactionManager) throws RepositoryConfigurationException
+   {
       lockRoot = Fqn.fromElements(LOCKS);
       
       List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
@@ -216,19 +235,12 @@
          CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
 
          cache = factory.createCache(pathToConfig, false);
+         cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
          
-         if (transactionService.getTransactionManager() != null)
-         {
-            cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionService.getTransactionManager());
-         }
-         
          cache.create();
          cache.start();
          
-         if (!cache.getRoot().hasChild(lockRoot)) 
-         {
-            cache.getRoot().addChild(lockRoot);
-         }
+         createStructuredNode(lockRoot);
 
          // Context recall is a workaround of JDBCCacheLoader starting. 
          context.recall();
@@ -772,4 +784,17 @@
    {
       return Fqn.fromRelativeElements(lockRoot, nodeId);
    }
+   
+   /**
+    *  Will be created structured node in cache, like /$LOCKS
+    */
+   private void createStructuredNode(Fqn fqn) {
+      Node<Serializable, Object> node = cache.getRoot().getChild(fqn); 
+      if (node == null) 
+      { 
+      cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true); 
+      node = cache.getRoot().addChild(fqn); 
+      } 
+      node.setResident(true);
+   }
 }



More information about the exo-jcr-commits mailing list