[jboss-svn-commits] JBL Code SVN: r31708 - in labs/jbosstm/trunk: txbridge and 18 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Feb 17 05:51:56 EST 2010
Author: jhalliday
Date: 2010-02-17 05:51:55 -0500 (Wed, 17 Feb 2010)
New Revision: 31708
Added:
labs/jbosstm/trunk/txbridge/tests/
labs/jbosstm/trunk/txbridge/tests/build.xml
labs/jbosstm/trunk/txbridge/tests/dd/
labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-client.xml
labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-server.xml
labs/jbosstm/trunk/txbridge/tests/dd/jboss-beans.xml
labs/jbosstm/trunk/txbridge/tests/dd/scripts/
labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt
labs/jbosstm/trunk/txbridge/tests/dd/web.xml
labs/jbosstm/trunk/txbridge/tests/src/
labs/jbosstm/trunk/txbridge/tests/src/org/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestClient.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestService.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestService.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestServiceImpl.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestSynchronization.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResource.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecovered.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecoveryHelper.java
Modified:
labs/jbosstm/trunk/maven/pom-template.xml
labs/jbosstm/trunk/txbridge/build.xml
labs/jbosstm/trunk/txbridge/demo/build.xml
labs/jbosstm/trunk/txbridge/demo/dd/web.xml
labs/jbosstm/trunk/txbridge/demo/src/org/jboss/jbossts/txbridge/demo/client/Restaurant.java
labs/jbosstm/trunk/txbridge/demo/web/index.jsp
labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.odt
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeDurableParticipant.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeRecoveryManager.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeVolatileParticipant.java
Log:
Added initial structure for txbridge testsuite and other minor bridge updates. JBTM-44
Modified: labs/jbosstm/trunk/maven/pom-template.xml
===================================================================
--- labs/jbosstm/trunk/maven/pom-template.xml 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/maven/pom-template.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -379,6 +379,12 @@
<artifactId>jaxws-api</artifactId>
</dependency>
+ <!-- txbridge demo -->
+ <dependency>
+ <groupId>org.hibernate.java-persistence</groupId>
+ <artifactId>jpa-api</artifactId>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
Modified: labs/jbosstm/trunk/txbridge/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/build.xml 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/build.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -26,9 +26,6 @@
JBossTS Transaction Bridge
</description>
- <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/output/jboss-6.0.0-SNAPSHOT"/>
- <property name="jbossas.server" value="default"/>
-
<property name="jbossts.home" location=".."/>
<property name="src" location="src"/>
@@ -38,17 +35,16 @@
<fileset dir="${jbossts.home}/install/lib">
<include name="jbossjta.jar"/>
<include name="jbossjts.jar"/>
- <include name="ext/log4j-1.2.14.jar"/>
- <include name="ext/jta-1_1-classes.zip"/>
- <include name="ext/connector-api.jar"/>
</fileset>
- <fileset dir="${jbossts.home}/XTS/sar/build">
- <include name="jbossxts-api.jar"/>
+ <fileset dir="../build/extlib">
+ <include name="log4j.jar"/>
+ <include name="jta.jar"/>
+ <include name="jboss-jca-api.jar"/>
</fileset>
- <fileset dir="${jbossas.home}/common/lib">
- <include name="jbossws-native-jaxws.jar"/>
+ <fileset dir="${jbossts.home}/XTS/xts-install/lib">
+ <include name="jbossxts-api.jar"/>
</fileset>
</path>
@@ -64,7 +60,7 @@
<target name="compile" depends="init"
description="compile the source ">
<mkdir dir="${build}/classes"/>
- <javac srcdir="${src}" destdir="${build}/classes" debug="true">
+ <javac srcdir="${src}" destdir="${build}/classes" debug="true" includeantruntime="false">
<classpath refid="build-prereqs"/>
</javac>
</target>
@@ -81,15 +77,18 @@
</jar>
</target>
- <target name="deploy" depends="dist" description="deploy to JBossAS">
- <copy file="${build}/txbridge.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy/"/>
- </target>
-
<!-- ##################################################################################### -->
<!-- the following targets are utility functions for the JBossTS dev team.
You probably don't need to worry about them. -->
+ <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT"/>
+ <property name="jbossas.server" value="default"/>
+
+ <target name="deploy" depends="dist" description="deploy to JBossAS">
+ <copy file="${build}/txbridge.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy/"/>
+ </target>
+
<target name="install-jts">
<copy todir="${jbossas.home}/common/lib">
<fileset dir="${jbossts.home}/install/lib" includes="*.jar"/>
Modified: labs/jbosstm/trunk/txbridge/demo/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/demo/build.xml 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/demo/build.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -26,8 +26,7 @@
JBossTS Transaction Bridge Demo App
</description>
- <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/output/jboss-6.0.0-SNAPSHOT"/>
- <property name="jbossas.server" value="default"/>
+ <property name="jbossts.home" location="../.."/>
<property name="src" location="src"/>
<property name="dd" location="dd"/>
@@ -35,21 +34,19 @@
<property name="build" location="build"/>
<path id="build-prereqs">
- <fileset dir="${jbossas.home}/common/lib">
- <include name="jboss-javaee.jar"/>
- <include name="ejb3-persistence.jar"/>
+ <fileset dir="../../build/extlib">
<include name="servlet-api.jar"/>
- <include name="jbossws-native-jaxws.jar"/>
- <include name="log4j.jar"/>
+ <include name="log4j.jar"/>
+ <include name="jta.jar"/>
+ <include name="jpa-api.jar"/>
+ <include name="jboss-ejb-api.jar"/>
+ </fileset>
- <include name="jbossjts.jar"/>
- </fileset>
-
- <fileset dir="${jbossas.home}/server/${jbossas.server}/deploy/jbossxts.sar">
+ <fileset dir="${jbossts.home}/XTS/xts-install/lib">
<include name="jbossxts-api.jar"/>
</fileset>
- <!-- TODO get from deployed loc instead -->
+ <!-- TODO get from deployed location instead? -->
<fileset dir="../build/">
<include name="txbridge.jar"/>
</fileset>
@@ -68,7 +65,7 @@
<target name="compile" depends="init"
description="compile the source ">
<mkdir dir="${build}/classes"/>
- <javac srcdir="${src}" destdir="${build}/classes" debug="true">
+ <javac srcdir="${src}" destdir="${build}/classes" debug="true" includeantruntime="false">
<classpath refid="build-prereqs"/>
</javac>
</target>
@@ -95,6 +92,11 @@
</target>
+ <!-- ##################################################################################### -->
+
+ <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT"/>
+ <property name="jbossas.server" value="default"/>
+
<target name="deploy-service" depends="dist" description="deploy EJB to JBossAS">
<copy file="${build}/txbridge-demo-service.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy"/>
</target>
Modified: labs/jbosstm/trunk/txbridge/demo/dd/web.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/demo/dd/web.xml 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/demo/dd/web.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -30,7 +30,6 @@
<servlet>
<servlet-name>Basic Client Servlet</servlet-name>
<servlet-class>org.jboss.jbossts.txbridge.demo.client.BasicClient</servlet-class>
- <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
Modified: labs/jbosstm/trunk/txbridge/demo/src/org/jboss/jbossts/txbridge/demo/client/Restaurant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/demo/src/org/jboss/jbossts/txbridge/demo/client/Restaurant.java 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/demo/src/org/jboss/jbossts/txbridge/demo/client/Restaurant.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * (C) 2007, 2009 @author JBoss Inc
+ */
package org.jboss.jbossts.txbridge.demo.client;
import javax.jws.WebService;
Modified: labs/jbosstm/trunk/txbridge/demo/web/index.jsp
===================================================================
--- labs/jbosstm/trunk/txbridge/demo/web/index.jsp 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/demo/web/index.jsp 2010-02-17 10:51:55 UTC (rev 31708)
@@ -62,6 +62,8 @@
<option value="AtomicTransaction">WS-AT</option>
<option value="JTA">JTA (requires XTS demo services)</option>
</select>
+ <br/>WS-AT parent to JTA subordinate is Inbound Bridging.
+ <br/>JTA parent to WS-AT subordinate is Outbound Bridging.
</p>
<p>
Modified: labs/jbosstm/trunk/txbridge/docs/TransactionBridgingGuide.odt
===================================================================
(Binary files differ)
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeDurableParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeDurableParticipant.java 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeDurableParticipant.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -61,7 +61,7 @@
static final long serialVersionUID = -5739871936627778072L;
- // Xid not guarateed Serializable by spec, but our XidImple happens to be
+ // Xid not guaranteed Serializable by spec, but our XidImple happens to be
private Xid xid;
// Id needed for recovery of the subordinate tx. Uids are likewise Serializable.
@@ -107,14 +107,16 @@
throw ioException;
}
- out.defaultWriteObject();
+ //out.defaultWriteObject();
+ out.writeObject(xid);
+ out.writeObject(subordinateTransactionId);
}
/**
* Deserialization hook. Unpacks transaction recovery information and uses it to
* recover the subordinate transaction.
*
- * @param in the strean from which to unpack the object state.
+ * @param in the stream from which to unpack the object state.
* @throws IOException if deserialzation and recovery fail.
* @throws ClassNotFoundException if deserialzation fails.
*/
@@ -122,7 +124,10 @@
{
log.trace("readObject()");
- in.defaultReadObject();
+ //in.defaultReadObject();
+ xid = (Xid)in.readObject();
+ subordinateTransactionId = (Uid)in.readObject();
+
xaTerminator = SubordinationManager.getXATerminator();
try
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeRecoveryManager.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeRecoveryManager.java 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeRecoveryManager.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -23,22 +23,33 @@
*/
package org.jboss.jbossts.txbridge;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryModule;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
import org.apache.log4j.Logger;
import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryModule;
import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
import com.arjuna.wst.Durable2PCParticipant;
+import javax.resource.spi.XATerminator;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
import java.io.ObjectInputStream;
/**
- * Integrates with JBossAS 5 MC lifecycle to provide recovery services.
+ * Integrates with JBossAS MC lifecycle to provide recovery services.
*
* @author jonathan.halliday at redhat.com, 2009-02-10
*/
-public class BridgeRecoveryManager implements XTSATRecoveryModule
+public class BridgeRecoveryManager implements XTSATRecoveryModule, RecoveryModule
{
private static Logger log = Logger.getLogger(BridgeRecoveryManager.class);
+ private final XTSATRecoveryManager xtsATRecoveryManager = XTSATRecoveryManager.getRecoveryManager();
+ private final RecoveryManager acRecoveryManager = RecoveryManager.manager();
+ private final XATerminator xaTerminator = SubordinationManager.getXATerminator();
+
/**
* MC lifecycle callback, used to register the recovery module with the transaction manager.
*/
@@ -46,7 +57,8 @@
{
log.info("BridgeRecoveryManager starting");
- XTSATRecoveryManager.getRecoveryManager().registerRecoveryModule(this);
+ xtsATRecoveryManager.registerRecoveryModule(this);
+ acRecoveryManager.addModule(this);
}
/**
@@ -56,7 +68,8 @@
{
log.info("BridgeRecoveryManager stopping");
- XTSATRecoveryManager.getRecoveryManager().unregisterRecoveryModule(this);
+ xtsATRecoveryManager.unregisterRecoveryModule(this);
+ acRecoveryManager.removeModule(this, false);
}
/**
@@ -66,11 +79,12 @@
* participant was originally saved using serialization.
*
* @param id the id used when the participant was created
- * @param objectInputStream a stream from which the application should deserialise the participant
+ * @param objectInputStream a stream from which the application should deserialize the participant
* if it recognises that the id belongs to the module's application
* @return the deserialized Participant object
* @throws Exception if an error occurs deserializing the durable participant
*/
+ @Override
public Durable2PCParticipant deserialize(String id, ObjectInputStream objectInputStream) throws Exception
{
log.trace("deserialize(id="+id+")");
@@ -89,8 +103,55 @@
/**
* Unused recovery callback. We use serialization instead, so this method will always throw an exception if called.
*/
+ @Override
public Durable2PCParticipant recreate(String s, byte[] bytes) throws Exception
{
throw new Exception("recreation not supported - should use deserialization instead.");
}
+
+ /**
+ * Called by the RecoveryManager at start up, and then
+ * PERIODIC_RECOVERY_PERIOD seconds after the completion, for all RecoveryModules,
+ * of the second pass
+ */
+ @Override
+ public void periodicWorkFirstPass()
+ {
+ log.trace("periodicWorkFirstPass()");
+
+ if(!xtsATRecoveryManager.isParticipantRecoveryStarted()) {
+ // can't do anything until XTS Participant recovery has run.
+ return;
+ }
+
+ Xid[] xids = null;
+ try {
+ xids = xaTerminator.recover(XAResource.TMSTARTRSCAN);
+ xaTerminator.recover(XAResource.TMENDRSCAN);
+
+ } catch(XAException e) {
+ log.error("Problem whilst scanning for in-doubt subordinate transactions", e);
+ }
+
+ if(xids == null) {
+ return;
+ }
+
+ for(Xid xid : xids) {
+ log.trace("in-doubt Xid: "+xid);
+ }
+
+ // TODO: finish me
+
+ }
+
+ /**
+ * Called by the RecoveryManager RECOVERY_BACKOFF_PERIOD seconds
+ * after the completion of the first pass
+ */
+ @Override
+ public void periodicWorkSecondPass()
+ {
+ log.trace("periodicWorkSecondPass()");
+ }
}
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeVolatileParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeVolatileParticipant.java 2010-02-17 10:20:39 UTC (rev 31707)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/BridgeVolatileParticipant.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -43,7 +43,7 @@
private static Logger log = Logger.getLogger(BridgeVolatileParticipant.class);
// no standard interface for driving Synchronization phases separately
- // in JCA, so we have to use proprietry API.
+ // in JCA, so we have to use proprietary API.
private XATerminatorExtensions xaTerminatorExtensions;
private String externalTxId;
@@ -80,7 +80,7 @@
// hard to invoke afterCompletion on the subordinate. So we cheat a bit by using setRollbackOnly instead.
// A slightly more efficient but less clear impl would be to have the same object implement both the Volatile
// and Durable Participants and keep count of the number of prepare/rollback invocations to know
- // if being invoked as Volatile or Dirable.
+ // if being invoked as Volatile or Durable.
// TODO InboundBridgeManager.getInboundBridge() would be better,
Added: labs/jbosstm/trunk/txbridge/tests/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/build.xml (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/build.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010
+ * @author JBoss, by Red Hat.
+-->
+
+<project name="TxBridgeTests" default="dist" basedir=".">
+ <description>
+ JBossTS Transaction Bridge Test Suite
+ </description>
+
+ <property name="jbossts.home" location="../.."/>
+
+ <property name="src" location="src"/>
+ <property name="dd" location="dd"/>
+ <property name="build" location="build"/>
+
+ <path id="build-prereqs">
+ <fileset dir="../../build/extlib">
+ <include name="servlet-api.jar"/>
+ <include name="log4j.jar"/>
+ <include name="jta.jar"/>
+ <include name="jpa-api.jar"/>
+ <include name="jboss-ejb-api.jar"/>
+ <include name="junit.jar"/>
+ </fileset>
+
+ <fileset dir="${jbossts.home}/install/lib">
+ <include name="jbossjta.jar"/>
+ <include name="jbossjts.jar"/>
+ </fileset>
+
+ <fileset dir="${jbossts.home}/XTS/xts-install/lib">
+ <include name="jbossxts-api.jar"/>
+ </fileset>
+
+ </path>
+
+ <target name="clean" description="clean up">
+ <delete dir="${build}"/>
+ </target>
+
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init"
+ description="compile the source ">
+ <mkdir dir="${build}/classes"/>
+ <javac srcdir="${src}" destdir="${build}/classes" debug="true" includeantruntime="false">
+ <classpath refid="build-prereqs"/>
+ </javac>
+ </target>
+
+ <target name="run" depends="compile">
+ <java classname="org.jboss.jbossts.txbridge.tests.Scratch" fork="true">
+ <classpath>
+ <pathelement location="${build}/classes"/>
+ <path refid="build-prereqs"/>
+ </classpath>
+
+ <jvmarg value="-Xdebug" />
+ <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
+
+ </java>
+ </target>
+
+ <target name="dist" depends="compile"
+ description="generate the distribution">
+
+ <copy file="${dd}/jaxws-handlers-server.xml"
+ todir="${build}/classes/org/jboss/jbossts/txbridge/tests/service"/>
+
+ <jar destfile="${build}/txbridge-tests-service.jar">
+ <fileset dir="${build}/classes">
+ <include name="org/jboss/jbossts/txbridge/tests/service/*"/>
+ <include name="org/jboss/jbossts/txbridge/tests/utility/*"/>
+ </fileset>
+ <metainf dir="dd">
+ <include name="jboss-beans.xml"/>
+ </metainf>
+ </jar>
+
+ <copy file="${dd}/jaxws-handlers-client.xml"
+ todir="${build}/classes/org/jboss/jbossts/txbridge/tests/client"/>
+
+ <war warfile="${build}/txbridge-tests-client.war" webxml="${dd}/web.xml">
+ <classes dir="${build}/classes">
+ <include name="org/jboss/jbossts/txbridge/tests/client/*"/>
+ </classes>
+ </war>
+
+ </target>
+
+ <!-- ##################################################################################### -->
+
+ <property name="jbossas.home" location="/home/jhalli/IdeaProjects/jboss/jbossas_trunk/build/target/jboss-6.0.0-SNAPSHOT"/>
+ <property name="jbossas.server" value="default"/>
+
+ <target name="deploy-service" depends="dist" description="deploy EJB to JBossAS">
+ <copy file="${build}/txbridge-tests-service.jar" todir="${jbossas.home}/server/${jbossas.server}/deploy"/>
+ </target>
+
+ <target name="deploy-client" depends="dist" description="deploy Servlet to JBossAS">
+ <copy file="${build}/txbridge-tests-client.war" todir="${jbossas.home}/server/${jbossas.server}/deploy"/>
+ </target>
+
+</project>
+
Added: labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-client.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-client.xml (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-client.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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) 2007, 2009
+ * @author JBoss Inc.
+-->
+
+<!-- Client side config file for outbound bridging -->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+
+ <!-- JSR 181 does not seem to directly define how the handler chain is constructed from this xml,
+ although JSR 109 6.2.2.3 seems to indicate the parser is required to maintain the declared ordering.
+
+ Since we need the OutboundBridgeHandler to be invoked before the HeaderContextProcessor,
+ we list them in that order -->
+
+ <handler>
+ <handler-name>TransactionBridgeHandler</handler-name>
+ <handler-class>org.jboss.jbossts.txbridge.JaxWSTxOutboundBridgeHandler</handler-class>
+ </handler>
+
+ <handler>
+ <handler-name>WebServicesTxContextHandler</handler-name>
+ <handler-class>com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor</handler-class>
+ </handler>
+
+ </handler-chain>
+</handler-chains>
Added: labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-server.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-server.xml (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/dd/jaxws-handlers-server.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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) 2007, 2009
+ * @author JBoss Inc.
+-->
+
+<!-- Server side config file for inbound bridging -->
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+
+ <!-- JSR 181 does not seem to directly define how the handler chain is constructed from this xml,
+ although JSR 109 6.2.2.3 seems to indicate the parser is required to maintain the declared ordering.
+ JSR 224 9.3.2 says the constructed chain is then invoked in reverse order for inbound requests.
+ Since we need the HeaderContextProcessor to be invoked before the InboundBridgeHandler,
+ we therefore list the InboundBridgeHandler first -->
+
+ <handler>
+ <handler-name>TransactionBridgeHandler</handler-name>
+ <handler-class>org.jboss.jbossts.txbridge.JaxWSTxInboundBridgeHandler</handler-class>
+ </handler>
+
+ <handler>
+ <handler-name>WebServicesTxContextHandler</handler-name>
+ <handler-class>com.arjuna.mw.wst11.service.JaxWSHeaderContextProcessor</handler-class>
+ </handler>
+
+ </handler-chain>
+</handler-chains>
Added: labs/jbosstm/trunk/txbridge/tests/dd/jboss-beans.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/jboss-beans.xml (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/dd/jboss-beans.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010
+ * @author JBoss, by Red Hat.
+-->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="TxBridgeTests" class="org.jboss.jbossts.txbridge.tests.utility.TestXAResourceRecoveryHelper">
+
+ <constructor factoryClass="org.jboss.jbossts.txbridge.tests.utility.TestXAResourceRecoveryHelper" factoryMethod="getInstance"/>
+
+ <depends>jboss.xts:service=XTSService</depends>
+
+ <depends>jboss:service=TransactionManager</depends>
+
+ </bean>
+
+</deployment>
\ No newline at end of file
Added: labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/dd/scripts/txbridge-byteman-rules.txt 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,7 @@
+RULE testrule
+CLASS ^XTSATRecoveryManager
+METHOD writeParticipantRecoveryRecord
+AT EXIT
+IF true
+DO killJVM()
+ENDRULE
Added: labs/jbosstm/trunk/txbridge/tests/dd/web.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/dd/web.xml (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/dd/web.xml 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,38 @@
+<!--
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010
+ * @author JBoss, by Red Hat.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <display-name>XML Transaction Bridge Test Client</display-name>
+
+ <description>XML Transaction Bridge Test Client</description>
+
+ <servlet>
+ <servlet-name>Test Client Servlet</servlet-name>
+ <servlet-class>org.jboss.jbossts.txbridge.tests.client.TestClient</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Test Client Servlet</servlet-name>
+ <url-pattern>/testclient</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestClient.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestClient.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestClient.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.client;
+
+import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
+import com.arjuna.wst.TransactionRolledBackException;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.handler.Handler;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Servlet which includes test methods for exercising the txbridge.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestClient extends HttpServlet
+{
+ private static Logger log = Logger.getLogger(TestClient.class);
+
+ private ServletContext context;
+ private TestService testService;
+
+ /**
+ * Initialise the servlet.
+ * @param config The servlet configuration.
+ */
+ public void init(final ServletConfig config)
+ throws ServletException
+ {
+ try
+ {
+ URL wsdlLocation = new URL("http://localhost:8080/txbridge-tests-service/TestServiceImpl?wsdl");
+ QName serviceName = new QName("http://service.tests.txbridge.jbossts.jboss.org/", "TestServiceImplService");
+
+ Service service = Service.create(wsdlLocation, serviceName);
+ testService = service.getPort(TestService.class);
+
+ // we could have used @HandlerChain but it's nice to show a bit of variety...
+ BindingProvider bindingProvider = (BindingProvider)testService;
+ List<Handler> handlers = new ArrayList<Handler>(1);
+ handlers.add(new JaxWSHeaderContextProcessor());
+ bindingProvider.getBinding().setHandlerChain(handlers);
+
+ context = config.getServletContext();
+ }
+ catch(Exception e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
+ {
+ String param = request.getParameter("param");
+
+ log.info("param: "+param);
+
+ try
+ {
+ com.arjuna.mw.wst11.UserTransaction ut = UserTransactionFactory.userTransaction();
+
+ log.info("starting the transaction...");
+
+ ut.begin();
+
+ log.info("transaction ID= " + ut.toString());
+
+ log.info("calling business Web Services...");
+
+ //////////////////////
+
+ testService.doStuff();
+
+ //////////////////////
+
+ log.info("calling commit on the transaction...");
+
+ ut.commit();
+ }
+ catch (final TransactionRolledBackException tre)
+ {
+ log.info("Transaction rolled back") ;
+ }
+ catch (Exception e)
+ {
+ log.info("problem: ", e);
+ }
+
+ PrintWriter out = response.getWriter();
+ out.println("done");
+ out.close();
+ }
+}
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestService.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/client/TestService.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.client;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * Interface for a web service used by txbridge test cases. Client side version.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at WebService
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+public interface TestService
+{
+ public void doStuff();
+}
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestService.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestService.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.service;
+
+/**
+ * Interface for a web service used by txbridge test cases. Service side version.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public interface TestService
+{
+ public void doStuff();
+}
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestServiceImpl.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestServiceImpl.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/service/TestServiceImpl.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.service;
+
+import org.apache.log4j.Logger;
+import org.jboss.jbossts.txbridge.tests.utility.TestXAResource;
+
+import javax.ejb.*;
+
+import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.transaction.TransactionManager;
+
+/**
+ * Implementation of a web service used by txbridge test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+ at Stateless
+ at Remote(TestService.class)
+ at WebService()
+ at SOAPBinding(style = SOAPBinding.Style.RPC)
+ at HandlerChain(file = "jaxws-handlers-server.xml") // relative path from the class file
+ at TransactionAttribute(TransactionAttributeType.MANDATORY) // default is REQUIRED
+public class TestServiceImpl implements TestService
+{
+ private static Logger log = Logger.getLogger(TestServiceImpl.class);
+
+ @Override
+ @WebMethod
+ public void doStuff()
+ {
+ log.trace("doStuff()");
+
+ TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+
+ try {
+ tm.getTransaction().enlistResource(new TestXAResource());
+ } catch(Exception e) {
+ log.error("could not enlist resource", e);
+ }
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestSynchronization.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestSynchronization.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestSynchronization.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.txbridge.tests.utility;
+
+import org.apache.log4j.Logger;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Implementation of Synchronization for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestSynchronization implements Synchronization
+{
+ private static Logger log = Logger.getLogger(TestSynchronization.class);
+
+ private boolean beforeCompletionDone = false;
+ private boolean afterCompletionDone = false;
+
+ public boolean isBeforeCompletionDone()
+ {
+ return beforeCompletionDone;
+ }
+
+ public boolean isAfterCompletionDone()
+ {
+ return afterCompletionDone;
+ }
+
+ public void beforeCompletion() {
+ if(beforeCompletionDone) {
+ log.trace("beforeCompletion called more than once");
+ throw new RuntimeException("beforeCompletion called more than once");
+ }
+
+ beforeCompletionDone = true;
+ log.trace("TestSynchronization.beforeCompletion()");
+ }
+
+ public void afterCompletion(int i) {
+ if(afterCompletionDone) {
+ log.trace("afterCompletion called more than once");
+ throw new RuntimeException("afterCompletion called more than once");
+ }
+
+ afterCompletionDone = true;
+ log.trace("TestSynchronization.afterCompletion("+i+")");
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResource.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResource.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResource.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.jbossts.txbridge.tests.utility;
+
+import org.apache.log4j.Logger;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+
+/**
+ * Implementation of XAResource for use in tx test cases.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResource implements XAResource
+{
+ private static Logger log = Logger.getLogger(TestXAResource.class);
+
+ private int txTimeout;
+
+ private Xid currentXid;
+
+ private int prepareReturnValue = XAResource.XA_OK;
+ private XAException commitException = null;
+
+ public int getPrepareReturnValue()
+ {
+ return prepareReturnValue;
+ }
+
+ public void setPrepareReturnValue(int prepareReturnValue)
+ {
+ this.prepareReturnValue = prepareReturnValue;
+ }
+
+ public XAException getCommitException()
+ {
+ return commitException;
+ }
+
+ public void setCommitException(XAException commitException)
+ {
+ this.commitException = commitException;
+ }
+
+ public void commit(Xid xid, boolean b) throws XAException
+ {
+ log.trace("TestXAResource.commit(Xid="+xid+", b="+b+")");
+ if(!xid.equals(currentXid)) {
+ log.trace("TestXAResource.commit - wrong Xid!");
+ }
+
+ if(commitException != null) {
+ throw commitException;
+ }
+
+ currentXid = null;
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ public void end(Xid xid, int i) throws XAException {
+ log.trace("TestXAResource.end(Xid="+xid+", b="+i+")");
+ }
+
+ public void forget(Xid xid) throws XAException {
+ log.trace("TestXAResource.forget(Xid="+xid+")");
+ if(!xid.equals(currentXid)) {
+ log.trace("TestXAResource.forget - wrong Xid!");
+ }
+ currentXid = null;
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ log.trace("TestXAResource.getTransactionTimeout() [returning "+txTimeout+"]");
+ return txTimeout;
+ }
+
+ public boolean isSameRM(XAResource xaResource) throws XAException {
+ log.trace("TestXAResource.isSameRM(xaResource="+xaResource+")");
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ log.trace("TestXAResource.prepare(Xid="+xid+") returning "+prepareReturnValue);
+ if(prepareReturnValue == XA_OK) {
+ TestXAResourceRecoveryHelper.getInstance().logPrepared(xid);
+ }
+ return prepareReturnValue;
+ }
+
+ public Xid[] recover(int i) throws XAException {
+ log.trace("TestXAResource.recover(i="+i+")");
+ return new Xid[0];
+ }
+
+ public void rollback(Xid xid) throws XAException {
+ log.trace("TestXAResource.rollback(Xid="+xid+")");
+ if(!xid.equals(currentXid)) {
+ log.trace("TestXAResource.rollback - wrong Xid!");
+ }
+ currentXid = null;
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ public boolean setTransactionTimeout(int i) throws XAException {
+ log.trace("TestXAResource.setTransactionTimeout(i="+i+")");
+ txTimeout= i;
+ return true;
+ }
+
+ public void start(Xid xid, int i) throws XAException {
+ log.trace("TestXAResource.start(Xid="+xid+", i="+i+")");
+ if(currentXid != null) {
+ log.trace("TestXAResource.start - wrong Xid!");
+ }
+ currentXid = xid;
+ }
+
+ public String toString() {
+ return new String("TestXAResourcee("+txTimeout+", "+currentXid+")");
+ }
+}
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecovered.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecovered.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecovered.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.utility;
+
+import org.apache.log4j.Logger;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * Implementation of XAResource for use in txbridge recovery tests.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResourceRecovered extends TestXAResource implements XAResource
+{
+ private static Logger log = Logger.getLogger(TestXAResourceRecovered.class);
+
+ @Override
+ public void rollback(Xid xid) throws XAException
+ {
+ log.trace("TestXAResourceRecovered.rollback(Xid="+xid+")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ @Override
+ public void commit(Xid xid, boolean b) throws XAException
+ {
+ log.trace("TestXAResourceRecovered.commit(Xid="+xid+", b="+b+")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+ @Override
+ public Xid[] recover(int i) throws XAException {
+ log.trace("TestXAResourceRecovered.recover(i="+i+")");
+
+ return TestXAResourceRecoveryHelper.getInstance().recover();
+ }
+
+ @Override
+ public void forget(Xid xid) throws XAException {
+ log.trace("TestXAResource.forget(Xid="+xid+")");
+
+ TestXAResourceRecoveryHelper.getInstance().removeLog(xid);
+ }
+
+}
Added: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecoveryHelper.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecoveryHelper.java (rev 0)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/utility/TestXAResourceRecoveryHelper.java 2010-02-17 10:51:55 UTC (rev 31708)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.jboss.jbossts.txbridge.tests.utility;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryModule;
+import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
+import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
+import org.apache.log4j.Logger;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import java.io.*;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ * Implementation of XAResourceRecoveryHelper for use in txbridge recovery tests.
+ * Provides persistence for TestXAResource via a file in the ObjectStore.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com) 2010-01
+ */
+public class TestXAResourceRecoveryHelper implements XAResourceRecoveryHelper
+{
+ private static Logger log = Logger.getLogger(TestXAResourceRecoveryHelper.class);
+
+ private static final TestXAResourceRecoveryHelper instance = new TestXAResourceRecoveryHelper();
+
+ private final Set<Xid> preparedXids = new HashSet<Xid>();
+
+ public static TestXAResourceRecoveryHelper getInstance()
+ {
+ return instance;
+ }
+
+ protected TestXAResourceRecoveryHelper() {}
+
+ /**
+ * MC lifecycle callback, used to register the recovery module with the transaction manager.
+ */
+ public void start()
+ {
+ log.info("TestXAResourceRecoveryHelper starting");
+
+ getRecoveryModule().addXAResourceRecoveryHelper(getInstance());
+
+ recoverFromDisk();
+ }
+
+ /**
+ * MC lifecycle callback, used to unregister the recovery module from the transaction manager.
+ */
+ public void stop()
+ {
+ log.info("TestXAResourceRecoveryHelper stopping");
+
+ getRecoveryModule().removeXAResourceRecoveryHelper(getInstance());
+ }
+
+ private XARecoveryModule getRecoveryModule()
+ {
+ for(RecoveryModule recoveryModule : ((Vector<RecoveryModule>) RecoveryManager.manager().getModules())) {
+ if(recoveryModule instanceof XARecoveryModule) {
+ return (XARecoveryModule)recoveryModule;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean initialise(String param) throws Exception
+ {
+ log.trace("initialise(param="+param+")");
+
+ return true;
+ }
+
+ @Override
+ public XAResource[] getXAResources() throws Exception
+ {
+ log.trace("getXAResources()");
+
+ XAResource values[] = new XAResource[1];
+ values[0] = new TestXAResourceRecovered();
+
+ return values;
+ }
+
+ ///////////////////////////
+
+ public void logPrepared(Xid xid) throws XAException
+ {
+ log.trace("logPrepared(xid="+xid+")");
+
+ synchronized (preparedXids) {
+ if(preparedXids.add(xid)) {
+ writeToDisk();
+ } else {
+ throw new XAException(XAException.XAER_PROTO);
+ }
+ }
+ }
+
+ public void removeLog(Xid xid) throws XAException
+ {
+ log.trace("removeLog(xid="+xid);
+
+ synchronized (preparedXids) {
+ if(preparedXids.remove(xid)) {
+ writeToDisk();
+ } else {
+ throw new XAException(XAException.XAER_NOTA);
+ }
+ }
+ }
+
+ public Xid[] recover()
+ {
+ log.trace("recover()");
+
+ return preparedXids.toArray(new Xid[preparedXids.size()]);
+ }
+
+
+ private void writeToDisk() {
+ File logFile = getLogFile();
+ log.trace("logging "+preparedXids.size()+" records to "+logFile.getAbsolutePath());
+
+ try {
+ FileOutputStream fos = new FileOutputStream(logFile);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ oos.writeObject(preparedXids);
+ oos.close();
+ fos.close();
+ } catch(IOException e) {
+ log.error(e);
+ }
+ }
+
+ private void recoverFromDisk() {
+ File logFile = getLogFile();
+ log.trace("recovering from "+logFile.getAbsolutePath());
+
+ if(!logFile.exists()) {
+ return;
+ }
+
+ try {
+ FileInputStream fis = new FileInputStream(logFile);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ Set<Xid> xids = (Set<Xid>)ois.readObject();
+ preparedXids.addAll(xids);
+ log.trace("Recovered "+xids+" Xids");
+ ois.close();
+ fis.close();
+ } catch(Exception e) {
+ log.error(e);
+ }
+
+ }
+
+ private File getLogFile() {
+ String parentDir = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
+ String childDir = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
+ File logDir = new File(parentDir, childDir);
+ File logFile = new File(logDir, "TestXAResource.ser");
+ return logFile;
+ }
+
+
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list