[jboss-svn-commits] JBL Code SVN: r37289 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final: ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 22 11:30:46 EDT 2011
Author: jhalliday
Date: 2011-07-22 11:30:46 -0400 (Fri, 22 Jul 2011)
New Revision: 37289
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionSynchronizationRegistryImple.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionSynchronizationRegistryImple.java
Log:
Improve TransactionSynchronizationRegistry performance. JBTM-853
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionSynchronizationRegistryImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionSynchronizationRegistryImple.java 2011-07-22 15:29:39 UTC (rev 37288)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionSynchronizationRegistryImple.java 2011-07-22 15:30:46 UTC (rev 37289)
@@ -25,11 +25,12 @@
import com.arjuna.ats.jta.logging.jtaLogger;
import com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple;
-
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import javax.transaction.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Hashtable;
@@ -50,176 +51,180 @@
private static final long serialVersionUID = 1L;
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
- {
- return this;
- }
+ // cached for performance. Note: must set tm config before instantiating a TSRImple instance.
+ private transient javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
+ objectInputStream.defaultReadObject();
+ tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ }
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
+ {
+ return this;
+ }
+
// Return an opaque object to represent the transaction bound to the current thread at the time this method is called.
- public Object getTransactionKey()
+ public Object getTransactionKey()
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionKey");
+ }
+
+ TransactionImple transactionImple = null;
+ try
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionKey");
- }
+ transactionImple = (TransactionImple)tm.getTransaction();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- TransactionImple transactionImple = null;
- try
- {
- transactionImple = (TransactionImple)tm.getTransaction();
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ if (transactionImple == null) {
+ return null;
+ } else {
+ return transactionImple.get_uid();
+ }
+ }
- if (transactionImple == null) {
- return null;
- } else {
- return transactionImple.get_uid();
- }
+ // Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
+ public void putResource(Object key, Object value)
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.putResource");
}
- // Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
- public void putResource(Object key, Object value)
+ if(key == null)
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.putResource");
- }
+ throw new NullPointerException();
+ }
- if(key == null)
- {
- throw new NullPointerException();
- }
+ TransactionImple transactionImple = getTransactionImple();
+ transactionImple.putTxLocalResource(key, value);
+ }
- TransactionImple transactionImple = getTransactionImple();
- transactionImple.putTxLocalResource(key, value);
+ // Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
+ public Object getResource(Object key)
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getResource");
}
- // Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
- public Object getResource(Object key)
+ if(key == null)
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getResource");
- }
+ throw new NullPointerException();
+ }
- if(key == null)
- {
- throw new NullPointerException();
- }
+ TransactionImple transactionImple = getTransactionImple();
+ return transactionImple.getTxLocalResource(key);
+ }
- TransactionImple transactionImple = getTransactionImple();
- return transactionImple.getTxLocalResource(key);
+ // Register a Synchronization instance with special ordering semantics.
+ public void registerInterposedSynchronization(Synchronization synchronization)
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.registerInterposedSynchronization");
}
- // Register a Synchronization instance with special ordering semantics.
- public void registerInterposedSynchronization(Synchronization synchronization)
+ TransactionImple transactionImple = getTransactionImple();
+
+ try
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.registerInterposedSynchronization");
- }
+ transactionImple.registerSynchronizationImple(new SynchronizationImple(synchronization, true));
+ }
+ catch (RollbackException e)
+ {
+ throw new com.arjuna.ats.jta.exceptions.RollbackException(jtaLogger.i18NLogger.get_transaction_arjunacore_syncrollbackexception(), e);
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
+ }
- TransactionImple transactionImple = getTransactionImple();
-
- try
- {
- transactionImple.registerSynchronizationImple(new SynchronizationImple(synchronization, true));
- }
- catch (RollbackException e)
- {
- throw new com.arjuna.ats.jta.exceptions.RollbackException(jtaLogger.i18NLogger.get_transaction_arjunacore_syncrollbackexception(), e);
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ // Return the status of the transaction bound to the current thread at the time this method is called.
+ public int getTransactionStatus()
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionStatus");
}
- // Return the status of the transaction bound to the current thread at the time this method is called.
- public int getTransactionStatus()
+ try
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionStatus");
- }
+ return tm.getStatus();
+ }
+ catch(SystemException e)
+ {
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- try
- {
- return tm.getStatus();
- }
- catch(SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ }
+ // Set the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
+ public void setRollbackOnly()
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.setRollbackOnly");
}
- // Set the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
- public void setRollbackOnly()
+ try
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.setRollbackOnly");
- }
+ Transaction transaction = tm.getTransaction();
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- try
- {
- Transaction transaction = tm.getTransaction();
+ if(transaction == null)
+ {
+ throw new IllegalStateException();
+ }
- if(transaction == null)
- {
- throw new IllegalStateException();
- }
-
- tm.setRollbackOnly();
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ tm.setRollbackOnly();
}
-
- // Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
- public boolean getRollbackOnly()
+ catch (SystemException e)
{
- if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getRollbackOnly");
- }
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
+ }
- TransactionImple transactionImple = getTransactionImple();
+ // Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
+ public boolean getRollbackOnly()
+ {
+ if (jtaLogger.logger.isTraceEnabled()) {
+ jtaLogger.logger.trace("TransactionSynchronizationRegistryImple.getRollbackOnly");
+ }
- if(transactionImple == null) {
- throw new IllegalStateException();
- }
+ TransactionImple transactionImple = getTransactionImple();
- try
- {
- return (transactionImple.getStatus() == Status.STATUS_MARKED_ROLLBACK);
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ if(transactionImple == null) {
+ throw new IllegalStateException();
}
- private TransactionImple getTransactionImple() throws IllegalStateException
+ try
{
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- TransactionImple transactionImple = null;
- try
- {
- transactionImple = (TransactionImple)tm.getTransaction();
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
- }
+ return (transactionImple.getStatus() == Status.STATUS_MARKED_ROLLBACK);
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
+ }
- if(transactionImple == null)
- {
- throw new IllegalStateException();
- }
+ private TransactionImple getTransactionImple() throws IllegalStateException
+ {
+ TransactionImple transactionImple = null;
+ try
+ {
+ transactionImple = (TransactionImple)tm.getTransaction();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaLogger.i18NLogger.get_transaction_arjunacore_systemexception(), e);
+ }
- return transactionImple;
+ if(transactionImple == null)
+ {
+ throw new IllegalStateException();
}
+
+ return transactionImple;
+ }
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionSynchronizationRegistryImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionSynchronizationRegistryImple.java 2011-07-22 15:29:39 UTC (rev 37288)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionSynchronizationRegistryImple.java 2011-07-22 15:30:46 UTC (rev 37289)
@@ -30,6 +30,8 @@
import javax.naming.Name;
import javax.naming.spi.ObjectFactory;
import javax.transaction.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Hashtable;
@@ -49,179 +51,183 @@
* http://jcp.org/aboutJava/communityprocess/maintenance/jsr907/907ChangeLog.html
*/
- // Return an opaque object to represent the transaction bound to the current thread at the time this method is called.
+ // Return an opaque object to represent the transaction bound to the current thread at the time this method is called.
private static final long serialVersionUID = 1L;
+ // cached for performance. Note: must set tm config before instantiating a TSRImple instance.
+ private transient javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+
+ private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
+ objectInputStream.defaultReadObject();
+ tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ }
+
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
{
return this;
}
- public Object getTransactionKey()
+ public Object getTransactionKey()
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionKey");
+ }
+
+ TransactionImple transactionImple = null;
+ try
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionKey");
- }
+ transactionImple = (TransactionImple)tm.getTransaction();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- TransactionImple transactionImple = null;
- try
- {
- transactionImple = (TransactionImple)tm.getTransaction();
+ if (transactionImple == null) {
+ return null;
+ } else {
+ return transactionImple.get_uid();
}
- catch (SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ }
- if (transactionImple == null) {
- return null;
- } else {
- return transactionImple.get_uid();
- }
+ // Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
+ public void putResource(Object key, Object value)
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.putResource");
}
- // Add or replace an object in the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
- public void putResource(Object key, Object value)
+ if(key == null)
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.putResource");
- }
+ throw new NullPointerException();
+ }
- if(key == null)
- {
- throw new NullPointerException();
- }
+ TransactionImple transactionImple = getTransactionImple();
+ transactionImple.putTxLocalResource(key, value);
+ }
- TransactionImple transactionImple = getTransactionImple();
- transactionImple.putTxLocalResource(key, value);
+ // Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
+ public Object getResource(Object key)
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getResource");
}
- // Get an object from the Map of resources being managed for the transaction bound to the current thread at the time this method is called.
- public Object getResource(Object key)
+ if(key == null)
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getResource");
- }
+ throw new NullPointerException();
+ }
- if(key == null)
- {
- throw new NullPointerException();
- }
+ TransactionImple transactionImple = getTransactionImple();
+ return transactionImple.getTxLocalResource(key);
+ }
- TransactionImple transactionImple = getTransactionImple();
- return transactionImple.getTxLocalResource(key);
+ // Register a Synchronization instance with special ordering semantics.
+ public void registerInterposedSynchronization(Synchronization synchronization)
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.registerInterposedSynchronization");
}
- // Register a Synchronization instance with special ordering semantics.
- public void registerInterposedSynchronization(Synchronization synchronization)
+ TransactionImple transactionImple = getTransactionImple();
+
+ try
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.registerInterposedSynchronization");
- }
+ transactionImple.registerSynchronizationImple(new JTAInterposedSynchronizationImple(synchronization));
+ }
+ catch (RollbackException e)
+ {
+ throw new com.arjuna.ats.jta.exceptions.RollbackException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_syncrollbackexception(), e);
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
+ }
- TransactionImple transactionImple = getTransactionImple();
-
- try
- {
- transactionImple.registerSynchronizationImple(new JTAInterposedSynchronizationImple(synchronization));
- }
- catch (RollbackException e)
- {
- throw new com.arjuna.ats.jta.exceptions.RollbackException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_syncrollbackexception(), e);
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ // Return the status of the transaction bound to the current thread at the time this method is called.
+ public int getTransactionStatus()
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionStatus");
}
- // Return the status of the transaction bound to the current thread at the time this method is called.
- public int getTransactionStatus()
+ try
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getTransactionStatus");
- }
+ return tm.getStatus();
+ }
+ catch(SystemException e)
+ {
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- try
- {
- return tm.getStatus();
- }
- catch(SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ }
+ // Set the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
+ public void setRollbackOnly()
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.setRollbackOnly");
}
- // Set the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
- public void setRollbackOnly()
+ try
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.setRollbackOnly");
- }
+ Transaction transaction = tm.getTransaction();
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- try
- {
- Transaction transaction = tm.getTransaction();
+ if(transaction == null)
+ {
+ throw new IllegalStateException();
+ }
- if(transaction == null)
- {
- throw new IllegalStateException();
- }
-
- tm.setRollbackOnly();
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ tm.setRollbackOnly();
}
-
- // Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
- public boolean getRollbackOnly()
+ catch (SystemException e)
{
- if (jtaxLogger.logger.isTraceEnabled()) {
- jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getRollbackOnly");
- }
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
+ }
- TransactionImple transactionImple = getTransactionImple();
+ // Get the rollbackOnly status of the transaction bound to the current thread at the time this method is called.
+ public boolean getRollbackOnly()
+ {
+ if (jtaxLogger.logger.isTraceEnabled()) {
+ jtaxLogger.logger.trace("TransactionSynchronizationRegistryImple.getRollbackOnly");
+ }
- if(transactionImple == null) {
- throw new IllegalStateException();
- }
+ TransactionImple transactionImple = getTransactionImple();
- try
- {
- return (transactionImple.getStatus() == Status.STATUS_MARKED_ROLLBACK);
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ if(transactionImple == null) {
+ throw new IllegalStateException();
}
- private TransactionImple getTransactionImple() throws IllegalStateException
+ try
{
- javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- TransactionImple transactionImple = null;
- try
- {
- transactionImple = (TransactionImple)tm.getTransaction();
- }
- catch (SystemException e)
- {
- throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
- }
+ return (transactionImple.getStatus() == Status.STATUS_MARKED_ROLLBACK);
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
+ }
- if(transactionImple == null)
- {
- throw new IllegalStateException();
- }
+ private TransactionImple getTransactionImple() throws IllegalStateException
+ {
+ TransactionImple transactionImple = null;
+ try
+ {
+ transactionImple = (TransactionImple)tm.getTransaction();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(jtaxLogger.i18NLogger.get_jtax_transaction_jts_systemexception(), e);
+ }
- return transactionImple;
+ if(transactionImple == null)
+ {
+ throw new IllegalStateException();
}
+
+ return transactionImple;
+ }
}
More information about the jboss-svn-commits
mailing list