[jboss-svn-commits] JBL Code SVN: r37302 - in labs/jbosstm/trunk: ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 25 11:00:57 EDT 2011
Author: jhalliday
Date: 2011-07-25 11:00:57 -0400 (Mon, 25 Jul 2011)
New Revision: 37302
Added:
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecordWrappingPlugin.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecordWrappingPluginImpl.java
Modified:
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java
Log:
Support XAResourceWrapper. JBTM-859
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -41,6 +41,7 @@
import com.arjuna.ats.internal.arjuna.common.UidHelper;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
import com.arjuna.ats.jta.logging.jtaLogger;
import com.arjuna.ats.jta.common.jtaPropertyManager;
import com.arjuna.ats.jta.recovery.*;
@@ -177,7 +178,7 @@
* transaction.
*/
- public XAResource getNewXAResource(Xid xid)
+ private XAResource getNewXAResource(Xid xid)
{
if (_xidScans == null) {
resourceInitiatedRecovery();
@@ -201,6 +202,17 @@
return null;
}
+ /**
+ * @param xaResourceRecord The record to reassociate.
+ *
+ * @return the XAResource than can be used to commit/rollback the specified
+ * record.
+ */
+ public XAResource getNewXAResource(XAResourceRecord xaResourceRecord)
+ {
+ return getNewXAResource(xaResourceRecord.getXid());
+ }
+
protected XARecoveryModule(XARecoveryResourceManager recoveryClass, String logName)
{
_logName = logName;
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -101,6 +101,10 @@
}
_theXAResource = res;
+ if(_xaResourceRecordWrappingPlugin != null) {
+ _xaResourceRecordWrappingPlugin.transcribeWrapperData(this);
+ }
+
_recoveryObject = null;
_tranID = xid;
@@ -181,7 +185,7 @@
public int topLevelPrepare()
{
if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("XAResourceRecord.topLevelPrepare for " + _tranID);
+ jtaLogger.logger.trace("XAResourceRecord.topLevelPrepare for " + this);
}
if (!_valid || (_theXAResource == null) || (_tranID == null))
@@ -263,7 +267,7 @@
public int topLevelAbort()
{
if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("XAResourceRecord.topLevelAbort for " + _tranID);
+ jtaLogger.logger.trace("XAResourceRecord.topLevelAbort for " + this);
}
if (!_valid)
@@ -411,7 +415,7 @@
public int topLevelCommit()
{
if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("XAResourceRecord.topLevelCommit for " + _tranID);
+ jtaLogger.logger.trace("XAResourceRecord.topLevelCommit for " + this);
}
if (!_prepared)
@@ -557,7 +561,7 @@
public int topLevelOnePhaseCommit()
{
if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("XAResourceRecord.topLevelOnePhaseCommit for " + _tranID);
+ jtaLogger.logger.trace("XAResourceRecord.topLevelOnePhaseCommit for " + this);
}
boolean commit = true;
@@ -730,7 +734,7 @@
public boolean forgetHeuristic()
{
if (jtaLogger.logger.isTraceEnabled()) {
- jtaLogger.logger.trace("XAResourceRecord.forget for " + _tranID);
+ jtaLogger.logger.trace("XAResourceRecord.forget for " + this);
}
forget();
@@ -807,33 +811,37 @@
{
os.packInt(RecoverableXAConnection.OBJECT_RECOVERY);
- if (_theXAResource instanceof Serializable)
- {
- try
- {
- ByteArrayOutputStream s = new ByteArrayOutputStream();
- ObjectOutputStream o = new ObjectOutputStream(s);
+ os.packString(_productName);
+ os.packString(_productVersion);
+ os.packString(_jndiName);
- o.writeObject(_theXAResource);
- o.close();
+ if (_theXAResource instanceof Serializable)
+ {
+ try
+ {
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ ObjectOutputStream o = new ObjectOutputStream(s);
- os.packBoolean(true);
+ o.writeObject(_theXAResource);
+ o.close();
- os.packBytes(s.toByteArray());
- }
- catch (NotSerializableException ex)
- {
- jtaLogger.i18NLogger.warn_resources_arjunacore_savestate();
+ os.packBoolean(true);
- return false;
- }
- }
- else
- {
- // have to rely upon XAResource.recover!
+ os.packBytes(s.toByteArray());
+ }
+ catch (NotSerializableException ex)
+ {
+ jtaLogger.i18NLogger.warn_resources_arjunacore_savestate();
- os.packBoolean(false);
- }
+ return false;
+ }
+ }
+ else
+ {
+ // have to rely upon XAResource.recover!
+
+ os.packBoolean(false);
+ }
}
else
{
@@ -874,6 +882,10 @@
if (os.unpackInt() == RecoverableXAConnection.OBJECT_RECOVERY)
{
+ _productName = os.unpackString();
+ _productVersion = os.unpackString();
+ _jndiName = os.unpackString();
+
boolean haveXAResource = os.unpackBoolean();
if (haveXAResource)
@@ -911,7 +923,7 @@
if (_theXAResource == null)
{
- jtaLogger.i18NLogger.warn_resources_arjunacore_norecoveryxa(XAHelper.xidToString(_tranID));
+ jtaLogger.i18NLogger.warn_resources_arjunacore_norecoveryxa( toString() );
/*
* Don't prevent tx from activating because there may be
@@ -999,7 +1011,63 @@
return false;
}
- public XAResourceRecord()
+ /**
+ * Returns the resource manager product name.
+ * @return the product name
+ */
+ public String getProductName()
+ {
+ return _productName;
+ }
+
+ /**
+ * Sets the resource manager product name.
+ * @param productName the product name
+ */
+ public void setProductName(String productName)
+ {
+ this._productName = productName;
+ }
+
+ /**
+ * Returns the resource manager product version.
+ * @return the product version
+ */
+ public String getProductVersion()
+ {
+ return _productVersion;
+ }
+
+ /**
+ * Sets the resource manager product version.
+ * @param productVersion the product version
+ */
+ public void setProductVersion(String productVersion)
+ {
+ this._productVersion = productVersion;
+ }
+
+ /**
+ * Returns the resource manager JNDI name for e.g. xa datasource.
+ * Note this is not used for lookup, only for information.
+ * @return the JNDI name.
+ */
+ public String getJndiName()
+ {
+ return _jndiName;
+ }
+
+ /**
+ * Sets the resource manager JNDI name.
+ * Note this is not used for lookup, only for information.
+ * @param jndiName the JNDI name.
+ */
+ public void setJndiName(String jndiName)
+ {
+ this._jndiName = jndiName;
+ }
+
+ public XAResourceRecord()
{
super();
@@ -1025,22 +1093,17 @@
_valid = true;
_theTransaction = null;
_recovered = true;
- }
-
- public String toString ()
- {
- return "XAResourceRecord < resource:"+_theXAResource+", txid:"+_tranID+", heuristic"+TwoPhaseOutcome.stringForm(_heuristic)+" "+super.toString()+" >";
- }
+ }
- /**
- * For those objects where the original XAResource could not be saved.
- */
+ public String toString ()
+ {
+ return "XAResourceRecord < resource:"+_theXAResource+", txid:"+_tranID+
+ ", heuristic: "+TwoPhaseOutcome.stringForm(_heuristic)+
+ ((_productName != null && _productVersion != null) ? ", product: "+_productName+"/"+_productVersion : "")+
+ ((_jndiName != null) ? ", jndiName: "+_jndiName : "")+
+ " "+super.toString()+" >";
+ }
- protected synchronized void setXAResource(XAResource res)
- {
- _theXAResource = res;
- }
-
/**
* This routine finds the new XAResource for the transaction that used the
* old resource we couldn't serialize. It does this by looking up the
@@ -1070,7 +1133,7 @@
* Blaargh! There are better ways to do this!
*/
- return ((XARecoveryModule) m).getNewXAResource(_tranID);
+ return ((XARecoveryModule) m).getNewXAResource(this);
}
}
}
@@ -1136,6 +1199,12 @@
private TransactionImple _theTransaction;
private boolean _recovered = false;
+ // extra metadata from the wrapper, if present
+ private String _productName;
+ private String _productVersion;
+ private String _jndiName;
+ private static final XAResourceRecordWrappingPlugin _xaResourceRecordWrappingPlugin;
+
private static boolean _rollbackOptimization = false;
private static boolean _assumedComplete = false;
@@ -1156,6 +1225,8 @@
* with. Hence USE WITH EXTREME CARE!!
*/
_assumedComplete = jtaPropertyManager.getJTAEnvironmentBean().isXaAssumeRecoveryComplete();
+
+ _xaResourceRecordWrappingPlugin = jtaPropertyManager.getJTAEnvironmentBean().getXAResourceRecordWrappingPlugin();
}
}
Copied: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecordWrappingPlugin.java (from rev 37287, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecordWrappingPlugin.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecordWrappingPlugin.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecordWrappingPlugin.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package com.arjuna.ats.internal.jta.resources.arjunacore;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * Callback interface to allow customisable population of XAResourceRecord metadata.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2011-07
+ */
+public interface XAResourceRecordWrappingPlugin
+{
+ public void transcribeWrapperData(XAResourceRecord record);
+
+ public String getEISName(XAResource xaResource);
+}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -32,6 +32,7 @@
package com.arjuna.ats.internal.jta.transaction.arjunacore;
import com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecordWrappingPlugin;
import com.arjuna.ats.internal.jta.xa.TxInfo;
import com.arjuna.ats.internal.jta.utils.*;
import com.arjuna.ats.internal.jta.utils.arjunacore.StatusConverter;
@@ -571,7 +572,7 @@
}
}
- xid = createXid(branchRequired, theModifier);
+ xid = createXid(branchRequired, theModifier, xaRes);
boolean associatedWork = false;
int retry = 20;
@@ -651,7 +652,7 @@
|| (e.errorCode == XAException.XAER_RMERR))
{
if (retry > 0)
- xid = createXid(true, theModifier);
+ xid = createXid(true, theModifier, xaRes);
retry--;
}
@@ -975,7 +976,7 @@
Xid res = baseXid();
if (res == null)
- res = new XidImple(_theTransaction, false);
+ res = new XidImple(_theTransaction);
return res;
}
@@ -1482,14 +1483,20 @@
return null;
}
- private final Xid createXid(boolean branch, XAModifier theModifier)
+ private final Xid createXid(boolean branch, XAModifier theModifier, XAResource xaResource)
{
Xid xid = baseXid();
if (xid != null)
return xid;
- xid = new XidImple(_theTransaction, branch);
+ String eisName = null;
+ if(branch) {
+ if(_xaResourceRecordWrappingPlugin != null) {
+ eisName = _xaResourceRecordWrappingPlugin.getEISName(xaResource);
+ }
+ }
+ xid = new XidImple(_theTransaction, branch, eisName);
if (theModifier != null)
{
@@ -1590,6 +1597,8 @@
private static final Class LAST_RESOURCE_OPTIMISATION_INTERFACE;
+ private static final XAResourceRecordWrappingPlugin _xaResourceRecordWrappingPlugin;
+
static
{
XA_TRANSACTION_TIMEOUT_ENABLED = jtaPropertyManager.getJTAEnvironmentBean().isXaTransactionTimeoutEnabled();
@@ -1599,6 +1608,8 @@
if(LAST_RESOURCE_OPTIMISATION_INTERFACE == null) {
jtaLogger.i18NLogger.warn_transaction_arjunacore_lastResourceOptimisationInterface(jtaPropertyManager.getJTAEnvironmentBean().getLastResourceOptimisationInterfaceClassName());
}
+
+ _xaResourceRecordWrappingPlugin = jtaPropertyManager.getJTAEnvironmentBean().getXAResourceRecordWrappingPlugin();
}
private static ConcurrentHashMap _transactions = new ConcurrentHashMap();
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -21,6 +21,7 @@
package com.arjuna.ats.jta.common;
import com.arjuna.ats.internal.arjuna.common.ClassloadingUtility;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecordWrappingPlugin;
import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
import com.arjuna.ats.jta.resources.XAResourceMap;
@@ -83,6 +84,9 @@
private volatile String lastResourceOptimisationInterfaceClassName = "com.arjuna.ats.jta.resources.LastResourceCommitOptimisation";
private volatile Class lastResourceOptimisationInterface = null;
+ private volatile String xaResourceRecordWrappingPluginClassName;
+ private volatile XAResourceRecordWrappingPlugin xaResourceRecordWrappingPlugin;
+
/**
* Returns true if subtransactions are allowed.
* Warning: subtransactions are not JTA spec compliant and most XA resource managers don't understand them.
@@ -859,4 +863,84 @@
}
}
}
+
+ /**
+ * Returns the class name of the XAResourceRecordWrappingPlugin implementation.
+ *
+ * Default: null
+ *
+ * @return the name of the class implementing XAResourceRecordWrappingPlugin.
+ */
+ public String getXAResourceRecordWrappingPluginClassName()
+ {
+ return xaResourceRecordWrappingPluginClassName;
+ }
+
+ /**
+ * Sets the class name of the XAResourceRecordWrappingPlugin implementation.
+ *
+ * @param xaResourceRecordWrappingPluginClassName the name of a class which implements XAResourceRecordWrappingPlugin.
+ */
+ public void setXAResourceRecordWrappingPluginClassName(String xaResourceRecordWrappingPluginClassName)
+ {
+ synchronized(this)
+ {
+ if(xaResourceRecordWrappingPluginClassName == null)
+ {
+ this.xaResourceRecordWrappingPlugin = null;
+ }
+ else if(!xaResourceRecordWrappingPluginClassName.equals(this.xaResourceRecordWrappingPluginClassName))
+ {
+ this.xaResourceRecordWrappingPlugin = null;
+ }
+ this.xaResourceRecordWrappingPluginClassName = xaResourceRecordWrappingPluginClassName;
+ }
+ }
+
+ /**
+ * Returns an instance of a class implementing XAResourceRecordWrappingPlugin.
+ *
+ * If there is no pre-instantiated instance set and classloading or instantiation fails,
+ * this method will log an appropriate warning and return null, not throw an exception.
+ *
+ * @return a XAResourceRecordWrappingPlugin implementation instance, or null.
+ */
+ public XAResourceRecordWrappingPlugin getXAResourceRecordWrappingPlugin()
+ {
+ if(xaResourceRecordWrappingPlugin == null && xaResourceRecordWrappingPluginClassName != null)
+ {
+ synchronized(this) {
+ if(xaResourceRecordWrappingPlugin == null && xaResourceRecordWrappingPluginClassName != null) {
+ XAResourceRecordWrappingPlugin instance = ClassloadingUtility.loadAndInstantiateClass(XAResourceRecordWrappingPlugin.class, xaResourceRecordWrappingPluginClassName, null);
+ xaResourceRecordWrappingPlugin = instance;
+ }
+ }
+ }
+
+ return xaResourceRecordWrappingPlugin;
+ }
+
+ /**
+ * Sets the instance of XAResourceRecordWrappingPlugin
+ *
+ * @param instance an Object that implements XAResourceRecordWrappingPlugin, or null.
+ */
+ public void setXAResourceRecordWrappingPlugin(XAResourceRecordWrappingPlugin instance)
+ {
+ synchronized(this)
+ {
+ XAResourceRecordWrappingPlugin oldInstance = this.xaResourceRecordWrappingPlugin;
+ xaResourceRecordWrappingPlugin = instance;
+
+ if(instance == null)
+ {
+ this.xaResourceRecordWrappingPluginClassName = null;
+ }
+ else if(instance != oldInstance)
+ {
+ String name = ClassloadingUtility.getNameForClass(instance);
+ this.xaResourceRecordWrappingPluginClassName = name;
+ }
+ }
+ }
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -48,12 +48,12 @@
{
public static final int FORMAT_ID = 131076; // different from JTS ones.
- static XID getXid (Uid uid, boolean branch) throws IllegalStateException
+ static XID getXid (Uid uid, boolean branch, String eisName) throws IllegalStateException
{
if (branch)
- return getXid(uid, new Uid(), FORMAT_ID, null);
+ return getXid(uid, new Uid(), FORMAT_ID, eisName);
else
- return getXid(uid, Uid.nullUid(), FORMAT_ID, null);
+ return getXid(uid, Uid.nullUid(), FORMAT_ID, eisName);
}
public static Xid getXid (Uid uid, boolean branch, int formatId) throws IllegalStateException
@@ -188,7 +188,27 @@
private static String getEISName(XID xid)
{
- return "unknown eis name"; // TODO
+ if(xid == null || xid.formatID != FORMAT_ID) {
+ return "unknown eis name";
+ }
+
+ Uid uid = getUid(xid);
+ int uidLength = uid.getBytes().length;
+ int nameLength = xid.bqual_length-uidLength;
+
+ if(nameLength == 0) {
+ return "unknown eis name";
+ }
+
+ byte[] eisName = new byte[nameLength];
+ System.arraycopy(xid.data, xid.gtrid_length+uidLength, eisName, 0, eisName.length);
+
+ try {
+ return new String(eisName, "US-ASCII");
+ } catch(UnsupportedEncodingException e) {
+ // should never happen, we use a required charset.
+ return "<failed to get eisName>";
+ }
}
public static String getXIDString(XID xid)
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -72,24 +72,24 @@
public XidImple (AtomicAction c)
{
- this(c.get_uid(), false);
+ this(c.get_uid(), false, null);
}
- public XidImple (AtomicAction c, boolean branch)
+ public XidImple (AtomicAction c, boolean branch, String eisName)
{
- this(c.get_uid(), branch);
+ this(c.get_uid(), branch, eisName);
}
public XidImple (Uid id)
{
- this(id, false);
+ this(id, false, null);
}
- public XidImple (Uid id, boolean branch)
+ public XidImple (Uid id, boolean branch, String eisName)
{
try
{
- _theXid = XATxConverter.getXid(id, branch);
+ _theXid = XATxConverter.getXid(id, branch, eisName);
}
catch (Exception e)
{
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -34,6 +34,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
import com.arjuna.ats.jta.xa.XidImple;
@@ -80,18 +81,18 @@
jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r);
XARecoveryModule xarm = new XARecoveryModule();
+
+ assertNull(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(), null) ));
- assertNull(xarm.getNewXAResource(new XidImple()));
-
for (int i = 0; i < 11; i++)
{
xarm.periodicWorkFirstPass();
xarm.periodicWorkSecondPass();
}
- assertTrue(xarm.getNewXAResource(new XidImple(new Uid())) == null);
+ assertTrue(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(new Uid()), null) ) == null);
- assertNull(xarm.getNewXAResource(new XidImple()));
+ assertNull(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(), null) ));
}
@Test
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -167,19 +167,21 @@
@Test
public void testXidCreation () throws Exception
{
- Class[] parameterTypes = new Class[2];
+ Class[] parameterTypes = new Class[3];
TransactionImple tx = new TransactionImple(0);
parameterTypes[0] = boolean.class;
parameterTypes[1] = XAModifier.class;
+ parameterTypes[2] = XAResource.class;
Method m = tx.getClass().getDeclaredMethod("createXid", parameterTypes);
m.setAccessible(true);
- Object[] parameters = new Object[2];
+ Object[] parameters = new Object[3];
parameters[0] = false;
parameters[1] = new DummyXAModifier();
+ parameters[2] = new DummyXA(false);
Xid res = (Xid) m.invoke(tx, parameters);
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java 2011-07-25 14:16:41 UTC (rev 37301)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -47,7 +47,7 @@
public void test()
{
Uid test = new Uid();
- XidImple xidImple = new XidImple(test, true);
+ XidImple xidImple = new XidImple(test, true, null);
System.err.println("Uid is: "+test);
System.err.println("Xid is: "+xidImple);
Copied: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecordWrappingPluginImpl.java (from rev 37287, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecordWrappingPluginImpl.java)
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecordWrappingPluginImpl.java (rev 0)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecordWrappingPluginImpl.java 2011-07-25 15:00:57 UTC (rev 37302)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package com.arjuna.ats.internal.jbossatx.jta;
+
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
+import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecordWrappingPlugin;
+
+import javax.transaction.xa.XAResource;
+import org.jboss.tm.XAResourceWrapper;
+
+/**
+ * A plugin implementation for copying resource metadata from the JBoss AS specific
+ * XAResourceWrapper class to an XAResourceRecord.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2011-07
+ */
+public class XAResourceRecordWrappingPluginImpl implements XAResourceRecordWrappingPlugin
+{
+ public void transcribeWrapperData(XAResourceRecord record) {
+
+ XAResource xaResource = (XAResource)record.value();
+
+ if(xaResource instanceof XAResourceWrapper) {
+ XAResourceWrapper xaResourceWrapper = (XAResourceWrapper)xaResource;
+ record.setProductName(xaResourceWrapper.getProductName());
+ record.setProductVersion(xaResourceWrapper.getProductVersion());
+ record.setJndiName(xaResourceWrapper.getJndiName());
+ }
+ }
+
+ public String getEISName(XAResource xaResource) {
+
+ if(xaResource instanceof XAResourceWrapper) {
+ return ((XAResourceWrapper) xaResource).getJndiName();
+ } else {
+ return null;
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list