[exo-jcr-commits] exo-jcr SVN: r1369 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jan 13 03:23:40 EST 2010
Author: tolusha
Date: 2010-01-13 03:23:39 -0500 (Wed, 13 Jan 2010)
New Revision: 1369
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionManagerLookup.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/TCK.sh
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-334: JBossTransactionService refactoring
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/TCK.sh
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/TCK.sh 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/TCK.sh 2010-01-13 08:23:39 UTC (rev 1369)
@@ -1,2 +1,2 @@
-MAVEN_OPTS="-Duser.language=en -Duser.region=us -Dmaven.test.skip=true -DforkMode=never -Dorg.exoplatform.jcr.monitor.jdbcMonitor $MAVEN_OPTS "
-mvn $MAVEN_OPTS clean install -Prun-its
\ No newline at end of file
+MAVEN_OPTS="-Duser.language=en -Duser.region=us -Dmaven.test.skip=false -DforkMode=never -Dorg.exoplatform.jcr.monitor.jdbcMonitor $MAVEN_OPTS "
+mvn clean test -Prun-tck
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 08:23:39 UTC (rev 1369)
@@ -24,9 +24,10 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
+
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.transaction.jbosscache.JBossTransactionService;
import java.util.HashMap;
import java.util.List;
@@ -76,21 +77,15 @@
* System Workspace data container (persistent level)
*/
public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer, WorkspaceStorageCache cache,
- SystemDataContainerHolder systemDataContainerHolder)
+ SystemDataContainerHolder systemDataContainerHolder, JBossTransactionService transactionService)
{
super(dataContainer, systemDataContainerHolder);
this.cache = cache;
this.requestCache = new HashMap<Integer, DataRequest>();
addItemPersistenceListener(cache);
- if (cache instanceof JBossCacheWorkspaceStorageCache)
- {
- transactionManager = ((JBossCacheWorkspaceStorageCache)cache).getTransactionManager();
- }
- else
- {
- transactionManager = null;
- }
+
+ transactionManager = transactionService.getTransactionManager();
}
/**
@@ -190,56 +185,48 @@
@Override
public void save(ItemStateChangesLog changesLog) throws RepositoryException
{
- if (transactionManager == null)
+ try
{
+ transactionManager.begin();
+ transactionManager.setTransactionTimeout(90000);
+ cache.beginTransaction();
super.save(changesLog);
+ cache.commitTransaction();
+ transactionManager.commit();
}
- else
+ catch (RollbackException e)
{
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (RepositoryException e)
+ {
try
{
- transactionManager.begin();
- //should be configured from xml in feature
- transactionManager.setTransactionTimeout(90000);
- cache.beginTransaction();
- super.save(changesLog);
- cache.commitTransaction();
- transactionManager.commit();
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (RepositoryException e)
+ throw e;
+ }
+ catch (Exception e)
+ {
+ try
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- throw e;
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (Exception e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e1.getLocalizedMessage(), e1.getCause());
- }
- e.printStackTrace();
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ // Treat the exception
+ throw new RepositoryException(e1.getLocalizedMessage(), e1.getCause());
}
+ e.printStackTrace();
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
// notify listeners after transaction commit
super.notifySaveItems(changesLog, false);
@@ -339,46 +326,38 @@
if (parentData != null)
{
- if (transactionManager == null)
+ try
{
- cache.addChildNodes(parentData, childNodes);
+ if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.addChildNodes(parentData, childNodes);
+ }
+ else
+ {
+ transactionManager.begin();
+ cache.beginTransaction();
+ cache.addChildNodes(parentData, childNodes);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
}
- else
+ catch (RollbackException e)
{
-
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
try
{
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildNodes(parentData, childNodes);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildNodes(parentData, childNodes);
- cache.commitTransaction();
- transactionManager.commit();
- }
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- }
}
}
}
@@ -432,45 +411,38 @@
if (parentData != null)
{
- if (transactionManager == null)
+ try
{
- cache.addChildProperties(parentData, childProperties);
+ if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.addChildProperties(parentData, childProperties);
+ }
+ else
+ {
+ transactionManager.begin();
+ cache.beginTransaction();
+ cache.addChildProperties(parentData, childProperties);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
}
- else
+ catch (RollbackException e)
{
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
try
{
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildProperties(parentData, childProperties);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildProperties(parentData, childProperties);
- cache.commitTransaction();
- transactionManager.commit();
- }
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- }
}
}
}
@@ -500,45 +472,38 @@
data = super.getItemData(parentData, name);
if (data != null && cache.isEnabled())
{
- if (transactionManager == null)
+ try
{
- cache.put(data);
+ if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.put(data);
+ }
+ else
+ {
+ transactionManager.begin();
+ cache.beginTransaction();
+ cache.put(data);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
}
- else
+ catch (RollbackException e)
{
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
try
{
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(data);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.put(data);
- cache.commitTransaction();
- transactionManager.commit();
- }
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- }
}
}
return data;
@@ -557,47 +522,39 @@
ItemData data = super.getItemData(identifier);
if (data != null && cache.isEnabled())
{
- if (transactionManager == null)
+ try
{
- cache.put(data);
+ if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.put(data);
+ }
+ else
+ {
+ transactionManager.begin();
+ cache.beginTransaction();
+ cache.put(data);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
}
- else
+ catch (RollbackException e)
{
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
try
{
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.put(data);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.put(data);
- cache.commitTransaction();
- transactionManager.commit();
- }
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- }
}
-
}
return data;
}
@@ -640,45 +597,38 @@
if (parentData != null)
{
- if (transactionManager == null)
+ try
{
- cache.addChildPropertiesList(parentData, propertiesList);
+ if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
+ {
+ cache.addChildPropertiesList(parentData, propertiesList);
+ }
+ else
+ {
+ transactionManager.begin();
+ cache.beginTransaction();
+ cache.addChildPropertiesList(parentData, propertiesList);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
}
- else
+ catch (RollbackException e)
{
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (Exception e)
+ {
try
{
- if (transactionManager.getStatus() == Status.STATUS_ACTIVE)
- {
- cache.addChildPropertiesList(parentData, propertiesList);
- }
- else
- {
- transactionManager.begin();
- cache.beginTransaction();
- cache.addChildPropertiesList(parentData, propertiesList);
- cache.commitTransaction();
- transactionManager.commit();
- }
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RollbackException e)
+ catch (Exception e1)
{
- // Indicate that the transaction has been rolled back rather than committed.
+ // Treat the exception
throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
}
- catch (Exception e)
- {
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- // Treat the exception
- throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
- }
- }
}
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-13 08:23:39 UTC (rev 1369)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.jbosscache.JBossTransactionService;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
@@ -52,6 +53,7 @@
import javax.jcr.RepositoryException;
import javax.transaction.RollbackException;
+import javax.transaction.Status;
import javax.transaction.TransactionManager;
/**
@@ -133,6 +135,11 @@
protected final Fqn<String> refsRoot;
/**
+ * TransactionManager.
+ */
+ private TransactionManager transactionManager;
+
+ /**
* Node order comparator for getChildNodes().
*/
class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
@@ -254,17 +261,18 @@
}
}
- public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig) throws RepositoryException,
- RepositoryConfigurationException
+ public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, JBossTransactionService transactionService)
+ throws RepositoryException, RepositoryConfigurationException
{
- this(readJBCConfig(wsConfig));
+ this(readJBCConfig(wsConfig), transactionService);
}
/**
* JBossCacheWorkspaceStorageCache constructor.
*
*/
- public JBossCacheWorkspaceStorageCache(String jbcConfig) throws RepositoryException
+ public JBossCacheWorkspaceStorageCache(String jbcConfig, JBossTransactionService transactionService)
+ throws RepositoryException
{
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
LOG.info("JBoss Cache configuration used: " + jbcConfig);
@@ -278,12 +286,10 @@
// prepare cache structures
- // TODO transaction
- TransactionManager tm = getTransactionManager();
-
+ transactionManager = transactionService.getTransactionManager();
try
{
- tm.begin();
+ transactionManager.begin();
this.itemsRoot = Fqn.fromElements(ITEMS);
cacheRoot.addChild(this.itemsRoot).setResident(true);
@@ -305,7 +311,7 @@
// TODO apply locks
//this.locks = cacheRoot.addChild(Fqn.fromElements(JBossCacheStorage.LOCKS));
- tm.commit();
+ transactionManager.commit();
}
catch (RollbackException e)
{
@@ -316,7 +322,7 @@
{
try
{
- tm.rollback();
+ transactionManager.rollback();
throw new RepositoryException("Cannot preare cache", e);
}
catch (Exception e1)
@@ -340,15 +346,6 @@
}
/**
- * Return TransactionManager.
- * @return TransactionManager.
- */
- public TransactionManager getTransactionManager()
- {
- return cache.getTransactionManager();
- }
-
- /**
* {@inheritDoc}
*/
public void put(ItemData item)
@@ -419,8 +416,8 @@
}
/**
- * {@inheritDoc}
- */
+ * {@inheritDoc}
+ */
public void addChildNodes(NodeData parent, List<NodeData> childs)
{
// remove previous all (to be sure about consistency)
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionManagerLookup.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionManagerLookup.java 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionManagerLookup.java 2010-01-13 08:23:39 UTC (rev 1369)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.transaction.jbosscache;
-
-import org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup;
-import org.jboss.cache.transaction.TransactionManagerLookup;
-
-import javax.transaction.TransactionManager;
-
-/**
- * @author <a href="mailto:dmitry.kataev at exoplatform.com">Dmytro Katayev</a>
- * @version $Id$
- */
-public class JBossTransactionManagerLookup implements TransactionManagerLookup
-{
-
- protected JBossStandaloneJTAManagerLookup jtaManagerLookup;
-
- /**
- *
- */
- public JBossTransactionManagerLookup(JBossStandaloneJTAManagerLookup jtaManagerLookup)
- {
- this.jtaManagerLookup = jtaManagerLookup;
- }
-
- /**
- * {@inheritDoc}
- */
- public TransactionManager getTransactionManager() throws Exception
- {
- return jtaManagerLookup.getTransactionManager();
- }
-
-}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2010-01-13 08:23:39 UTC (rev 1369)
@@ -18,8 +18,10 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
+import org.exoplatform.services.transaction.jbosscache.JBossTransactionService;
/**
* Created by The eXo Platform SAS.
@@ -33,6 +35,8 @@
@Override
public WorkspaceStorageCache getCacheImpl() throws Exception
{
- return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml");
+ JBossTransactionService transactionService =
+ (JBossTransactionService)container.getComponentInstanceOfType(JBossTransactionService.class);
+ return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml", transactionService);
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-01-12 20:29:54 UTC (rev 1368)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-01-13 08:23:39 UTC (rev 1369)
@@ -194,6 +194,15 @@
<component>
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
</component>
+
+ <component>
+ <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
+ <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
+ </component>
<component>
<key>org.exoplatform.services.transaction.TransactionService</key>
More information about the exo-jcr-commits
mailing list