[jboss-svn-commits] JBL Code SVN: r25158 - in labs/jbosstm/trunk/XTS: sar and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Feb 9 08:11:42 EST 2009
Author: adinn
Date: 2009-02-09 08:11:42 -0500 (Mon, 09 Feb 2009)
New Revision: 25158
Added:
labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/
labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/at/
labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java
Modified:
labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java
labs/jbosstm/trunk/XTS/sar/build.xml
Log:
implemented WS-AT 1.1. BridgeWrapper class which exposes subordinate transaction management for JTA ==> AT bridge -- fixes JBTM-485
Modified: labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java 2009-02-09 12:57:04 UTC (rev 25157)
+++ labs/jbosstm/trunk/XTS/WSTX/classes11/com/arjuna/mwlabs/wst11/at/ContextFactoryImple.java 2009-02-09 13:11:42 UTC (rev 25158)
@@ -43,12 +43,10 @@
import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateCoordinator;
import com.arjuna.mwlabs.wst11.at.context.ArjunaContextImple;
import com.arjuna.mwlabs.wst11.at.participants.CleanupSynchronization;
-import com.arjuna.mwlabs.wst11.at.RegistrarImple;
import com.arjuna.webservices11.wsat.AtomicTransactionConstants;
import com.arjuna.webservices11.wsat.processors.ParticipantProcessor;
import com.arjuna.webservices11.wsarj.InstanceIdentifier;
import com.arjuna.webservices11.wscoor.CoordinationConstants;
-import com.arjuna.webservices11.wscoor.client.WSCOORClient;
import com.arjuna.webservices11.ServiceRegistry;
import com.arjuna.wsc11.ContextFactory;
import com.arjuna.wsc11.RegistrationCoordinator;
@@ -66,7 +64,6 @@
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
-import javax.xml.ws.addressing.EndpointReference;
import javax.xml.namespace.QName;
public class ContextFactoryImple implements ContextFactory, LocalFactory
@@ -271,6 +268,78 @@
return null;
}
+ /**
+ * class used to return data required to manage a bridged to subordinate transaction
+ */
+ public class BridgeTxData
+ {
+ public CoordinationContext context;
+ public SubordinateCoordinator coordinator;
+ public String identifier;
+ }
+
+ /**
+ * create a bridged to subordinate WS-AT 1.1 transaction, associate it with the registrar and create and return
+ * a coordination context for it. n.b. this is a private, behind-the-scenes method for use by the JTA-AT
+ * transaction bridge code.
+ * @param expires the timeout for the bridged to AT transaction
+ * @param isSecure true if the registration cooridnator URL should use a secure address, otherwise false.
+ * @return a coordination context for the bridged to transaction
+ */
+ public BridgeTxData createBridgedTransaction (final Long expires, final boolean isSecure)
+ {
+ // we need to create a subordinate transaction and register it as both a durable and volatile
+ // participant with the registration service defined in the current context
+
+ SubordinateCoordinator subTx = null;
+ try {
+ subTx = (SubordinateCoordinator) createSubordinate();
+ } catch (NoActivityException e) {
+ // will not happen
+ return null;
+ } catch (InvalidProtocolException e) {
+ // will not happen
+ return null;
+ } catch (SystemException e) {
+ // may happen
+ return null;
+ }
+
+ // ok now create the context
+
+ final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry() ;
+ final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure) ;
+
+ final CoordinationContext coordinationContext = new CoordinationContext() ;
+ coordinationContext.setCoordinationType(AtomicTransactionConstants.WSAT_PROTOCOL);
+ CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
+ String txId = subTx.get_uid().stringForm();
+ identifier.setValue("urn:" + txId);
+ coordinationContext.setIdentifier(identifier) ;
+ if (expires != null && expires.longValue() > 0)
+ {
+ Expires expiresInstance = new Expires();
+ expiresInstance.setValue(expires);
+ coordinationContext.setExpires(expiresInstance);
+ }
+ W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
+ coordinationContext.setRegistrationService(registrationCoordinator) ;
+
+ // now associate the tx id with the sub transaction
+
+ try {
+ _theRegistrar.associate(subTx);
+ } catch (Exception e) {
+ // will not happen
+ }
+ BridgeTxData bridgeTxData = new BridgeTxData();
+ bridgeTxData.context = coordinationContext;
+ bridgeTxData.coordinator = subTx;
+ bridgeTxData.identifier = txId;
+
+ return bridgeTxData;
+ }
+
private W3CEndpointReference getParticipant(final String id, final boolean isSecure)
{
final QName serviceName = AtomicTransactionConstants.PARTICIPANT_SERVICE_QNAME;
Modified: labs/jbosstm/trunk/XTS/sar/build.xml
===================================================================
--- labs/jbosstm/trunk/XTS/sar/build.xml 2009-02-09 12:57:04 UTC (rev 25157)
+++ labs/jbosstm/trunk/XTS/sar/build.xml 2009-02-09 13:11:42 UTC (rev 25158)
@@ -93,6 +93,8 @@
</path>
<property name="com.arjuna.buildsystem.classpath" refid="com.arjuna.buildsystem.classpath"/>
+ <property name="bridge.api.class.files" value="org/jboss/jbossts/xts/bridge/at/BridgeWrapper.class"/>
+
<target name="init">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
@@ -109,7 +111,7 @@
<target name="sar" depends="sar-11"/>
<target name="compile" depends="init">
- <javac srcdir="src" destdir="${build.classes.dir}" debug="${javac.debug}">
+ <javac srcdir="src" destdir="${build.classes.dir}" debug="${javac.debug}" excludes="org/jboss/jbossts/xts/bridge/**/*" >
<classpath>
<fileset dir="${jboss.client.lib.dir}" includes="${jboss.client.lib.jars}"/>
<pathelement location="${jbossas.home}/lib/jboss-system-jmx.jar"/>
@@ -119,6 +121,18 @@
</javac>
</target>
+ <!-- compile the 1.1 specific classes in the sar source which support WS-AT 1.1. bridging -->
+ <target name="compile11" depends="compile">
+ <javac srcdir="src" destdir="${build.classes.dir}" debug="${javac.debug}" includes="org/jboss/jbossts/xts/bridge/**/*" >
+ <classpath>
+ <fileset dir="${jboss.client.lib.dir}" includes="${jboss.client.lib.jars}"/>
+ <pathelement location="${jbossas.home}/lib/jboss-system-jmx.jar"/>
+ <fileset dir="${lib.dir}" includes="*.jar"/>
+ <fileset dir="${lib.dir}/ext" includes="jbossjta.jar jbossjts.jar jbossts-common.jar"/>
+ </classpath>
+ </javac>
+ </target>
+
<!-- build the messages resource bundle for use by the XTS logger -->
<target name="dev-resourcebundle">
<echo message="Generating XTS Bundle"/>
@@ -152,6 +166,10 @@
<unjar src="${lib.dir}/wstx-api.jar" dest="${build.dir}/tmp/api"/>
<unjar src="${lib.dir}/wstx10-api.jar" dest="${build.dir}/tmp/api"/>
<unjar src="${lib.dir}/wstx11-api.jar" dest="${build.dir}/tmp/api"/>
+ <!-- include bridge api class -->
+ <copy todir="${build.dir}/tmp/api">
+ <fileset dir="${build.classes.dir}" includes="${bridge.api.class.files}"/>
+ </copy>
<jar file="${build.dir}/jbossxts-api.jar" basedir="${build.dir}/tmp/api"/>
<copy file="${build.dir}/jbossxts-api.jar" tofile="${lib.dir}/jbossxts-api.jar"/>
<delete dir="${build.dir}/tmp/api"/>
@@ -164,6 +182,10 @@
<unjar src="${lib.dir}/ws-t11-api.jar" dest="${build.dir}/tmp/api"/>
<unjar src="${lib.dir}/wstx-api.jar" dest="${build.dir}/tmp/api"/>
<unjar src="${lib.dir}/wstx11-api.jar" dest="${build.dir}/tmp/api"/>
+ <!-- include bridge api class -->
+ <copy todir="${build.dir}/tmp/api">
+ <fileset dir="${build.classes.dir}" includes="${bridge.api.class.files}"/>
+ </copy>
<jar file="${build.dir}/jbossxts-api.jar" basedir="${build.dir}/tmp/api"/>
<copy file="${build.dir}/jbossxts-api.jar" tofile="${lib.dir}/jbossxts-api.jar"/>
<delete dir="${build.dir}/tmp/api"/>
@@ -182,7 +204,7 @@
</target>
<!-- build XTS service archive supporting both 1.0 and 1.1 WS-C/T protocols -->
- <target name="sar-both" depends="init, compile, dev-resourcebundle, api-both-jar">
+ <target name="sar-both" depends="init, compile11, compile, dev-resourcebundle, api-both-jar">
<!-- create config jar containing conf files for 1.0 and 1.1 -->
<filter token="coordinator.hostname" value="${coordinator.hostname}"/>
<filter token="coordinator.port" value="${coordinator.port}"/>
@@ -218,13 +240,13 @@
<!-- include web service config -->
<fileset dir="${build.dir}" includes="META-INF/application.xml"/>
- <!-- include sar boot and shutdown code -->
- <fileset dir="${build.classes.dir}" includes="**/*"/>
+ <!-- include sar boot and shutdown code and 1.1 bridge code *but* exclude the bridge API class -->
+ <fileset dir="${build.classes.dir}" includes="**/*" excludes="${bridge.api.class.files}"/>
</jar>
</target>
<!-- build XTS service archive supporting 1.1 WS-C/T protocols -->
- <target name="sar-11" depends="init, compile, dev-resourcebundle, api11-jar">
+ <target name="sar-11" depends="init, compile11, compile, dev-resourcebundle, api11-jar">
<!-- create config jar containing conf files for 1.1 -->
<filter token="coordinator.hostname" value="${coordinator.hostname}"/>
<filter token="coordinator.port" value="${coordinator.port}"/>
@@ -257,8 +279,8 @@
<!-- include web service config -->
<fileset dir="${build.dir}" includes="META-INF/application.xml"/>
- <!-- include sar boot and shutdown code -->
- <fileset dir="${build.classes.dir}" includes="**/*"/>
+ <!-- include sar boot and shutdown code and 1.1 bridge code *but* exclude the bridge API class -->
+ <fileset dir="${build.classes.dir}" includes="**/*" excludes="${bridge.api.class.files}"/>
</jar>
</target>
Added: labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java
===================================================================
--- labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java (rev 0)
+++ labs/jbosstm/trunk/XTS/sar/src/org/jboss/jbossts/xts/bridge/at/BridgeWrapper.java 2009-02-09 13:11:42 UTC (rev 25158)
@@ -0,0 +1,176 @@
+package org.jboss.jbossts.xts.bridge.at;
+
+import com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateCoordinator;
+import com.arjuna.mwlabs.wst11.at.ContextFactoryImple;
+import com.arjuna.mwlabs.wst11.at.context.TxContextImple;
+import com.arjuna.mw.wst.TxContext;
+import com.arjuna.mw.wst.exceptions.UnknownTransactionException;
+import com.arjuna.wsc11.ContextFactoryMapper;
+import com.arjuna.webservices11.wsat.AtomicTransactionConstants;
+import com.arjuna.wst.SystemException;
+import org.jboss.jbossts.xts.recovery.participant.at.XTSATRecoveryManager;
+
+/**
+ * An API class for use by the JTA ==> AT bridge manager providing a wrapper around a subordinate transaction.
+ * Static methods are provided to create and register a WS-AT subordinate transaction or to locate a recovered
+ * transaction. The returned wrapper allows a client to drive the coordinator through prepare, (phase 2) commit
+ * and/or rollback, to access the transaction id under which the coordinator is registered and, if the transaction
+ * has not been recovered, to obtain a resumable tx context for the transaction.
+ *
+ * n.b. this class only supports bridging to WS-AT 1.1 transactions.
+ */
+public class BridgeWrapper
+{
+ /**
+ * cached reference to the WS-AT 1.1. context factory - we only support bridging to WS-AT 1.1 subordinate
+ * transactions
+ */
+ private static ContextFactoryImple contextFactory =
+ (ContextFactoryImple)ContextFactoryMapper.getFactory().getContextFactory(AtomicTransactionConstants.WSAT_PROTOCOL);
+
+ /**
+ * this class handles all creation of bridged transactions
+ */
+
+ private BridgeWrapper()
+ {
+ }
+
+ /**
+ * create an AT 1.1 subordinate transaction, associate it with the AT 1.1. registry then return a
+ * BridgedTransaction wrapper allowing the transaction to be driven through prepare, commit
+ * and/or rollback and providing access to the transaction id and a context which can be used to
+ * resume the transaction.
+ * @param expires the timeout for the bridged-to transaction or 0 if no timeout is required
+ * @param isSecure true if AT 1.1. protocol messages for the bridged-to transaction should employ
+ * secure communications, otherwise false
+ * @return a wrapper for the bridged-to transaction
+ * @throws SystemException
+ */
+ public static BridgeWrapper create(long expires, boolean isSecure)
+ {
+ // the AT 1.1 context factory provides us with a means to create the required data.
+
+ ContextFactoryImple.BridgeTxData bridgeTxData = contextFactory.createBridgedTransaction(expires, isSecure);
+ if (bridgeTxData != null) {
+ BridgeWrapper bridgeWrapper = new BridgeWrapper();
+
+ bridgeWrapper.context = new TxContextImple(bridgeTxData.context);
+ bridgeWrapper.coordinator = bridgeTxData.coordinator;
+ bridgeWrapper.id = bridgeTxData.identifier;
+ return bridgeWrapper;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * recreate a wrapper for a bridged-to WS-AT 1.1 transaction recovered from the log
+ * @param identifier the identifier of a previously created bridged-to transaction
+ * @return a wrapper for the bridged-to transaction or null if it may still be awaiting recovery
+ * @throws UnknownTransactionException if recovery has been performed and no transaction with the
+ * given identifier has been foung in the log
+ */
+ public static BridgeWrapper recover(String identifier) throws UnknownTransactionException
+ {
+ SubordinateCoordinator coordinator = SubordinateCoordinator.getRecoveredCoordinator(identifier);
+ if (coordinator != null) {
+ BridgeWrapper bridgeWrapper = new BridgeWrapper();
+ bridgeWrapper.context = null;
+ bridgeWrapper.coordinator =coordinator;
+ bridgeWrapper.id = identifier;
+ return bridgeWrapper;
+ } else {
+ XTSATRecoveryManager recoveryManager = XTSATRecoveryManager.getRecoveryManager();
+ if (recoveryManager.isCoordinatorRecoveryStarted()) {
+ throw new UnknownTransactionException();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * obtain the identifier for the bridged-to transaction
+ * @return the identifier for the bridged-to transaction
+ */
+ public String getIdentifier()
+ {
+ return id;
+ }
+
+ /**
+ * obtain a resumable transaction context for the bridged-to transaction
+ * @return a resumable transaction context
+ * @throws UnknownTransactionException if this transaction has been recovered from the log and hence
+ * has no associated transaction context.
+ */
+ public TxContext getContext() throws UnknownTransactionException
+ {
+ if (context != null) {
+ return context;
+ } else {
+ throw new UnknownTransactionException();
+ }
+ }
+
+ /**
+ * initiate synchronization beforeCompletion processing for the bridged-to transaction
+ *
+ * @return true if the beforeCompletion succeeds otherwise false.
+ */
+ public boolean prepareVolatile()
+ {
+ return coordinator.prepareVolatile();
+ }
+
+ /**
+ * prepare the bridged-to transaction
+ * @return the result of preparing the transaction
+ */
+
+ public int prepare ()
+ {
+ return coordinator.prepare();
+ }
+
+
+ /**
+ * initiate synchronization afterCompletion processing for the bridged-to transaction following a
+ * successful commit
+ */
+ public void commitVolatile()
+ {
+ coordinator.commitVolatile();
+ }
+
+ /**
+ * perform a phase 2 commit for the bridged-to transaction
+ */
+
+ public void commit ()
+ {
+ coordinator.commit();
+ }
+
+ /**
+ * initiate synchronization afterCompletion processing for the bridged-to transaction following a
+ * rollback
+ */
+ public void rollbackVolatile()
+ {
+ coordinator.rollbackVolatile();
+ }
+
+ /**
+ * rollback the bridged-to transaction
+ */
+ public void rollback ()
+ {
+ coordinator.rollback();
+ }
+
+ private SubordinateCoordinator coordinator;
+ private TxContext context;
+ private String id;
+}
More information about the jboss-svn-commits
mailing list