[jboss-svn-commits] JBL Code SVN: r9906 - in labs/jbosstm/trunk: ArjunaJTA and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 2 07:15:24 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-03-02 07:15:23 -0500 (Fri, 02 Mar 2007)
New Revision: 9906
Added:
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceAllowedTestCase.java
labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceDisallowTestCase.java
labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/JTSTestCase.java
labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/
labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastOnePhaseResource.java
labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceAllowedTestCase.java
labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceDisallowTestCase.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/LastResourceRecord.java
labs/jbosstm/trunk/ArjunaJTA/build.xml
labs/jbosstm/trunk/ArjunaJTA/jta/build.xml
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/Environment.java
labs/jbosstm/trunk/ArjunaJTS/build.xml
labs/jbosstm/trunk/ArjunaJTS/jtax/build.xml
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/LastResourceRecord.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java
labs/jbosstm/trunk/common/build.xml
Log:
Added support for multiple last resources: JBTM-169
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/LastResourceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/LastResourceRecord.java 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/LastResourceRecord.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -188,10 +188,7 @@
public boolean shouldAdd (AbstractRecord a)
{
- if (a instanceof LastResourceRecord)
- return false;
- else
- return true;
+ return (a.typeIs() == typeIs()) ;
}
public boolean shouldMerge (AbstractRecord a)
@@ -245,5 +242,4 @@
private OnePhaseResource _lro;
private static final Uid ONE_PHASE_RESOURCE_UID = Uid.lastResourceUid() ;
-
}
Modified: labs/jbosstm/trunk/ArjunaJTA/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/build.xml 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTA/build.xml 2007-03-02 12:15:23 UTC (rev 9906)
@@ -275,7 +275,7 @@
</target>
<target name="com.hp.mwlabs.ts.product.jta.jar">
- <ant dir="jta" target="com.hp.mw.ts.jta.jar" />
+ <ant dir="jta" target="com.hp.mw.ts.jta.build" />
</target>
<target name="com.hp.mwlabs.ts.product.jdbc.jar">
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/build.xml 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/build.xml 2007-03-02 12:15:23 UTC (rev 9906)
@@ -47,8 +47,9 @@
location="build"/>
<property name="com.hp.mwlabs.ts.jta.builddir" location="${com.hp.mwlabs.ts.jta.buildroot}/classes/"/>
<property name="com.hp.mwlabs.ts.jta.dest" location="${com.hp.mwlabs.ts.jta.buildroot}/classes"/>
- <property name="com.hp.mwlabs.ts.jta.tests.src" location="tests"/>
+ <property name="com.hp.mwlabs.ts.jta.tests.src" location="tests/classes"/>
<property name="com.hp.mwlabs.ts.jta.tests.dest" location="${com.hp.mwlabs.ts.jta.buildroot}/tests"/>
+ <property name="com.hp.mwlabs.ts.jta.reports.dest" location="${com.hp.mwlabs.ts.jta.buildroot}/reports"/>
<property name="com.hp.mwlabs.ts.jta.jar.dest" location="lib"/>
<property name="com.hp.mwlabs.ts.jta.tests.destdir" location="${com.hp.mwlabs.ts.jta.jar.dest}/tests/"/>
@@ -189,8 +190,25 @@
</propertyfile>
</target>
- <target name="com.hp.mwlabs.ts.jta.tests.jar" depends="com.hp.mwlabs.ts.jta.tests.compile" if="com.hp.mwlabs.ts.jta.tests.compile">
+ <target name="com.hp.mwlabs.ts.jta.tests.run" depends="com.hp.mwlabs.ts.jta.tests.compile" if="com.hp.mwlabs.ts.jta.tests.compile">
+ <mkdir dir="${com.hp.mwlabs.ts.jta.reports.dest}"/>
+ <junit printsummary="yes">
+ <formatter type="plain"/>
+ <classpath>
+ <pathelement location="${com.hp.mwlabs.ts.jta.tests.dest}"/>
+ <path location="${com.hp.mwlabs.ts.jta.dest}"/>
+ <pathelement path="${build.classpath}"/>
+ <pathelement location="etc"/>
+ </classpath>
+ <batchtest haltonerror="yes" haltonfailure="yes" fork="yes"
+ todir="${com.hp.mwlabs.ts.jta.reports.dest}">
+ <fileset dir="${com.hp.mwlabs.ts.jta.tests.src}" includes="**/LastResource*TestCase.java"/>
+ </batchtest>
+ </junit>
+ </target>
+ <target name="com.hp.mwlabs.ts.jta.tests.jar" depends="com.hp.mwlabs.ts.jta.tests.run" if="com.hp.mwlabs.ts.jta.tests.compile">
+
<mkdir dir="${com.hp.mwlabs.ts.jta.tests.destdir}"/>
<jar basedir="${com.hp.mwlabs.ts.jta.tests.dest}"
jarfile="${com.hp.mwlabs.ts.jta.tests.destdir}/${com.hp.mwlabs.ts.modulename}_tests.jar"/>
@@ -299,19 +317,11 @@
</target>
<!-- Short target names -->
+ <target name="jar" depends="com.hp.mw.ts.jta.jar"/>
+ <target name="tests" depends="com.hp.mw.ts.jta.build"/>
+ <target name="install" depends="com.hp.mw.ts.jta.install"/>
+ <target name="clean" depends="com.hp.mw.ts.jta.clean"/>
- <target name="jar" depends="com.hp.mw.ts.jta.jar">
-
- </target>
-
- <target name="install" depends="com.hp.mw.ts.jta.install">
-
- </target>
-
- <target name="clean" depends="com.hp.mw.ts.jta.clean">
-
- </target>
-
<target name="com.hp.mwlabs.jta.generateresourcebundle">
<echo message="Generating JTA Resource Bundle"/>
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 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -84,6 +84,20 @@
* @message com.arjuna.ats.internal.jta.transaction.arjunacore.lastResourceOptimisationInterface
* [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResourceOptimisationInterface] - failed
* to load Last Resource Optimisation Interface
+ *
+ * @message com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning
+ * [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning]
+ * Multiple last resources have been added to the current transaction.
+ * This is transactionally unsafe and should not be relied upon.
+ * Current resource is {0}
+ * @message com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow
+ * [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow]
+ * Adding multiple last resources is disallowed.
+ * Current resource is {0}
+ * @message com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.startupWarning
+ * [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.startupWarning]
+ * You have chosen to enable multiple last resources in the transaction manager.
+ * This is transactionally unsafe and should not be relied upon.
*/
public class TransactionImple implements javax.transaction.Transaction,
@@ -776,17 +790,39 @@
*/
final AbstractRecord record ;
- if ((xaRes instanceof LastResourceCommitOptimisation) ||
- ((LAST_RESOURCE_OPTIMISATION_INTERFACE != null) && LAST_RESOURCE_OPTIMISATION_INTERFACE.isInstance(xaRes)))
+ if ((xaRes instanceof LastResourceCommitOptimisation) ||
+ ((LAST_RESOURCE_OPTIMISATION_INTERFACE != null) && LAST_RESOURCE_OPTIMISATION_INTERFACE.isInstance(xaRes)))
{
- record = new LastResourceRecord(new XAOnePhaseResource(xaRes, xid, params)) ;
+ if (lastResourceCount == 1)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ if (ALLOW_MULTIPLE_LAST_RESOURCES)
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning", new Object[] {xaRes});
+ }
+ else
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow", new Object[] {xaRes});
+ }
+ }
+ }
+
+ if ((lastResourceCount++ == 0) || ALLOW_MULTIPLE_LAST_RESOURCES)
+ {
+ record = new LastResourceRecord(new XAOnePhaseResource(xaRes, xid, params)) ;
+ }
+ else
+ {
+ record = null ;
+ }
}
else
{
- record = new XAResourceRecord(this, xaRes, xid, params);
+ record = new XAResourceRecord(this, xaRes, xid, params);
}
- if (_theTransaction.add(record) != AddOutcome.AR_ADDED)
+ if ((record == null) || (_theTransaction.add(record) != AddOutcome.AR_ADDED))
{
markRollbackOnly();
@@ -1591,7 +1627,17 @@
private int _suspendCount;
private final boolean _xaTransactionTimeoutEnabled;
private Map txLocalResources;
+
+ /**
+ * Count of last resources seen in this transaction.
+ */
+ private int lastResourceCount ;
+ /**
+ * Do we allow multiple last resources?
+ */
+ private static final boolean ALLOW_MULTIPLE_LAST_RESOURCES ;
+
private static final boolean XA_TRANSACTION_TIMEOUT_ENABLED ;
private static final Class LAST_RESOURCE_OPTIMISATION_INTERFACE ;
@@ -1624,6 +1670,13 @@
}
}
LAST_RESOURCE_OPTIMISATION_INTERFACE = lastResourceOptimisationInterface ;
+
+ final String allowMultipleLastResources = jtaPropertyManager.getPropertyManager().getProperty(Environment.ALLOW_MULTIPLE_LAST_RESOURCES) ;
+ ALLOW_MULTIPLE_LAST_RESOURCES = (allowMultipleLastResources == null ? false : Boolean.valueOf(allowMultipleLastResources).booleanValue()) ;
+ if (ALLOW_MULTIPLE_LAST_RESOURCES && jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.startupWarning");
+ }
}
private static Hashtable _transactions = new Hashtable();
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/Environment.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/Environment.java 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/Environment.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -60,6 +60,7 @@
public static final String XA_ERROR_HANDLER = "com.arjuna.ats.jta.xaErrorHandler";
public static final String XA_TRANSACTION_TIMEOUT_ENABLED = "com.arjuna.ats.jta.xaTransactionTimeoutEnabled";
public static final String LAST_RESOURCE_OPTIMISATION_INTERFACE = "com.arjuna.ats.jta.lastResourceOptimisationInterface";
+ public static final String ALLOW_MULTIPLE_LAST_RESOURCES = "com.arjuna.ats.jta.allowMultipleLastResources";
}
Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceAllowedTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceAllowedTestCase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceAllowedTestCase.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.lastresource;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import junit.framework.TestCase;
+
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+import com.arjuna.ats.jta.common.Environment;
+
+public class LastResourceAllowedTestCase extends TestCase
+{
+ protected void setUp() throws Exception
+ {
+ System.setProperty(Environment.ALLOW_MULTIPLE_LAST_RESOURCES, "true") ;
+ }
+
+ public void testAllowed()
+ throws SystemException, NotSupportedException, RollbackException
+ {
+ final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource thirdResource = new LastOnePhaseResource() ;
+
+ final TransactionManager tm = new TransactionManagerImple() ;
+ tm.begin() ;
+ try
+ {
+ final Transaction tx = tm.getTransaction() ;
+ assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
+ assertTrue("Second resource enlisted", tx.enlistResource(secondResource)) ;
+ assertTrue("Third resource enlisted", tx.enlistResource(thirdResource)) ;
+ }
+ finally
+ {
+ tm.rollback() ;
+ }
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceAllowedTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceDisallowTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceDisallowTestCase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceDisallowTestCase.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.lastresource;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import junit.framework.TestCase;
+
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+
+public class LastResourceDisallowTestCase extends TestCase
+{
+ public void testDisallowed()
+ throws SystemException, NotSupportedException, RollbackException
+ {
+ final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
+
+ final TransactionManager tm = new TransactionManagerImple() ;
+ tm.begin() ;
+ try
+ {
+ final Transaction tx = tm.getTransaction() ;
+ assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
+ assertFalse("Second resource enlisted", tx.enlistResource(secondResource)) ;
+ }
+ finally
+ {
+ tm.rollback() ;
+ }
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/lastresource/LastResourceDisallowTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbosstm/trunk/ArjunaJTS/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/build.xml 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTS/build.xml 2007-03-02 12:15:23 UTC (rev 9906)
@@ -375,7 +375,7 @@
</target>
<target name="com.hp.mwlabs.ts.product.jtax.jar">
- <ant dir="jtax" target="com.hp.mw.ts.jtax.jar" />
+ <ant dir="jtax" target="com.hp.mw.ts.jtax.build" />
</target>
<target name="com.hp.mwlabs.ts.product.tsmx.jar">
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/build.xml 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/build.xml 2007-03-02 12:15:23 UTC (rev 9906)
@@ -49,10 +49,11 @@
value="build"/>
<property name="com.hp.mwlabs.ts.jtax.builddir" location="${com.hp.mwlabs.ts.jtax.buildroot}/classes/"/>
<property name="com.hp.mwlabs.ts.jtax.dest" value="${com.hp.mwlabs.ts.jtax.buildroot}/classes"/>
- <property name="com.hp.mwlabs.ts.jtax.tests.src" location="tests"/>
- <property name="com.hp.mwlabs.ts.jtax.tests.idl" value="${com.hp.mwlabs.ts.jtax.tests.src}/idl"/>
+ <property name="com.hp.mwlabs.ts.jtax.tests.dir" location="tests"/>
+ <property name="com.hp.mwlabs.ts.jtax.tests.src" location="${com.hp.mwlabs.ts.jtax.tests.dir}/classes"/>
+ <property name="com.hp.mwlabs.ts.jtax.tests.idl" location="${com.hp.mwlabs.ts.jtax.tests.dir}/idl"/>
<property name="com.hp.mwlabs.ts.jtax.tests.dest" value="${com.hp.mwlabs.ts.jtax.buildroot}/tests"/>
- <property name="com.hp.mwlabs.ts.jta.tests.dest" value="../jta/build/tests"/>
+ <property name="com.hp.mwlabs.ts.jtax.reports.dest" value="${com.hp.mwlabs.ts.jtax.buildroot}/reports"/>
<property name="com.hp.mwlabs.ts.jtax.jar.dest" value="lib"/>
<property name="com.hp.mwlabs.ts.jtax.tests.destdir" value="${com.hp.mwlabs.ts.jtax.jar.dest}/tests/"/>
@@ -66,6 +67,11 @@
name="com.hp.mw.orbportability.orbspecific.hporb.classpath"
value="../lib/jts.jar:../../common/lib/common.jar:../../orbportability/lib/orbportability.jar:../../orbportability/lib/ext/orbportability-ant.jar:../../arjuna/lib/arjuna.jar:../../txoj/lib/txoj.jar"/>
+ <property name="com.hp.mwlabs.ts.jacorb.lib" location="../jacorb/lib"/>
+ <path id="com.hp.mwlabs.ts.jacorb.classpath">
+ <fileset dir="${com.hp.mwlabs.ts.jacorb.lib}" includes="*.jar"/>
+ </path>
+
<property name="com.hp.mwlabs.ts.jtax.resourcebundle"
value="jtax_msg_en_US.properties"/>
@@ -180,8 +186,25 @@
</target>
- <target name="com.hp.mwlabs.ts.jtax.tests.jar" depends="com.hp.mwlabs.ts.jtax.tests.compile" if="com.hp.mwlabs.ts.jtax.tests.compile">
+ <target name="com.hp.mwlabs.ts.jtax.tests.run" depends="com.hp.mwlabs.ts.jtax.tests.compile" if="com.hp.mwlabs.ts.jtax.tests.compile">
+ <mkdir dir="${com.hp.mwlabs.ts.jtax.reports.dest}"/>
+ <junit printsummary="yes">
+ <formatter type="plain"/>
+ <classpath>
+ <pathelement location="${com.hp.mwlabs.ts.jtax.tests.dest}"/>
+ <path location="${com.hp.mwlabs.ts.jtax.dest}"/>
+ <path refid="com.hp.mwlabs.ts.jacorb.classpath"/>
+ <pathelement path="${build.classpath}"/>
+ </classpath>
+ <batchtest haltonerror="yes" haltonfailure="yes" fork="yes"
+ todir="${com.hp.mwlabs.ts.jtax.reports.dest}">
+ <fileset dir="${com.hp.mwlabs.ts.jtax.tests.src}" includes="**/LastResource*TestCase.java"/>
+ </batchtest>
+ </junit>
+ </target>
+ <target name="com.hp.mwlabs.ts.jtax.tests.jar" depends="com.hp.mwlabs.ts.jtax.tests.run" if="com.hp.mwlabs.ts.jtax.tests.compile">
+
<mkdir dir="${com.hp.mwlabs.ts.jtax.tests.destdir}"/>
<jar basedir="${com.hp.mwlabs.ts.jtax.tests.dest}"
jarfile="${com.hp.mwlabs.ts.jtax.tests.destdir}/${com.hp.mwlabs.ts.modulename}_tests.jar"/>
@@ -217,7 +240,6 @@
<classpath>
<path path="${build.classpath}"/>
<path path="${com.hp.mwlabs.ts.jtax.dest}"/>
- <path path="${com.hp.mwlabs.ts.jta.tests.dest}"/>
</classpath>
</javac>
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/LastResourceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/LastResourceRecord.java 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/resources/jts/orbspecific/LastResourceRecord.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -41,6 +41,7 @@
import org.omg.CosTransactions.NotPrepared;
import org.omg.CosTransactions.Vote;
+import com.arjuna.ArjunaOTS.OTSAbstractRecord;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.RecordType;
import com.arjuna.ats.internal.jta.transaction.jts.TransactionImple;
@@ -126,4 +127,9 @@
{
return false;
}
+
+ public boolean shouldAdd(OTSAbstractRecord record) throws SystemException
+ {
+ return (record.type_id() == type_id()) ;
+ }
}
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 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/transaction/jts/TransactionImple.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -45,7 +45,6 @@
import org.omg.CosTransactions.*;
import com.arjuna.ats.arjuna.coordinator.BasicAction;
-import com.arjuna.ats.arjuna.coordinator.OnePhaseResource;
import com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator;
import com.arjuna.ats.jta.xa.*;
@@ -111,6 +110,20 @@
* @message com.arjuna.ats.internal.jta.transaction.jts.lastResourceOptimisationInterface
* [com.arjuna.ats.internal.jta.transaction.jts.lastResourceOptimisationInterface] - failed
* to load Last Resource Optimisation Interface
+ *
+ * @message com.arjuna.ats.internal.jta.transaction.jts.lastResource.multipleWarning
+ * [com.arjuna.ats.internal.jta.transaction.jts.lastResource.multipleWarning]
+ * Multiple last resources have been added to the current transaction.
+ * This is transactionally unsafe and should not be relied upon.
+ * Current resource is {0}
+ * @message com.arjuna.ats.internal.jta.transaction.jts.lastResource.disallow
+ * [com.arjuna.ats.internal.jta.transaction.jts.lastResource.disallow]
+ * Adding multiple last resources is disallowed.
+ * Current resource is {0}
+ * @message com.arjuna.ats.internal.jta.transaction.jts.lastResource.startupWarning
+ * [com.arjuna.ats.internal.jta.transaction.jts.lastResource.startupWarning]
+ * You have chosen to enable multiple last resources in the transaction manager.
+ * This is transactionally unsafe and should not be relied upon.
*/
public class TransactionImple implements javax.transaction.Transaction,
@@ -826,17 +839,40 @@
*/
final XAResourceRecord res ;
- if ((xaRes instanceof LastResourceCommitOptimisation) ||
- ((LAST_RESOURCE_OPTIMISATION_INTERFACE != null) && LAST_RESOURCE_OPTIMISATION_INTERFACE.isInstance(xaRes)))
- {
- res = new LastResourceRecord(this, xaRes, xid,
- params) ;
- }
- else
- {
- res = new XAResourceRecord(this, xaRes, xid,
- params);
- }
+ if ((xaRes instanceof LastResourceCommitOptimisation) ||
+ ((LAST_RESOURCE_OPTIMISATION_INTERFACE != null) && LAST_RESOURCE_OPTIMISATION_INTERFACE.isInstance(xaRes)))
+ {
+ if (lastResourceCount == 1)
+ {
+ if (jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ if (ALLOW_MULTIPLE_LAST_RESOURCES)
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.jts.lastResource.multipleWarning", new Object[] {xaRes});
+ }
+ else
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.jts.lastResource.disallow", new Object[] {xaRes});
+ }
+ }
+ }
+
+ if ((lastResourceCount++ == 0) || ALLOW_MULTIPLE_LAST_RESOURCES)
+ {
+ res = new LastResourceRecord(this, xaRes, xid,
+ params) ;
+ }
+ else
+ {
+ markRollbackOnly() ;
+ return false ;
+ }
+ }
+ else
+ {
+ res = new XAResourceRecord(this, xaRes, xid,
+ params);
+ }
RecoveryCoordinator recCoord = _theTransaction.registerResource(res.getResource());
@@ -849,8 +885,6 @@
}
catch (Exception e)
{
- e.printStackTrace();
-
/*
* Some exceptional condition arose and we probably could not enlist
* the resouce. So, for safety mark the transaction as rollback
@@ -1681,7 +1715,17 @@
private Hashtable _duplicateResources;
private int _suspendCount;
private final boolean _xaTransactionTimeoutEnabled ;
+
+ /**
+ * Count of last resources seen in this transaction.
+ */
+ private int lastResourceCount ;
+ /**
+ * Do we allow multiple last resources?
+ */
+ private static final boolean ALLOW_MULTIPLE_LAST_RESOURCES ;
+
private static final boolean XA_TRANSACTION_TIMEOUT_ENABLED ;
private static final Class LAST_RESOURCE_OPTIMISATION_INTERFACE ;
@@ -1714,6 +1758,13 @@
}
}
LAST_RESOURCE_OPTIMISATION_INTERFACE = lastResourceOptimisationInterface ;
+
+ final String allowMultipleLastResources = jtsPropertyManager.getPropertyManager().getProperty(Environment.ALLOW_MULTIPLE_LAST_RESOURCES) ;
+ ALLOW_MULTIPLE_LAST_RESOURCES = (allowMultipleLastResources == null ? false : Boolean.valueOf(allowMultipleLastResources).booleanValue()) ;
+ if (ALLOW_MULTIPLE_LAST_RESOURCES && jtaLogger.loggerI18N.isWarnEnabled())
+ {
+ jtaLogger.loggerI18N.warn("com.arjuna.ats.internal.jta.transaction.jts.lastResource.startupWarning");
+ }
}
private static Hashtable _transactions = new Hashtable();
Added: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/JTSTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/JTSTestCase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/JTSTestCase.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.jts;
+
+import junit.framework.TestCase;
+
+import com.arjuna.ats.internal.jts.ORBManager;
+import com.arjuna.orbportability.OA;
+import com.arjuna.orbportability.ORB;
+import com.arjuna.orbportability.RootOA;
+
+public class JTSTestCase extends TestCase
+{
+ private ORB orb ;
+ private RootOA oa ;
+
+ protected void setUp()
+ throws Exception
+ {
+ orb = ORB.getInstance("test");
+ oa = OA.getRootOA(orb);
+
+ orb.initORB(new String[0], null);
+ oa.initOA();
+
+ ORBManager.setORB(orb);
+ ORBManager.setPOA(oa);
+ }
+
+ protected void tearDown()
+ throws Exception
+ {
+ if (oa != null)
+ {
+ oa.destroy();
+ }
+ if (orb != null)
+ {
+ orb.shutdown();
+ }
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/JTSTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastOnePhaseResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastOnePhaseResource.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastOnePhaseResource.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.jts.lastresource;
+
+import java.io.Serializable;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.jta.resources.LastResourceCommitOptimisation;
+
+public class LastOnePhaseResource implements XAResource, Serializable, LastResourceCommitOptimisation
+{
+ private static final long serialVersionUID = -2677829642809706893L ;
+
+ public static final int INITIAL = 0 ;
+ public static final int COMMIT = 1 ;
+ public static final int ROLLBACK = 2 ;
+
+ private int status = INITIAL ;
+
+ public int prepare(final Xid xid)
+ throws XAException
+ {
+ throw new XAException("Prepare called on LastOnePhaseResource") ;
+ }
+
+ public void commit(final Xid xid, final boolean onePhaseCommit)
+ throws XAException
+ {
+ if (!onePhaseCommit)
+ {
+ throw new XAException("commit called with onePhaseCommit false") ;
+ }
+ status = COMMIT ;
+ }
+
+ public void rollback(final Xid xid)
+ throws XAException
+ {
+ status = ROLLBACK ;
+ }
+
+ public int getStatus()
+ {
+ return status ;
+ }
+
+ public boolean isSameRM(final XAResource xaResource)
+ throws XAException
+ {
+ return this.equals(xaResource) ;
+ }
+
+ public void start(final Xid xid, final int flags)
+ throws XAException
+ {
+ System.out.println("start called on LastOnePhaseResource for xid: " + xid + " with flags 0x" + Integer.toHexString(flags)) ;
+ }
+
+ public void end(final Xid xid, final int flags)
+ throws XAException
+ {
+ System.out.println("end called on LastOnePhaseResource for xid: " + xid + " with flags 0x" + Integer.toHexString(flags)) ;
+ }
+
+ public Xid[] recover(final int flags)
+ throws XAException
+ {
+ System.out.println("recover called on LastOnePhaseResource with flags 0x" + Integer.toHexString(flags)) ;
+ return null ;
+ }
+
+ public void forget(final Xid xid)
+ throws XAException
+ {
+ System.out.println("forget called on LastOnePhaseResource for xid: " + xid) ;
+ }
+
+ public boolean setTransactionTimeout(final int timeout)
+ throws XAException
+ {
+ // don't support it
+ return false ;
+ }
+
+ public int getTransactionTimeout()
+ throws XAException
+ {
+ return 60 ;
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastOnePhaseResource.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceAllowedTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceAllowedTestCase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceAllowedTestCase.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.jts.lastresource;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple;
+import com.arjuna.ats.jta.common.Environment;
+import com.hp.mwtests.ts.jta.jts.JTSTestCase;
+
+public class LastResourceAllowedTestCase extends JTSTestCase
+{
+ protected void setUp() throws Exception
+ {
+ System.setProperty(Environment.ALLOW_MULTIPLE_LAST_RESOURCES, "true") ;
+ super.setUp() ;
+ }
+
+ public void testAllowed()
+ throws SystemException, NotSupportedException, RollbackException
+ {
+ final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource thirdResource = new LastOnePhaseResource() ;
+
+ final TransactionManager tm = new TransactionManagerImple() ;
+ tm.begin() ;
+ try
+ {
+ final Transaction tx = tm.getTransaction() ;
+ assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
+ assertTrue("Second resource enlisted", tx.enlistResource(secondResource)) ;
+ assertTrue("Third resource enlisted", tx.enlistResource(thirdResource)) ;
+ }
+ finally
+ {
+ tm.rollback() ;
+ }
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceAllowedTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceDisallowTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceDisallowTestCase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceDisallowTestCase.java 2007-03-02 12:15:23 UTC (rev 9906)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.jta.jts.lastresource;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple;
+import com.hp.mwtests.ts.jta.jts.JTSTestCase;
+
+public class LastResourceDisallowTestCase extends JTSTestCase
+{
+ public void testDisallowed()
+ throws SystemException, NotSupportedException, RollbackException
+ {
+ final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
+ final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
+
+ final TransactionManager tm = new TransactionManagerImple() ;
+ tm.begin() ;
+ try
+ {
+ final Transaction tx = tm.getTransaction() ;
+ assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
+ assertFalse("Second resource enlisted", tx.enlistResource(secondResource)) ;
+ }
+ finally
+ {
+ tm.rollback() ;
+ }
+ }
+}
Property changes on: labs/jbosstm/trunk/ArjunaJTS/jtax/tests/classes/com/hp/mwtests/ts/jta/jts/lastresource/LastResourceDisallowTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbosstm/trunk/common/build.xml
===================================================================
--- labs/jbosstm/trunk/common/build.xml 2007-03-02 11:10:55 UTC (rev 9905)
+++ labs/jbosstm/trunk/common/build.xml 2007-03-02 12:15:23 UTC (rev 9906)
@@ -60,7 +60,7 @@
<property name="com.hp.mw.ts.common.tests.compile" value="yes"/>
- <property name="com.hp.mw.ts.common.tests.install" value="yes"/>
+ <property name="com.hp.mw.ts.common.tests.install" value="no"/>
<property name="com.hp.mw.ts.common.log4j.compile" value="yes"/>
<property name="com.hp.mw.ts.common.csf.compile" value="yes"/>
More information about the jboss-svn-commits
mailing list