Author: tolusha
Date: 2011-05-24 02:32:39 -0400 (Tue, 24 May 2011)
New Revision: 4416
Added:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/atomikos/
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/atomikos/TransactionsEssentialsTransactionService.java
Modified:
kernel/trunk/exo.kernel.component.common/pom.xml
kernel/trunk/pom.xml
Log:
EXOJCR-1329: Allow to use TransactionsEssentials as TransactionManager
Modified: kernel/trunk/exo.kernel.component.common/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.common/pom.xml 2011-05-24 04:33:12 UTC (rev 4415)
+++ kernel/trunk/exo.kernel.component.common/pom.xml 2011-05-24 06:32:39 UTC (rev 4416)
@@ -101,6 +101,11 @@
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.atomikos</groupId>
+ <artifactId>transactions-jta</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Added:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/atomikos/TransactionsEssentialsTransactionService.java
===================================================================
---
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/atomikos/TransactionsEssentialsTransactionService.java
(rev 0)
+++
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/atomikos/TransactionsEssentialsTransactionService.java 2011-05-24
06:32:39 UTC (rev 4416)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 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.impl.atomikos;
+
+import com.atomikos.icatch.jta.UserTransactionManager;
+
+import org.exoplatform.services.transaction.TransactionService;
+import org.exoplatform.services.transaction.impl.AbstractTransactionService;
+import org.picocontainer.Startable;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+/**
+ * An implementation of a {@link TransactionService} for TransactionsEssentials from
Atomikos
+ * to be used in standalone mode
+ *
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas
Filotto</a>
+ * @version $Id$
+ *
+ */
+public class TransactionsEssentialsTransactionService extends AbstractTransactionService
implements Startable
+{
+
+ /**
+ * @see
org.exoplatform.services.transaction.impl.AbstractTransactionService#findTransactionManager()
+ */
+ @Override
+ protected TransactionManager findTransactionManager() throws Exception
+ {
+ UserTransactionManager tm = new UserTransactionManager();
+ tm.init();
+ return tm;
+ }
+
+ /**
+ * @see
org.exoplatform.services.transaction.impl.AbstractTransactionService#findUserTransaction()
+ */
+ @Override
+ protected UserTransaction findUserTransaction() throws Exception
+ {
+ return (UserTransaction)getTransactionManager();
+ }
+
+ /**
+ * @see org.picocontainer.Startable#start()
+ */
+ public void start()
+ {
+ }
+
+ /**
+ * @see org.picocontainer.Startable#stop()
+ */
+ public void stop()
+ {
+ if (isTMInitialized())
+ {
+ TransactionManager tm = getTransactionManager();
+ if (tm instanceof UserTransactionManager)
+ {
+ UserTransactionManager utm = (UserTransactionManager)tm;
+ utm.close();
+ }
+ }
+ }
+}
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2011-05-24 04:33:12 UTC (rev 4415)
+++ kernel/trunk/pom.xml 2011-05-24 06:32:39 UTC (rev 4416)
@@ -213,6 +213,11 @@
<artifactId>jotm-core</artifactId>
<version>2.1.9</version>
</dependency>
+ <dependency>
+ <groupId>com.atomikos</groupId>
+ <artifactId>transactions-jta</artifactId>
+ <version>3.7.0</version>
+ </dependency>
</dependencies>
</dependencyManagement>