[jboss-svn-commits] JBL Code SVN: r26429 - in labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats: internal/jbossatx/jta and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 8 06:12:55 EDT 2009
Author: jhalliday
Date: 2009-05-08 06:12:55 -0400 (Fri, 08 May 2009)
New Revision: 26429
Modified:
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/agent/JBossAgentImpl.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/PropagationContextWrapper.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerDelegate.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerDelegate.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
Log:
Improved exception chaining behaviour. JBTM-548
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/agent/JBossAgentImpl.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/agent/JBossAgentImpl.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/agent/JBossAgentImpl.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
/*
+ * 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, 2001, 2002, 2003
*
* Arjuna Technologies Ltd.
@@ -65,9 +65,11 @@
}
catch (final NamingException ne)
{
- throw new ExceptionInInitializerError("Failed to initialize naming context: " + ne);
+ ExceptionInInitializerError exceptionInInitializerError = new ExceptionInInitializerError("Failed to initialize naming context: " + ne);
+ exceptionInInitializerError.initCause(ne);
+ throw exceptionInInitializerError;
}
-
+
RMIAdaptor adaptor = null ;
try
{
@@ -81,10 +83,12 @@
}
catch (final NamingException ne2)
{
- throw new ExceptionInInitializerError("Failed to retrieve reference to remote MBean server: " + ne2) ;
+ ExceptionInInitializerError exceptionInInitializerError = new ExceptionInInitializerError("Failed to retrieve reference to remote MBean server: " + ne2);
+ exceptionInInitializerError.initCause(ne);
+ throw exceptionInInitializerError;
}
}
-
+
final Class serverClass = MBeanServer.class ;
_server = (MBeanServer)Proxy.newProxyInstance(serverClass.getClassLoader(),
new Class[] {serverClass},new RemoteInvocationHandler(adaptor)) ;
@@ -97,10 +101,10 @@
return _server;
}
-
+
/**
* Remote Invocation Handler using RMIAdaptor.
- *
+ *
* @author kevin
*/
public static class RemoteInvocationHandler implements InvocationHandler
@@ -117,7 +121,7 @@
/**
* Construct the Remote Invocation Handler.
- *
+ *
* @param adaptor
*/
public RemoteInvocationHandler(final RMIAdaptor adaptor)
@@ -127,7 +131,7 @@
/**
* Invoke the method.
- *
+ *
* @param proxy The current proxy.
* @param method The method to invoke.
* @param args The arguments for the invocation.
@@ -147,7 +151,7 @@
catch (final NoSuchMethodException nsme)
{
throw new UnsupportedOperationException("Operation "
- + methodName + " not supported with remote proxy") ;
+ + methodName + " not supported with remote proxy", nsme) ;
}
try
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -60,17 +60,17 @@
* To use this class, add an XAResourceRecovery entry in the jta section of jbossjta-properties.xml
* for each database for which you need recovery, ensuring the value ends with ;jndiname=<datasource-name>
* i.e. the same value as is in the -ds.xml jndi-name element.
- *
+ *
* Note for users with secured JMX invokers, use the extended format:
* ;jndiname=MyExampleDbName,username=foo,password=bar
* The username and password refer to the JMX invoker, NOT the datasource.
- *
+ *
* It's not possible to override the jdbc username and password given in the -ds.xml file at present.
* Since the recovery system sometimes needs greater db user privs than the app code, it may be preferable to
* set up a -ds.xml file only for recovery usage. This approach works for databases which allow users to
* recover one another's transactions, which is most of them. But consult
* your db docs or friendly neighbourhood DBA to be sure, then test it anyhow.
- *
+ *
* You also need the XARecoveryModule enabled and appropriate values for nodeIdentifier and xaRecoveryNode set.
* See the JBossTS recovery guide if you are unclear on how the recovery system works.
*
@@ -78,7 +78,7 @@
* if you configure the recovery manager to run as a separate process. (JMX can be accessed remotely,
* but it would need code changes to the lookup function and some classpath additions).
*
- *
+ *
* <properties depends="arjuna" name="jta">
* ...
* <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery1"
@@ -118,7 +118,7 @@
if (parameter == null)
return false;
-
+
retrieveData(parameter, _DELIMITER);
return true;
@@ -179,13 +179,13 @@
InitialContext context = new InitialContext();
MBeanServerConnection server = (MBeanServerConnection)context.lookup("jmx/invoker/RMIAdaptor");
ObjectName objectName = new ObjectName("jboss.jca:name="+_dataSourceId+",service=ManagedConnectionFactory");
-
+
if(_username !=null && _password !=null)
{
SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
SecurityAssociation.setCredential(_password);
}
-
+
String className = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceClass"}, new String[] {"java.lang.String"});
log.debug("AppServerJDBCXARecovery datasource classname = "+className);
@@ -194,7 +194,7 @@
SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
SecurityAssociation.setCredential(_password);
}
-
+
String properties = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceProperties"}, new String[] {"java.lang.String"});
// debug disabled due to security paranoia - it may log datasource password in cleartext.
// log.debug("AppServerJDBCXARecovery.result="+properties);
@@ -205,7 +205,9 @@
} catch(Exception e) {
_dataSource = null;
log.error("AppServerJDBCXARecovery.createDataSource got exception during getXADataSource call: "+e.toString(), e);
- throw new SQLException(e.toString());
+ SQLException sqlException = new SQLException(e.toString());
+ sqlException.initCause(e);
+ throw sqlException;
}
}
}
@@ -222,7 +224,9 @@
log.error("AppServerJDBCXARecovery.createDataSource(name="+_dataSourceId+") got exception " + mbe.toString(), mbe);
}
- throw new SQLException(mbe.toString());
+ SQLException sqlException = new SQLException(mbe.toString());
+ sqlException.initCause(mbe);
+ throw sqlException;
}
catch (SQLException ex)
{
@@ -234,7 +238,9 @@
{
log.error("AppServerJDBCXARecovery.createDataSource got exception "+e.toString(), e);
- throw new SQLException(e.toString());
+ SQLException sqlException = new SQLException(e.toString());
+ sqlException.initCause(e);
+ throw sqlException;
}
}
@@ -299,7 +305,9 @@
{
log.error("AppServerJDBCXARecovery.createConnection got exception "+e.toString(), e);
- throw new SQLException(e.toString());
+ SQLException sqlException = new SQLException(e.toString());
+ sqlException.initCause(e);
+ throw sqlException;
}
}
@@ -372,7 +380,7 @@
}
return xads;
}
-
+
public void retrieveData(String parameter,String delimiter)
{
StringTokenizer st = new StringTokenizer(parameter,delimiter);
@@ -395,13 +403,13 @@
}
}
}
-
+
if(_dataSourceId == null && parameter != null && !parameter.contains("=")) {
// try to fallback to old parameter format where only the dataSourceId is given, without jndiname= prefix
_dataSourceId = parameter;
}
}
-
+
private boolean _supportsIsValidMethod;
private XAConnection _connection;
private XADataSource _dataSource;
@@ -411,11 +419,11 @@
private String _dataSourceId;
private String _username;
private String _password;
-
+
private final String _JNDINAME = "jndiname";
private final String _USERNAME = "username";
private final String _PASSWORD = "password";
private final String _DELIMITER = ",";
-
+
private Logger log = org.jboss.logging.Logger.getLogger(AppServerJDBCXARecovery.class);
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/PropagationContextWrapper.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/PropagationContextWrapper.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/PropagationContextWrapper.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -1,343 +1,347 @@
-/*
- * 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, 2001, 2002, 2003
- *
- * Arjuna Technologies Ltd.
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: PropagationContextWrapper.java,v 1.5 2004/10/04 09:48:19 nmcl Exp $
- */
-
-package com.arjuna.ats.internal.jbossatx.jts;
-
-import org.omg.CosTransactions.*;
-
-import java.io.*;
-
-import com.arjuna.ats.internal.jts.ORBManager;
-import com.arjuna.ats.jts.utils.Utility;
-
-/**
- * This class is a wrapper around a PropagationContext object allowing it to be serialized.
- *
- * @author Richard A. Begg (richard.begg at arjuna.com)
- * @version $Id: PropagationContextWrapper.java,v 1.5 2004/10/04 09:48:19 nmcl Exp $
- */
-
-public class PropagationContextWrapper implements Externalizable
-{
- private static boolean _propagateFullContext = false;
-
- private boolean _isNull = true;
- private int _timeout;
- private TransIdentityWrapper _current;
- private TransIdentityWrapper[] _parents = null;
-
- private PropagationContext _tpc = null;
-
- public static void setPropagateFullContext(boolean propagateFullContext)
- {
- _propagateFullContext = propagateFullContext;
- }
-
- public static boolean getPropagateFullContext()
- {
- return _propagateFullContext;
- }
-
- /**
- * Default constructor required for serialization
- */
-
- public PropagationContextWrapper()
- {
- }
-
- /**
- * Create a wrapper around a propagation context class
- * @param tpc
- */
-
- public PropagationContextWrapper(PropagationContext tpc)
- {
- this();
-
- _isNull = (tpc == null);
-
- if (tpc != null)
- {
- _current = new TransIdentityWrapper();
-
- _current._coordinator = ORBManager.getORB().orb().object_to_string(tpc.current.coord);
- _current.setOtid(tpc.current.otid);
-
- _timeout = tpc.timeout;
-
- if (_propagateFullContext)
- {
- _current._terminator = ORBManager.getORB().orb().object_to_string(tpc.current.term);
-
- _parents = new TransIdentityWrapper[tpc.parents.length];
-
- for (int count = 0; count < tpc.parents.length; count++)
- {
- _parents[count] = new TransIdentityWrapper();
- _parents[count]._coordinator = ORBManager.getORB().orb().object_to_string(tpc.parents[count].coord);
- _parents[count]._terminator = ORBManager.getORB().orb().object_to_string(tpc.parents[count].term);
- _parents[count].setOtid(tpc.parents[count].otid);
- }
- }
- }
- }
-
- public int hashCode()
- {
- return _isNull ? 0 : _current.hashCode();
- }
-
- public boolean equals(Object o)
- {
- if (o instanceof PropagationContextWrapper)
- {
- PropagationContextWrapper comp = (PropagationContextWrapper) o;
-
- if (!_isNull && !comp._isNull)
- {
- return (_current.equals(comp._current));
- }
- }
-
- return false;
- }
-
- // this is called on the remote side
-
- public PropagationContext getPropagationContext()
- {
- if (_isNull)
- {
- return null;
- }
-
- if (_tpc == null)
- {
- if (_propagateFullContext)
- {
- TransIdentity[] parents = new TransIdentity[_parents != null ? _parents.length : 0];
-
- for (int count = 0; count < parents.length; count++)
- {
- parents[count] = _parents[count].getTransIdentity();
- }
-
- _tpc = new PropagationContext(_timeout,
- _current.getTransIdentity(),
- parents,
- null);
- }
- else
- {
- _tpc = new PropagationContext(_timeout,
- _current.getTransIdentity(),
- new TransIdentity[0], // no parents, but not null
- null);
- }
- }
-
- return _tpc;
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- try
- {
- out.writeBoolean(_propagateFullContext);
- out.writeBoolean(_isNull);
-
- if (!_isNull)
- {
- out.writeInt(_timeout);
- _current.writeExternal(out, _propagateFullContext);
-
- if (_propagateFullContext)
- {
- out.writeInt(_parents.length);
-
- for (int count = 0; count < _parents.length; count++)
- {
- _parents[count].writeExternal(out, _propagateFullContext);
- }
- }
- }
- }
- catch (Exception e)
- {
- throw new IOException(e.toString());
- }
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- try
- {
- boolean fullContext = in.readBoolean();
-
- _isNull = in.readBoolean();
-
- if (!_isNull)
- {
- _timeout = in.readInt();
- _current = new TransIdentityWrapper();
- _current.readExternal(in, fullContext);
-
- if (fullContext)
- {
- _parents = new TransIdentityWrapper[in.readInt()];
-
- for (int count = 0; count < _parents.length; count++)
- {
- _parents[count] = new TransIdentityWrapper();
- _parents[count].readExternal(in, fullContext);
- }
- }
- }
-
- _tpc = null;
- }
- catch (Exception e)
- {
- throw new IOException(e.toString());
- }
- }
-
- /**
- * A wrapper around a transidentity object so that it can be serialized.
- */
-
- private class TransIdentityWrapper implements Serializable
- {
- public String _coordinator = null;
- private otid_t _otid = null;
- public String _terminator = null;
- private int _hashCode = 0;
-
- public TransIdentity getTransIdentity()
- {
- return new TransIdentity(CoordinatorHelper.narrow(ORBManager.getORB().orb().string_to_object(_coordinator)),
- _terminator == null ? null : TerminatorHelper.narrow(ORBManager.getORB().orb().string_to_object(_terminator)),
- _otid);
- }
-
- public otid_t getOtid()
- {
- return _otid;
- }
-
- public void setOtid(otid_t o)
- {
- _otid = o;
- _hashCode = Utility.otidToUid(_otid).hashCode();
- }
-
- private boolean same(otid_t otid1, otid_t otid2)
- {
- if ((otid1.formatID == otid2.formatID) &&
- (otid1.bqual_length == otid2.bqual_length))
- {
- for (int i = 0; i < otid1.bqual_length; i++)
- {
- if (otid1.tid[i] != otid2.tid[i])
- return false;
- }
-
- /*
- * Got here, so must be equal!
- */
-
- return true;
- }
- else
- return false;
- }
-
- public int hashCode()
- {
- return _hashCode;
- }
-
- public boolean equals(Object o)
- {
- if (o instanceof TransIdentityWrapper)
- {
- TransIdentityWrapper t = (TransIdentityWrapper) o;
-
- return _otid != null && t._otid != null && same(_otid, t._otid);
- }
-
- return false;
- }
-
- /**
- * The object implements the writeExternal method to save its contents
- * by calling the methods of DataOutput for its primitive values or
- * calling the writeObject method of ObjectOutput for objects, strings,
- * and arrays.
- *
- * @serialData Overriding methods should use this tag to describe
- * the data layout of this Externalizable object.
- * List the sequence of element types and, if possible,
- * relate the element to a public/protected field and/or
- * method of this Externalizable class.
- *
- * @param out the stream to write the object to
- * @exception IOException Includes any I/O exceptions that may occur
- */
-
- public void writeExternal(ObjectOutput out, boolean fullContext) throws IOException
- {
- out.writeObject(_coordinator);
- out.writeObject(getOtid());
-
- if (fullContext)
- {
- out.writeObject(_terminator);
- }
- }
-
- public void readExternal(ObjectInput in, boolean fullContext) throws IOException, ClassNotFoundException
- {
- _coordinator = (String) in.readObject();
- setOtid((otid_t) in.readObject());
-
- if (fullContext)
- {
- _terminator = (String) in.readObject();
- }
- else
- {
- _terminator = null;
- }
- }
- }
+/*
+ * 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, 2001, 2002, 2003
+ *
+ * Arjuna Technologies Ltd.
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: PropagationContextWrapper.java,v 1.5 2004/10/04 09:48:19 nmcl Exp $
+ */
+
+package com.arjuna.ats.internal.jbossatx.jts;
+
+import org.omg.CosTransactions.*;
+
+import java.io.*;
+
+import com.arjuna.ats.internal.jts.ORBManager;
+import com.arjuna.ats.jts.utils.Utility;
+
+/**
+ * This class is a wrapper around a PropagationContext object allowing it to be serialized.
+ *
+ * @author Richard A. Begg (richard.begg at arjuna.com)
+ * @version $Id: PropagationContextWrapper.java,v 1.5 2004/10/04 09:48:19 nmcl Exp $
+ */
+
+public class PropagationContextWrapper implements Externalizable
+{
+ private static boolean _propagateFullContext = false;
+
+ private boolean _isNull = true;
+ private int _timeout;
+ private TransIdentityWrapper _current;
+ private TransIdentityWrapper[] _parents = null;
+
+ private PropagationContext _tpc = null;
+
+ public static void setPropagateFullContext(boolean propagateFullContext)
+ {
+ _propagateFullContext = propagateFullContext;
+ }
+
+ public static boolean getPropagateFullContext()
+ {
+ return _propagateFullContext;
+ }
+
+ /**
+ * Default constructor required for serialization
+ */
+
+ public PropagationContextWrapper()
+ {
+ }
+
+ /**
+ * Create a wrapper around a propagation context class
+ * @param tpc
+ */
+
+ public PropagationContextWrapper(PropagationContext tpc)
+ {
+ this();
+
+ _isNull = (tpc == null);
+
+ if (tpc != null)
+ {
+ _current = new TransIdentityWrapper();
+
+ _current._coordinator = ORBManager.getORB().orb().object_to_string(tpc.current.coord);
+ _current.setOtid(tpc.current.otid);
+
+ _timeout = tpc.timeout;
+
+ if (_propagateFullContext)
+ {
+ _current._terminator = ORBManager.getORB().orb().object_to_string(tpc.current.term);
+
+ _parents = new TransIdentityWrapper[tpc.parents.length];
+
+ for (int count = 0; count < tpc.parents.length; count++)
+ {
+ _parents[count] = new TransIdentityWrapper();
+ _parents[count]._coordinator = ORBManager.getORB().orb().object_to_string(tpc.parents[count].coord);
+ _parents[count]._terminator = ORBManager.getORB().orb().object_to_string(tpc.parents[count].term);
+ _parents[count].setOtid(tpc.parents[count].otid);
+ }
+ }
+ }
+ }
+
+ public int hashCode()
+ {
+ return _isNull ? 0 : _current.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o instanceof PropagationContextWrapper)
+ {
+ PropagationContextWrapper comp = (PropagationContextWrapper) o;
+
+ if (!_isNull && !comp._isNull)
+ {
+ return (_current.equals(comp._current));
+ }
+ }
+
+ return false;
+ }
+
+ // this is called on the remote side
+
+ public PropagationContext getPropagationContext()
+ {
+ if (_isNull)
+ {
+ return null;
+ }
+
+ if (_tpc == null)
+ {
+ if (_propagateFullContext)
+ {
+ TransIdentity[] parents = new TransIdentity[_parents != null ? _parents.length : 0];
+
+ for (int count = 0; count < parents.length; count++)
+ {
+ parents[count] = _parents[count].getTransIdentity();
+ }
+
+ _tpc = new PropagationContext(_timeout,
+ _current.getTransIdentity(),
+ parents,
+ null);
+ }
+ else
+ {
+ _tpc = new PropagationContext(_timeout,
+ _current.getTransIdentity(),
+ new TransIdentity[0], // no parents, but not null
+ null);
+ }
+ }
+
+ return _tpc;
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ try
+ {
+ out.writeBoolean(_propagateFullContext);
+ out.writeBoolean(_isNull);
+
+ if (!_isNull)
+ {
+ out.writeInt(_timeout);
+ _current.writeExternal(out, _propagateFullContext);
+
+ if (_propagateFullContext)
+ {
+ out.writeInt(_parents.length);
+
+ for (int count = 0; count < _parents.length; count++)
+ {
+ _parents[count].writeExternal(out, _propagateFullContext);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioException = new IOException(e.toString());
+ ioException.initCause(e);
+ throw ioException;
+ }
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ try
+ {
+ boolean fullContext = in.readBoolean();
+
+ _isNull = in.readBoolean();
+
+ if (!_isNull)
+ {
+ _timeout = in.readInt();
+ _current = new TransIdentityWrapper();
+ _current.readExternal(in, fullContext);
+
+ if (fullContext)
+ {
+ _parents = new TransIdentityWrapper[in.readInt()];
+
+ for (int count = 0; count < _parents.length; count++)
+ {
+ _parents[count] = new TransIdentityWrapper();
+ _parents[count].readExternal(in, fullContext);
+ }
+ }
+ }
+
+ _tpc = null;
+ }
+ catch (Exception e)
+ {
+ IOException ioException = new IOException(e.toString());
+ ioException.initCause(e);
+ throw ioException;
+ }
+ }
+
+ /**
+ * A wrapper around a transidentity object so that it can be serialized.
+ */
+
+ private class TransIdentityWrapper implements Serializable
+ {
+ public String _coordinator = null;
+ private otid_t _otid = null;
+ public String _terminator = null;
+ private int _hashCode = 0;
+
+ public TransIdentity getTransIdentity()
+ {
+ return new TransIdentity(CoordinatorHelper.narrow(ORBManager.getORB().orb().string_to_object(_coordinator)),
+ _terminator == null ? null : TerminatorHelper.narrow(ORBManager.getORB().orb().string_to_object(_terminator)),
+ _otid);
+ }
+
+ public otid_t getOtid()
+ {
+ return _otid;
+ }
+
+ public void setOtid(otid_t o)
+ {
+ _otid = o;
+ _hashCode = Utility.otidToUid(_otid).hashCode();
+ }
+
+ private boolean same(otid_t otid1, otid_t otid2)
+ {
+ if ((otid1.formatID == otid2.formatID) &&
+ (otid1.bqual_length == otid2.bqual_length))
+ {
+ for (int i = 0; i < otid1.bqual_length; i++)
+ {
+ if (otid1.tid[i] != otid2.tid[i])
+ return false;
+ }
+
+ /*
+ * Got here, so must be equal!
+ */
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return _hashCode;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o instanceof TransIdentityWrapper)
+ {
+ TransIdentityWrapper t = (TransIdentityWrapper) o;
+
+ return _otid != null && t._otid != null && same(_otid, t._otid);
+ }
+
+ return false;
+ }
+
+ /**
+ * The object implements the writeExternal method to save its contents
+ * by calling the methods of DataOutput for its primitive values or
+ * calling the writeObject method of ObjectOutput for objects, strings,
+ * and arrays.
+ *
+ * @serialData Overriding methods should use this tag to describe
+ * the data layout of this Externalizable object.
+ * List the sequence of element types and, if possible,
+ * relate the element to a public/protected field and/or
+ * method of this Externalizable class.
+ *
+ * @param out the stream to write the object to
+ * @exception IOException Includes any I/O exceptions that may occur
+ */
+
+ public void writeExternal(ObjectOutput out, boolean fullContext) throws IOException
+ {
+ out.writeObject(_coordinator);
+ out.writeObject(getOtid());
+
+ if (fullContext)
+ {
+ out.writeObject(_terminator);
+ }
+ }
+
+ public void readExternal(ObjectInput in, boolean fullContext) throws IOException, ClassNotFoundException
+ {
+ _coordinator = (String) in.readObject();
+ setOtid((otid_t) in.readObject());
+
+ if (fullContext)
+ {
+ _terminator = (String) in.readObject();
+ }
+ else
+ {
+ _terminator = null;
+ }
+ }
+ }
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerDelegate.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerDelegate.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerDelegate.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -116,7 +116,10 @@
}
catch (final SystemException se)
{
- throw new RollbackException(jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate.getTimeLeftBeforeTransactionTimeout_2")) ;
+ RollbackException rollbackException = new RollbackException(
+ jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate.getTimeLeftBeforeTransactionTimeout_2")) ;
+ rollbackException.initCause(se);
+ throw rollbackException;
}
return -1 ;
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -60,7 +60,7 @@
catch(InvalidName e)
{
throw new RuntimeException("Could not register initial " +
- "reference for InboundTransactionCurrent implementation: " + e);
+ "reference for InboundTransactionCurrent implementation: " + e, e);
}
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerDelegate.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerDelegate.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerDelegate.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -112,7 +112,10 @@
}
catch (final SystemException se)
{
- throw new RollbackException(jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jts.TransactionManagerDelegate.getTimeLeftBeforeTransactionTimeout_2")) ;
+ RollbackException rollbackException = new RollbackException(
+ jbossatxLogger.logMesg.getString("com.arjuna.ats.jbossatx.jts.TransactionManagerDelegate.getTimeLeftBeforeTransactionTimeout_2")) ;
+ rollbackException.initCause(se);
+ throw rollbackException;
}
return -1 ;
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java 2009-05-08 09:41:28 UTC (rev 26428)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java 2009-05-08 10:12:55 UTC (rev 26429)
@@ -278,7 +278,7 @@
{
log.fatal("Problem encountered while trying to register transaction manager with ORB!");
- throw new Exception("Problem encountered while trying to register transaction manager with ORB! "+ex);
+ throw new Exception("Problem encountered while trying to register transaction manager with ORB! "+ex, ex);
}
More information about the jboss-svn-commits
mailing list