[jboss-svn-commits] JBL Code SVN: r30085 - in labs/jbosstm/trunk: ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 10 09:24:43 EST 2009
Author: jhalliday
Date: 2009-11-10 09:24:43 -0500 (Tue, 10 Nov 2009)
New Revision: 30085
Added:
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jts/XidUtils.java
Removed:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/xa/
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils/XATxConverter.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/
Modified:
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/jndi.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XAModifier.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/AtomicTransaction.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/ControlWrapper.java
labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/utils/Utility.java
Log:
Moved Xid handling into jta/jtax where it belongs. JBTM-653
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils/XATxConverter.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils/XATxConverter.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils/XATxConverter.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -1,212 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, 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) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2002,
- *
- * Hewlett-Packard Arjuna Labs,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: XATxConverter.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.internal.arjuna.utils;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.xa.XID;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author Mark Little (mark.little at arjuna.com)
- * @version $Id: XATxConverter.java 2342 2006-03-30 13:06:17Z $
- * @since JTS 1.0.
- */
-
-public class XATxConverter
-{
- public static final int FORMAT_ID = 131076; // different from JTS ones.
-
- public static XID getXid (Uid uid, boolean branch) throws IllegalStateException
- {
- return getXid(uid, branch, FORMAT_ID);
- }
-
- public static XID getXid (Uid uid, boolean branch, int formatId) throws IllegalStateException
- {
- if (branch)
- return getXid(uid, new Uid(), formatId, null);
- else
- return getXid(uid, Uid.nullUid(), formatId, null);
- }
-
- private static XID getXid(Uid uid, Uid branch, int formatId, String eisNameString) throws IllegalStateException
- {
- if (uid == null) {
- throw new IllegalStateException();
- }
-
- XID xid = new XID();
- xid.formatID = formatId;
-
- // gtrid is uid byte form followed by as many chars of the node name as will fit.
- byte[] gtridUid = uid.getBytes();
-
- if (gtridUid.length > XID.MAXBQUALSIZE) {
- throw new IllegalStateException(); // Uid is too long!!!!
- }
-
- int spareGtridBytes = XID.MAXGTRIDSIZE - gtridUid.length;
- byte[] nodeName = TxControl.getXANodeName();
- int nodeNameLengthToUse = nodeName.length;
- if( nodeName.length > spareGtridBytes) {
- nodeNameLengthToUse = spareGtridBytes;
- }
- xid.gtrid_length = gtridUid.length+nodeNameLengthToUse;
-
- // src, srcPos, dest, destPos, length
- System.arraycopy(gtridUid, 0, xid.data, 0, gtridUid.length);
- System.arraycopy(nodeName, 0, xid.data, gtridUid.length, nodeNameLengthToUse);
-
-
- if (branch.notEquals(Uid.nullUid()))
- {
- // bqual is uid byte form plus EIS name.
- byte[] bqualUid = branch.getBytes();
-
- if (bqualUid.length > XID.MAXBQUALSIZE) {
- throw new IllegalStateException(); // Uid is too long!!!!
- }
-
- int spareBqualBytes = XID.MAXBQUALSIZE - bqualUid.length;
- byte[] eisName;
- try {
- // caution: we may truncate the byte[] to fit, so double byte encodings are best avoided.
- eisName = (eisNameString == null ? new byte[0] : eisNameString.getBytes("US-ASCII"));
- } catch(UnsupportedEncodingException e) {
- eisName = new byte[0];
- }
- int eisNameLengthToUse = eisName.length;
- if( eisName.length > spareBqualBytes) {
- eisNameLengthToUse = spareBqualBytes;
- }
- xid.bqual_length = bqualUid.length+eisNameLengthToUse;
-
- // src, srcPos, dest, destPos, length
- System.arraycopy (bqualUid, 0, xid.data, xid.gtrid_length, bqualUid.length);
- System.arraycopy (eisName, 0, xid.data, xid.gtrid_length+bqualUid.length, eisNameLengthToUse);
- }
- else
- {
- /*
- * Note: for some dbs we seem to be able to get
- * away with setting the size field to the size
- * of the actual branch. However, for Oracle,
- * it appears as though it must always be 64.
- * (At least for zero branches.)
- */
- xid.data[xid.gtrid_length] = (byte) 0;
- xid.bqual_length = 64;
- }
-
- return xid;
- }
-
- public static Uid getUid(XID xid)
- {
- if (xid == null || xid.formatID != FORMAT_ID) {
- return Uid.nullUid();
- }
-
- // The Uid byte are the first in the data array, so we just pass
- // in the whole thing and the additional trailing data is ignored.
- Uid tx = new Uid(xid.data);
- return tx;
- }
-
- public static String getNodeName(XID xid)
- {
- if(xid.formatID != FORMAT_ID) {
- return null;
- }
-
- // the node name follows the Uid with no separator, so the only
- // way to tell where it starts is to figure out how long the Uid is.
- Uid uid = getUid(xid);
- int uidLength = uid.getBytes().length;
- int nameLength = xid.gtrid_length-uidLength;
- byte[] nodeName = new byte[nameLength];
- System.arraycopy(xid.data, uidLength, nodeName, 0, nodeName.length);
-
- try {
- return new String(nodeName, "US-ASCII");
- } catch(UnsupportedEncodingException e) {
- // should never happen, we use a required charset.
- return "<failed to get nodename>";
- }
- }
-
- private static Uid getBranchUid(XID xid)
- {
- if (xid == null || xid.formatID != FORMAT_ID) {
- return Uid.nullUid();
- }
-
- byte[] bqual = new byte[xid.bqual_length];
- System.arraycopy(xid.data, xid.gtrid_length, bqual, 0, xid.bqual_length);
-
- // The Uid byte are the first in the data array, so we just pass
- // in the whole thing and the additional trailing data is ignored.
- Uid tx = new Uid(bqual);
- return tx;
- }
-
- private static String getEISName(XID xid)
- {
- return "unknown eis name"; // TODO
- }
-
- public static String getXIDString(XID xid)
- {
- // companion method to XID.toString - try to keep them in sync.
-
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("< formatId=");
- stringBuilder.append(xid.formatID);
- stringBuilder.append(", gtrid_length=");
- stringBuilder.append(xid.gtrid_length);
- stringBuilder.append(", bqual_length=");
- stringBuilder.append(xid.bqual_length);
- stringBuilder.append(", tx_uid=");
- stringBuilder.append(getUid(xid).stringForm());
- stringBuilder.append(", node_name=");
- stringBuilder.append(getNodeName(xid));
- stringBuilder.append(", branch_uid=");
- stringBuilder.append(getBranchUid(xid));
- stringBuilder.append(", eis_name=");
- stringBuilder.append(getEISName(xid));
- stringBuilder.append(" >");
-
- return stringBuilder.toString();
- }
-}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/jndi.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/jndi.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/drivers/modifiers/jndi.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -32,11 +32,9 @@
package com.arjuna.ats.internal.jdbc.drivers.modifiers;
import com.arjuna.ats.jta.xa.XAModifier;
-import com.arjuna.ats.jta.xa.XidImple;
import com.arjuna.ats.jta.exceptions.NotImplementedException;
import com.arjuna.ats.jdbc.logging.jdbcLogger;
-import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.transaction.xa.Xid;
@@ -76,7 +74,7 @@
return level;
}
- public Xid createXid (XidImple xid) throws NotImplementedException
+ public Xid createXid (Xid xid) throws NotImplementedException
{
throw new NotImplementedException();
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -32,7 +32,7 @@
package com.arjuna.ats.jta.utils;
import com.arjuna.ats.jta.logging.jtaLogger;
-import com.arjuna.ats.arjuna.xa.XID;
+import com.arjuna.ats.jta.xa.XidImple;
import javax.transaction.xa.*;
@@ -212,7 +212,7 @@
public static String xidToString (Xid xid)
{
- if(xid instanceof XID) {
+ if(xid instanceof XidImple) {
// ensure consistent representation of our native XIDs in the log output.
return xid.toString();
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XAModifier.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XAModifier.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XAModifier.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -56,7 +56,7 @@
* fact that the JTA does not mention this!
*/
- public Xid createXid (XidImple xid) throws SQLException, NotImplementedException;
+ public Xid createXid (Xid xid) throws SQLException, NotImplementedException;
/**
* Return the xa_start parameters for this level.
Copied: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java (from rev 30075, labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/utils/XATxConverter.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -0,0 +1,218 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2002,
+ *
+ * Hewlett-Packard Arjuna Labs,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: XATxConverter.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.jta.xa;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+
+import javax.transaction.xa.Xid;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author Mark Little (mark.little at arjuna.com)
+ * @version $Id: XATxConverter.java 2342 2006-03-30 13:06:17Z $
+ * @since JTS 1.0.
+ */
+
+public class XATxConverter
+{
+ public static final int FORMAT_ID = 131076; // different from JTS ones.
+
+ static XID getXid (Uid uid, boolean branch) throws IllegalStateException
+ {
+ if (branch)
+ return getXid(uid, new Uid(), FORMAT_ID, null);
+ else
+ return getXid(uid, Uid.nullUid(), FORMAT_ID, null);
+ }
+
+ public static Xid getXid (Uid uid, boolean branch, int formatId) throws IllegalStateException
+ {
+ XID xid;
+ if (branch)
+ xid = getXid(uid, new Uid(), formatId, null);
+ else
+ xid = getXid(uid, Uid.nullUid(), formatId, null);
+
+ return new XidImple(xid);
+ }
+
+ private static XID getXid(Uid uid, Uid branch, int formatId, String eisNameString) throws IllegalStateException
+ {
+ if (uid == null) {
+ throw new IllegalStateException();
+ }
+
+ XID xid = new XID();
+ xid.formatID = formatId;
+
+ // gtrid is uid byte form followed by as many chars of the node name as will fit.
+ byte[] gtridUid = uid.getBytes();
+
+ if (gtridUid.length > XID.MAXBQUALSIZE) {
+ throw new IllegalStateException(); // Uid is too long!!!!
+ }
+
+ int spareGtridBytes = XID.MAXGTRIDSIZE - gtridUid.length;
+ byte[] nodeName = TxControl.getXANodeName();
+ int nodeNameLengthToUse = nodeName.length;
+ if( nodeName.length > spareGtridBytes) {
+ nodeNameLengthToUse = spareGtridBytes;
+ }
+ xid.gtrid_length = gtridUid.length+nodeNameLengthToUse;
+
+ // src, srcPos, dest, destPos, length
+ System.arraycopy(gtridUid, 0, xid.data, 0, gtridUid.length);
+ System.arraycopy(nodeName, 0, xid.data, gtridUid.length, nodeNameLengthToUse);
+
+
+ if (branch.notEquals(Uid.nullUid()))
+ {
+ // bqual is uid byte form plus EIS name.
+ byte[] bqualUid = branch.getBytes();
+
+ if (bqualUid.length > XID.MAXBQUALSIZE) {
+ throw new IllegalStateException(); // Uid is too long!!!!
+ }
+
+ int spareBqualBytes = XID.MAXBQUALSIZE - bqualUid.length;
+ byte[] eisName;
+ try {
+ // caution: we may truncate the byte[] to fit, so double byte encodings are best avoided.
+ eisName = (eisNameString == null ? new byte[0] : eisNameString.getBytes("US-ASCII"));
+ } catch(UnsupportedEncodingException e) {
+ eisName = new byte[0];
+ }
+ int eisNameLengthToUse = eisName.length;
+ if( eisName.length > spareBqualBytes) {
+ eisNameLengthToUse = spareBqualBytes;
+ }
+ xid.bqual_length = bqualUid.length+eisNameLengthToUse;
+
+ // src, srcPos, dest, destPos, length
+ System.arraycopy (bqualUid, 0, xid.data, xid.gtrid_length, bqualUid.length);
+ System.arraycopy (eisName, 0, xid.data, xid.gtrid_length+bqualUid.length, eisNameLengthToUse);
+ }
+ else
+ {
+ /*
+ * Note: for some dbs we seem to be able to get
+ * away with setting the size field to the size
+ * of the actual branch. However, for Oracle,
+ * it appears as though it must always be 64.
+ * (At least for zero branches.)
+ */
+ xid.data[xid.gtrid_length] = (byte) 0;
+ xid.bqual_length = 64;
+ }
+
+ return xid;
+ }
+
+ public static Uid getUid(XID xid)
+ {
+ if (xid == null || xid.formatID != FORMAT_ID) {
+ return Uid.nullUid();
+ }
+
+ // The Uid byte are the first in the data array, so we just pass
+ // in the whole thing and the additional trailing data is ignored.
+ Uid tx = new Uid(xid.data);
+ return tx;
+ }
+
+ public static String getNodeName(XID xid)
+ {
+ if(xid.formatID != FORMAT_ID) {
+ return null;
+ }
+
+ // the node name follows the Uid with no separator, so the only
+ // way to tell where it starts is to figure out how long the Uid is.
+ Uid uid = getUid(xid);
+ int uidLength = uid.getBytes().length;
+ int nameLength = xid.gtrid_length-uidLength;
+ byte[] nodeName = new byte[nameLength];
+ System.arraycopy(xid.data, uidLength, nodeName, 0, nodeName.length);
+
+ try {
+ return new String(nodeName, "US-ASCII");
+ } catch(UnsupportedEncodingException e) {
+ // should never happen, we use a required charset.
+ return "<failed to get nodename>";
+ }
+ }
+
+ private static Uid getBranchUid(XID xid)
+ {
+ if (xid == null || xid.formatID != FORMAT_ID) {
+ return Uid.nullUid();
+ }
+
+ byte[] bqual = new byte[xid.bqual_length];
+ System.arraycopy(xid.data, xid.gtrid_length, bqual, 0, xid.bqual_length);
+
+ // The Uid byte are the first in the data array, so we just pass
+ // in the whole thing and the additional trailing data is ignored.
+ Uid tx = new Uid(bqual);
+ return tx;
+ }
+
+ private static String getEISName(XID xid)
+ {
+ return "unknown eis name"; // TODO
+ }
+
+ public static String getXIDString(XID xid)
+ {
+ // companion method to XID.toString - try to keep them in sync.
+
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("< formatId=");
+ stringBuilder.append(xid.formatID);
+ stringBuilder.append(", gtrid_length=");
+ stringBuilder.append(xid.gtrid_length);
+ stringBuilder.append(", bqual_length=");
+ stringBuilder.append(xid.bqual_length);
+ stringBuilder.append(", tx_uid=");
+ stringBuilder.append(getUid(xid).stringForm());
+ stringBuilder.append(", node_name=");
+ stringBuilder.append(getNodeName(xid));
+ stringBuilder.append(", branch_uid=");
+ stringBuilder.append(getBranchUid(xid));
+ stringBuilder.append(", eis_name=");
+ stringBuilder.append(getEISName(xid));
+ stringBuilder.append(" >");
+
+ return stringBuilder.toString();
+ }
+}
Copied: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java (from rev 30075, labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/xa/XID.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: XID.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.jta.xa;
+
+import java.io.Serializable;
+
+/**
+ * An X/Open XID implementation.
+ *
+ * @author Mark Little (mark at arjuna.com)
+ * @version $Id: XID.java 2342 2006-03-30 13:06:17Z $
+ * @since JTS 1.0.
+ */
+// package private, arguably should be inner class of XidImple.
+class XID implements Serializable
+{
+
+ public static final int XIDDATASIZE = 128; /* size in bytes */
+
+ public static final int MAXGTRIDSIZE = 64; /*
+ * maximum size in bytes of
+ * gtrid
+ */
+
+ public static final int MAXBQUALSIZE = 64; /*
+ * maximum size in bytes of
+ * bqual
+ */
+
+ public static final int NULL_XID = -1;
+
+ public XID ()
+ {
+ formatID = NULL_XID;
+ gtrid_length = 0;
+ bqual_length = 0;
+ }
+
+ /**
+ * Check for equality, then check transaction id only.
+ */
+
+ public final boolean isSameTransaction (XID xid)
+ {
+ if (formatID == xid.formatID)
+ {
+ if (gtrid_length == xid.gtrid_length)
+ {
+ if (equals(xid))
+ return true;
+ else
+ {
+ for (int i = 0; i < gtrid_length; i++)
+ {
+ if (data[i] != xid.data[i])
+ return false;
+ }
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public void copy (XID toCopy)
+ {
+ if ((toCopy == null) || (toCopy.formatID == NULL_XID))
+ {
+ formatID = NULL_XID;
+ gtrid_length = 0;
+ bqual_length = 0;
+ }
+ else
+ {
+ formatID = toCopy.formatID;
+ gtrid_length = toCopy.gtrid_length;
+ bqual_length = toCopy.bqual_length;
+
+ System.arraycopy(toCopy.data, 0, data, 0, toCopy.data.length);
+ }
+ }
+
+ public boolean equals (XID other)
+ {
+ if (other == null)
+ return false;
+
+ if (other == this)
+ return true;
+ else
+ {
+ if ((formatID == other.formatID)
+ && (gtrid_length == other.gtrid_length)
+ && (bqual_length == other.bqual_length))
+ {
+ for (int i = 0; i < (gtrid_length + bqual_length); i++)
+ {
+ if (data[i] != other.data[i])
+ return false;
+ }
+
+ return true;
+ }
+ else
+ return false;
+ }
+ }
+
+ public String toString ()
+ {
+ // controversial and not too robust. see JBTM-297 before messing with this.
+
+ if(formatID == XATxConverter.FORMAT_ID) {
+ // it's one of ours, we know how to inspect it:
+ return XATxConverter.getXIDString(this);
+ }
+
+ // it's a foreign id format, use a general algorithm:
+
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.append("< ");
+ stringBuilder.append(formatID);
+ stringBuilder.append(", ");
+ stringBuilder.append(gtrid_length);
+ stringBuilder.append(", ");
+ stringBuilder.append(bqual_length);
+ stringBuilder.append(", ");
+
+ for (int i = 0; i < gtrid_length; i++) {
+ stringBuilder.append(data[i]);
+ }
+ stringBuilder.append(", ");
+ for (int i = 0; i < bqual_length; i++) {
+ stringBuilder.append(gtrid_length+data[i]);
+ }
+
+ stringBuilder.append(" >");
+ return stringBuilder.toString();
+ }
+
+ public int formatID; /* format identifier (0 for OSI) */
+ public int gtrid_length; /* value not to exceed 64 */
+ public int bqual_length; /* value not to exceed 64 */
+ public byte[] data = new byte[XIDDATASIZE];
+
+}
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 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -36,10 +36,7 @@
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.xa.XID;
-import com.arjuna.ats.internal.arjuna.utils.XATxConverter;
-
import java.io.*;
import javax.transaction.xa.Xid;
@@ -102,7 +99,7 @@
hashCode = getHash(_theXid) ;
}
- public XidImple (com.arjuna.ats.arjuna.xa.XID x)
+ public XidImple (XID x)
{
_theXid = x;
hashCode = getHash(_theXid) ;
@@ -193,14 +190,14 @@
return XATxConverter.getNodeName(_theXid);
}
- public final com.arjuna.ats.arjuna.xa.XID getXID ()
+ public final XID getXID ()
{
return _theXid;
}
public final void copy (Xid xid)
{
- _theXid = new com.arjuna.ats.arjuna.xa.XID();
+ _theXid = new XID();
if (xid != null)
{
@@ -302,7 +299,7 @@
try
{
if (_theXid == null)
- _theXid = new com.arjuna.ats.arjuna.xa.XID();
+ _theXid = new XID();
_theXid.formatID = os.unpackInt();
_theXid.gtrid_length = os.unpackInt();
Copied: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java (from rev 30069, labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/xidcheck.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, 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) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.jta.xa;
+
+import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.jta.xa.XidImple;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class xidcheck
+{
+ @Test
+ public void test()
+ {
+ Uid test = new Uid();
+ XidImple xidImple = new XidImple(test, true);
+
+ System.err.println("Uid is: "+test);
+ System.err.println("Xid is: "+xidImple);
+
+ Uid convertedUid = xidImple.getTransactionUid();
+
+ assertEquals(test, convertedUid);
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/AtomicTransaction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/AtomicTransaction.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/AtomicTransaction.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -32,11 +32,12 @@
package com.arjuna.ats.internal.jta.transaction.jts;
import com.arjuna.ats.internal.jts.ControlWrapper;
+import com.arjuna.ats.internal.jts.orbspecific.ControlImple;
+import com.arjuna.ats.internal.jta.utils.jts.XidUtils;
import com.arjuna.ats.jta.logging.*;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.xa.XID;
import com.arjuna.common.util.logging.*;
@@ -44,8 +45,9 @@
import org.omg.CORBA.SystemException;
import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
-import org.omg.CORBA.BAD_OPERATION;
+import javax.transaction.xa.Xid;
+
/**
* An extension of the AtomicTransaction class so we can create new instances
* without having to create a new transaction. Useful for when we work with
@@ -201,20 +203,13 @@
return _theAction;
}
- public final XID get_xid (boolean branch) throws SystemException
+ public final Xid get_xid (boolean branch) throws SystemException
{
- try
- {
- return _theAction.get_xid(branch);
- }
- catch (SystemException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new BAD_OPERATION();
- }
- }
-
+ ControlImple controlImple = _theAction.getImple();
+ if (controlImple != null) {
+ return XidUtils.getXid(controlImple.get_uid(), branch);
+ } else {
+ return XidUtils.getXid(_theAction.getControl(), branch);
+ }
+ }
}
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -1165,7 +1165,7 @@
Xid res = baseXid();
if (res == null)
- res = new XidImple(_theTransaction.get_xid(false));
+ return _theTransaction.get_xid(false);
return res;
}
@@ -1755,21 +1755,13 @@
try
{
- com.arjuna.ats.arjuna.xa.XID jtsXid = _theTransaction.get_xid(branch);
- com.arjuna.ats.arjuna.xa.XID tempXid = new com.arjuna.ats.arjuna.xa.XID();
+ jtaXid = _theTransaction.get_xid(branch);
- tempXid.formatID = jtsXid.formatID;
- tempXid.gtrid_length = jtsXid.gtrid_length;
- tempXid.bqual_length = jtsXid.bqual_length;
- System.arraycopy(jtsXid.data, 0, tempXid.data, 0, tempXid.data.length);
-
- jtaXid = new com.arjuna.ats.jta.xa.XidImple(tempXid);
-
if (theModifier != null)
{
try
{
- jtaXid = theModifier.createXid((com.arjuna.ats.jta.xa.XidImple) jtaXid);
+ jtaXid = theModifier.createXid(jtaXid);
}
catch (Exception e)
{
Added: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jts/XidUtils.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jts/XidUtils.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jts/XidUtils.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, 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) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.arjuna.ats.internal.jta.utils.jts;
+
+import com.arjuna.ats.jta.xa.XATxConverter;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple;
+import com.arjuna.ats.internal.jts.orbspecific.ControlImple;
+import com.arjuna.ats.jts.utils.Utility;
+
+import javax.transaction.xa.Xid;
+
+/**
+ * Utility functions for JTS (i.e. jtax) Xid handling.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+public class XidUtils
+{
+ public static Xid getXid (Uid uid, boolean branch) throws IllegalStateException
+ {
+ return XATxConverter.getXid(uid, branch, ArjunaTransactionImple.interpositionType());
+ }
+
+ public static Xid getXid (org.omg.CosTransactions.Control cont, boolean branch) throws IllegalStateException
+ {
+ if (cont == null)
+ throw new IllegalStateException();
+
+ Uid u = null;
+
+ if (cont instanceof ControlImple)
+ {
+ u = ((ControlImple) cont).get_uid();
+
+ return getXid(u, branch);
+ }
+ else
+ {
+ try
+ {
+ u = Utility.getUid(cont);
+ if(u.equals(Uid.nullUid())) {
+ throw new IllegalStateException();
+ }
+
+ return getXid(u, branch);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/ControlWrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/ControlWrapper.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/ControlWrapper.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -34,7 +34,6 @@
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.coordinator.Reapable;
import com.arjuna.ats.arjuna.coordinator.ActionStatus;
-import com.arjuna.ats.arjuna.xa.XID;
import com.arjuna.ats.jts.exceptions.ExceptionCodes;
import com.arjuna.ats.jts.utils.*;
@@ -535,23 +534,6 @@
}
}
- public final XID get_xid (boolean branch) throws SystemException
- {
- if (_controlImpl != null)
- return Utility.getXid(_controlImpl.get_uid(), branch);
- else
- {
- try
- {
- return Utility.getXid(_control, branch);
- }
- catch (Exception e)
- {
- throw new BAD_OPERATION();
- }
- }
- }
-
public final String get_transaction_name () throws SystemException
{
try
Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/utils/Utility.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/utils/Utility.java 2009-11-10 10:24:21 UTC (rev 30084)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/utils/Utility.java 2009-11-10 14:24:43 UTC (rev 30085)
@@ -32,16 +32,9 @@
package com.arjuna.ats.jts.utils;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.BasicAction;
import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.internal.arjuna.utils.XATxConverter;
-
-import com.arjuna.ats.jts.extensions.Arjuna;
-
import com.arjuna.ats.internal.jts.utils.Helper;
-import com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple;
-import com.arjuna.ats.internal.jts.orbspecific.ControlImple;
import org.omg.CosTransactions.*;
@@ -50,8 +43,7 @@
import java.io.PrintWriter;
import org.omg.CosTransactions.Unavailable;
-import org.omg.CORBA.SystemException;
-import java.lang.IllegalStateException;
+
import org.omg.CORBA.BAD_PARAM;
/**
@@ -145,41 +137,6 @@
* Could easily do it for JBoss transactions only.
*/
- public static com.arjuna.ats.arjuna.xa.XID getXid (Uid uid, boolean branch) throws IllegalStateException
- {
- return XATxConverter.getXid(uid, branch, ArjunaTransactionImple.interpositionType());
- }
-
- public static com.arjuna.ats.arjuna.xa.XID getXid (org.omg.CosTransactions.Control cont, boolean branch) throws IllegalStateException
- {
- if (cont == null)
- throw new IllegalStateException();
-
- Uid u = null;
-
- if (cont instanceof ControlImple)
- {
- u = ((ControlImple) cont).get_uid();
-
- return Utility.getXid(u, branch);
- }
- else
- {
- try
- {
- UidCoordinator arjcoord = Helper.getUidCoordinator(cont);
-
- u = Helper.getUid(arjcoord);
-
- return Utility.getXid(u, branch);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
- }
-
/**
* If this control refers to an JBoss transaction then return its native
* Uid representation. Otherwise return Uid.nullUid().
More information about the jboss-svn-commits
mailing list