[exo-jcr-commits] exo-jcr SVN: r1437 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Jan 16 10:15:51 EST 2010
Author: pnedonosko
Date: 2010-01-16 10:15:51 -0500 (Sat, 16 Jan 2010)
New Revision: 1437
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
Log:
EXOJCR-410: track-without-transaction parameter added
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-16 15:10:12 UTC (rev 1436)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/transaction/impl/jotm/TransactionServiceJotmImpl.java 2010-01-16 15:15:51 UTC (rev 1437)
@@ -48,12 +48,15 @@
* Azarenkov</a>
* @version $Id: $
*/
-
public class TransactionServiceJotmImpl implements TransactionService
{
protected static Log log = ExoLogger.getLogger("transaction.TransactionServiceJotmImpl");
+ public static final String TRACK_WITHOT_TRANSACTION_PARAM = "track-without-transaction";
+
+ private boolean trackWithoutTransaction = true;
+
private Current current;
public TransactionServiceJotmImpl(InitialContextInitializer initializer, InitParams params) throws RemoteException
@@ -65,10 +68,20 @@
current = new Current(tm);
// Change the timeout only if JOTM is not initialized yet
- if (params != null && params.getValueParam("timeout") != null)
+ if (params != null)
{
- int t = Integer.parseInt(params.getValueParam("timeout").getValue());
- current.setDefaultTimeout(t);
+ if (params.getValueParam("timeout") != null)
+ {
+
+ int t = Integer.parseInt(params.getValueParam("timeout").getValue());
+ current.setDefaultTimeout(t);
+ }
+
+ if (params.getValueParam(TRACK_WITHOT_TRANSACTION_PARAM) != null)
+ {
+ trackWithoutTransaction =
+ Boolean.parseBoolean(params.getValueParam(TRACK_WITHOT_TRANSACTION_PARAM).getValue());
+ }
}
}
else
@@ -77,33 +90,24 @@
}
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getTransactionManager
- * ()
+ /**
+ * {@inheritDoc}
*/
public TransactionManager getTransactionManager()
{
return current;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getUserTransaction
- * ()
+ /**
+ * {@inheritDoc}
*/
public UserTransaction getUserTransaction()
{
return current;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#enlistResource(
- * javax.transaction.xa.XAResource)
+ /**
+ * {@inheritDoc}
*/
public void enlistResource(ExoResource exores) throws RollbackException, SystemException
{
@@ -112,20 +116,22 @@
exores.setPayload(entry);
Transaction tx = getTransactionManager().getTransaction();
if (tx != null)
+ {
current.getTransaction().enlistResource(xares);
- else
+ }
+ else if (trackWithoutTransaction)
+ {
current.connectionOpened(entry);
- //
- entry.jotmResourceList = popThreadLocalRMEventList();
- pushThreadLocalRMEventList(entry.jotmResourceList);
+ // actual only if current.connectionOpened(entry);
+ // otherwise NPE inside the JOTM's Current
+ entry.jotmResourceList = popThreadLocalRMEventList();
+ pushThreadLocalRMEventList(entry.jotmResourceList);
+ }
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#delistResource(
- * javax.transaction.xa.XAResource)
+ /**
+ * {@inheritDoc}
*/
public void delistResource(ExoResource exores) throws RollbackException, SystemException
{
@@ -133,42 +139,41 @@
ResourceEntry entry = (ResourceEntry)exores.getPayload();
Transaction tx = getTransactionManager().getTransaction();
if (tx != null)
+ {
current.getTransaction().delistResource(xares, XAResource.TMNOFLAGS);
- else
+ }
+ else if (trackWithoutTransaction)
+ {
current.connectionClosed(entry);
- //
+ // actual only if current.connectionClosed(entry);
+ if (entry != null && entry.jotmResourceList != null)
+ {
+ entry.jotmResourceList.remove(xares);
+ }
+ }
+
exores.setPayload(null);
- if (entry != null && entry.jotmResourceList != null)
- {
- entry.jotmResourceList.remove(xares);
- }
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.transaction.TransactionService#createXid()
+ /**
+ * {@inheritDoc}
*/
public Xid createXid()
{
return new XidImpl();
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#getDefaultTimeout()
+ /**
+ * {@inheritDoc}
*/
public int getDefaultTimeout()
{
return current.getDefaultTimeout();
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.transaction.TransactionService#setTransactionTimeout
- * (int)
+ /**
+ * {@inheritDoc}
*/
public void setTransactionTimeout(int seconds) throws SystemException
{
More information about the exo-jcr-commits
mailing list