[jboss-cvs] JBossAS SVN: r65812 - in trunk/iiop: src/main/org/jboss/tm/iiop and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 3 17:43:21 EDT 2007
Author: reverbel
Date: 2007-10-03 17:43:20 -0400 (Wed, 03 Oct 2007)
New Revision: 65812
Removed:
trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionService.java
trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionServiceMBean.java
trunk/iiop/src/main/org/jboss/tm/iiop/OTSServant.java
trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransaction.java
trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransactionObjectFactory.java
trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrent.java
trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrentInitializer.java
trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSCoordinatorWrapper.java
trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSRecoveryCoordinatorWrapper.java
trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSResourceWrapper.java
trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSSynchronizationWrapper.java
trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/Util.java
Modified:
trunk/iiop/build.xml
trunk/iiop/pom.xml
trunk/iiop/src/main/org/jboss/tm/iiop/TxServerClientInterceptor.java
trunk/iiop/src/main/org/jboss/tm/iiop/TxServerInterceptor.java
Log:
Delete TM/OTS/DTM code, which now lives in a separate project (at http://xactor.sourceforge.net).
Modified: trunk/iiop/build.xml
===================================================================
--- trunk/iiop/build.xml 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/build.xml 2007-10-03 21:43:20 UTC (rev 65812)
@@ -104,7 +104,6 @@
<path refid="jboss.jbosssx.classpath"/>
<path refid="jboss.jboss.security.spi.classpath"/>
<path refid="jboss.security.int.classpath"/>
- <path refid="jboss.transaction.classpath"/>
</path>
<!-- ===== -->
Modified: trunk/iiop/pom.xml
===================================================================
--- trunk/iiop/pom.xml 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/pom.xml 2007-10-03 21:43:20 UTC (rev 65812)
@@ -141,10 +141,6 @@
<artifactId>jboss-as-naming</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-transaction</artifactId>
- </dependency>
- <dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</dependency>
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionService.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionService.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionService.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,206 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.iiop.CorbaNamingService;
-import org.jboss.iiop.CorbaORBService;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.tm.TMUtil;
-import org.jboss.tm.TxManager;
-import org.omg.CORBA.ORB;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosNaming.NamingContextPackage.CannotProceed;
-import org.omg.CosNaming.NamingContextPackage.InvalidName;
-import org.omg.CosNaming.NamingContextPackage.NotFound;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
-
-/**
- * Service MBean that provides the CORBA transaction service for JBoss.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class CorbaTransactionService
- extends ServiceMBeanSupport
- implements CorbaTransactionServiceMBean
-{
- // Constants -----------------------------------------------------
- public static String COSNAMING_NAME = "TransactionService";
- public static String COSNAMING_USERTX_NAME = "UserTransaction";
- public static String STR_TO_REMOTE_CONVERTER = "OtsStrToRemoteRefConverter";
-
- // Attributes ----------------------------------------------------
-
- /** The POA used by the CORBA transaction service. */
- private POA poa;
-
- /** The POA used by OTS <code>Resource>/code> instances. */
- private POA resourcePoa;
-
- // ServiceMBeanSupport overrides ---------------------------------
-
- protected void startService()
- throws Exception
- {
- Context jndiContext;
- ORB orb;
-
- try
- {
- jndiContext = new InitialContext();
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Cannot get intial JNDI context: " + e);
- }
- try
- {
- orb = (ORB)jndiContext.lookup("java:/" + CorbaORBService.ORB_NAME);
- }
- catch (NamingException e)
- {
- throw new RuntimeException("Cannot lookup java:/"
- + CorbaORBService.ORB_NAME + ": " + e);
- }
-
- // Get a POA for OTS objects that are not Resource instances
- poa = CorbaORBService.getOtsPoa();
-
- // Get another POA for OTS Resources, so that they can have their own
- // default servant. (The name clash between Terminator::rollback and
- // Resource::rollback disallows us to use a single default servant for
- // all OTS objects.)
- resourcePoa = CorbaORBService.getOtsResourcePoa();
-
- // Create the transaction service
- OTSServant theDefaultServant = new OTSServant(orb, poa, resourcePoa);
- poa.set_servant(theDefaultServant);
- resourcePoa.set_servant(theDefaultServant.getResourceServant());
-
- // Both OTS POAs should still be in the holding state at this point.
- // Activate them.
- poa.the_POAManager().activate();
- org.omg.CORBA.Object theTransactionFactory =
- poa.create_reference_with_id(OTSServant.theFactoryId(),
- TransactionFactoryExtHelper.id());
-
- // Register the transaction factory in the CORBA naming service
- NamingContextExt rootContext = null;
- try
- {
- // Obtain local (in-VM) CORBA naming context
- rootContext = NamingContextExtHelper.narrow((org.omg.CORBA.Object)
- jndiContext.lookup("java:/" + CorbaNamingService.NAMING_NAME));
- }
- catch (NamingException e)
- {
- throw new Exception("Cannot lookup java:/" +
- CorbaNamingService.NAMING_NAME + ":\n" + e);
- }
- try
- {
- // Register transaction factory in local CORBA naming context
- rootContext.rebind(rootContext.to_name(COSNAMING_NAME),
- theTransactionFactory);
- getLog().info("CORBA TransactionFactory started");
- getLog().debug("TransactionFactory: ["
- + orb.object_to_string(theTransactionFactory)
- + "]");
-
- // Register it also as "UserTransaction" to please user tx clients
- rootContext.rebind(rootContext.to_name(COSNAMING_USERTX_NAME),
- theTransactionFactory);
- }
- catch (Exception e)
- {
- getLog().error("Cannot bind transaction factory in CORBA naming service:", e);
- throw new Exception("Cannot bind transaction factory in CORBA naming service:\n"
- + e);
- }
-
- // Set the TxManager's OTSResourceFactory, OTSContextFactory
- // and OTSStringRemoteRefConverter
- TxManager tm = (TxManager)TMUtil.getTransactionManager();
- tm.setOTSResourceFactory(theDefaultServant);
- tm.setOTSContextFactory(theDefaultServant);
- tm.setOTSStringRemoteRefConverter(theDefaultServant);
-}
-
- protected void stopService()
- {
- try
- {
- // Put both OTS POAs in the holding state
- // (TODO: make sure JacORB's hold_requests bug gets fixed.)
- poa.the_POAManager().hold_requests(false);
-
- // Unset the TxManager's OTS ResourceFactory.
- TxManager tm = (TxManager)TMUtil.getTransactionManager();
- tm.setOTSResourceFactory(null);
-
- // Get local (in-VM) CORBA naming context
- Context jndiContext = new InitialContext();
- NamingContextExt rootContext =
- NamingContextExtHelper.narrow((org.omg.CORBA.Object)
- jndiContext.lookup("java:/"
- + CorbaNamingService.NAMING_NAME));
-
- // Unregister the transaction factory from the CORBA naming service
- try
- {
- NameComponent[] name = rootContext.to_name(COSNAMING_NAME);
- rootContext.unbind(name);
- }
- catch (InvalidName invalidName)
- {
- getLog().error("Cannot unregister transaction factory from CORBA naming service",
- invalidName);
- }
- catch (NotFound notFound)
- {
- getLog().error("Cannot unregister transaction factory from CORBA naming service",
- notFound);
- }
- catch (CannotProceed cannotProceed)
- {
- getLog().error("Cannot unregister transaction factory from CORBA naming service",
- cannotProceed);
- }
- }
- catch (NamingException namingException)
- {
- getLog().error("Unexpected error in JNDI lookup", namingException);
- }
- catch (AdapterInactive adapterInactive)
- {
- getLog().error("Unexpected error when stopping OTS POAs", adapterInactive);
- }
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionServiceMBean.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionServiceMBean.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/CorbaTransactionServiceMBean.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,34 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop;
-
-/**
- * Mbean interface for the JBoss CORBA transaction service.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public interface CorbaTransactionServiceMBean
- extends org.jboss.system.ServiceMBean
-{
-}
-
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/OTSServant.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/OTSServant.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/OTSServant.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,1696 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop;
-
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.omg.CORBA.BAD_INV_ORDER;
-import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.OBJECT_NOT_EXIST;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.TRANSIENT;
-import org.omg.CORBA.ORBPackage.InvalidName;
-import org.omg.CORBA.NO_PERMISSION;
-import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
-import org.omg.CORBA.UNKNOWN;
-import org.omg.CosTransactions.Control;
-import org.omg.CosTransactions.ControlHelper;
-import org.omg.CosTransactions.Coordinator;
-import org.omg.CosTransactions.CoordinatorHelper;
-import org.omg.CosTransactions.HeuristicCommit;
-import org.omg.CosTransactions.HeuristicHazard;
-import org.omg.CosTransactions.HeuristicMixed;
-import org.omg.CosTransactions.HeuristicRollback;
-import org.omg.CosTransactions.Inactive;
-import org.omg.CosTransactions.NotPrepared;
-import org.omg.CosTransactions.NotSubtransaction;
-import org.omg.CosTransactions.PropagationContext;
-import org.omg.CosTransactions.RecoveryCoordinator;
-import org.omg.CosTransactions.RecoveryCoordinatorHelper;
-import org.omg.CosTransactions.Resource;
-import org.omg.CosTransactions.ResourceHelper;
-import org.omg.CosTransactions.ResourcePOA;
-import org.omg.CosTransactions.Status;
-import org.omg.CosTransactions.SubtransactionAwareResource;
-import org.omg.CosTransactions.SubtransactionsUnavailable;
-import org.omg.CosTransactions.Synchronization;
-import org.omg.CosTransactions.SynchronizationUnavailable;
-import org.omg.CosTransactions.Terminator;
-import org.omg.CosTransactions.TerminatorHelper;
-import org.omg.CosTransactions.TransactionFactoryHelper;
-import org.omg.CosTransactions.TransIdentity;
-import org.omg.CosTransactions.Unavailable;
-import org.omg.CosTransactions.Vote;
-import org.omg.CosTransactions.otid_t;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.Servant;
-import org.omg.PortableServer.CurrentPackage.NoContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.tm.LocalId;
-import org.jboss.tm.OTSContextFactory;
-import org.jboss.tm.ResourceFactory;
-import org.jboss.tm.StringRemoteRefConverter;
-import org.jboss.tm.TransactionImpl;
-import org.jboss.tm.TMUtil;
-import org.jboss.tm.TxManager;
-import org.jboss.tm.XidImpl;
-import org.jboss.tm.iiop.wrapper.OTSCoordinatorWrapper;
-import org.jboss.tm.iiop.wrapper.OTSRecoveryCoordinatorWrapper;
-import org.jboss.tm.iiop.wrapper.OTSResourceWrapper;
-import org.jboss.tm.remoting.interfaces.HeuristicHazardException;
-import org.jboss.util.UnreachableStatementException;
-
-/**
- * CORBA servant for the JBoss Transaction Service.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class OTSServant
- extends TransactionServicePOA
- implements ResourceFactory,
- OTSContextFactory,
- StringRemoteRefConverter
-{
- // Constants ----------------------------------------------------
-
- private static final Logger log =
- Logger.getLogger(OTSServant.class);
-
- // The first byte of our CORBA oids tells the type of the object:
-
- /** Value in position 0 of the oid within a Control reference. */
- private static final byte CONTROL = 0x43;
-
- /** Value in position 0 of the oid within a Coordinator reference. */
- private static final byte COORDINATOR = 0x63;
-
- /** Value in position 0 of the oid within a TransactionFactory reference. */
- private static final byte TX_FACTORY = 0x46;
-
- /** Value in position 0 of the oid within a Terminator reference. */
- private static final byte TERMINATOR = 0x74;
-
- /** Value in position 0 of the oid within a RecoveryCoordinator reference. */
- private static final byte RECOVERY_COORDINATOR = 0x76;
-
- /** Value in position 0 of the oid within a Resource reference. */
- private static final byte RESOURCE = 0x72;
-
- // String arrays returned by _all_interfaces:
-
- /** Interface ids of Control and its superinterfaces. */
- private static final String[] controlInterfaceIds = {
- ControlHelper.id()
- };
-
- /** Interface ids of CoordinatorExt and its superinterfaces. */
- private static final String[] coordinatorInterfaceIds = {
- CoordinatorExtHelper.id(),
- CoordinatorHelper.id()
- };
-
- /** Interface ids of TransactionFactoryExt and its superinterfaces. */
- private static final String[] txFactoryInterfaceIds = {
- TransactionFactoryExtHelper.id(),
- TransactionFactoryHelper.id()
- };
-
- /** Interface ids of Terminator and its superinterfaces. */
- private static final String[] terminatorInterfaceIds = {
- TerminatorHelper.id()
- };
-
- /** Interface ids of RecoveryCoordinator and its superinterfaces. */
- private static final String[] recoveryCoordinatorInterfaceIds = {
- RecoveryCoordinatorHelper.id()
- };
-
- // Attributes ----------------------------------------------------
-
- private ORB orb;
- private POA poa;
- private POA resourcePoa;
- private ResourceImpl resourceServant;
- private org.omg.PortableServer.Current poaCurrent;
-
- // Package -------------------------------------------------------
-
- static byte[] theFactoryId() { return new byte[] { TX_FACTORY }; }
-
- // Constructor ---------------------------------------------------
-
- OTSServant(ORB orb, POA poa, POA resourcePoa)
- {
- this.orb = orb;
- this.poa = poa;
- this.resourcePoa = resourcePoa;
- this.resourceServant = new ResourceImpl();
-
- try
- {
- org.omg.CORBA.Object obj =
- orb.resolve_initial_references("POACurrent");
- poaCurrent = org.omg.PortableServer.CurrentHelper.narrow(obj);
- }
- catch (InvalidName e) // thrown by resolve_initial_references
- {
- log.warn("Call to resolve_initial_references failed: ", e);
- throw new RuntimeException(
- "Call to resolve_initial_references failed: ", e);
- }
- catch (BAD_PARAM e) // thrown by narrow
- {
- log.warn("Call to narrow failed: ", e);
- throw new RuntimeException("Call to narrow failed: ", e);
- }
- }
-
- // Attribute -----------------------------------------------------
-
- /**
- * Returns the default servant for OTS <code>Resource</code>s.
- */
- public Servant getResourceServant()
- {
- return resourceServant;
- }
-
- // org.omg.PortableServer.Servant override -----------------------
-
- public String[] _all_interfaces(POA poa, byte[] oid)
- {
- if (oid[0] == TX_FACTORY)
- return txFactoryInterfaceIds;
- else if (oid[0] == CONTROL)
- return controlInterfaceIds;
- else if (oid[0] == COORDINATOR)
- return coordinatorInterfaceIds;
- else if (oid[0] == TERMINATOR)
- return terminatorInterfaceIds;
- else if (oid[0] == RECOVERY_COORDINATOR)
- return recoveryCoordinatorInterfaceIds;
- else
- throw new BAD_PARAM("Unknown CORBA object id");
- }
-
- // TransactionFactoryExt operation -------------------------------
-
- public TransactionDesc create_transaction(int timeout)
- {
- log.trace("TransactionFactoryExt.create_transaction");
- checkInvocationTarget(TX_FACTORY);
- try
- {
- TransactionManager tm = TMUtil.getTransactionManager();
-
- // Set timeout value
- if (timeout != 0)
- tm.setTransactionTimeout(timeout);
-
- // Start tx
- tm.begin();
-
- // Suspend thread association
- // and get the xid and the local id the transaction
- TransactionImpl tx = (TransactionImpl)tm.suspend();
- XidImpl xid = tx.getXid();
- long localId = xid.getLocalIdValue();
-
- // Set up oid byte array to create CORBA reference to the Coordinator
- byte[] oid = new byte[9];
- oid[0] = COORDINATOR;
- LocalId.toByteArray(localId, oid, 1);
-
- // Create CORBA reference to the Coordinator
- Coordinator coord = CoordinatorHelper.narrow(
- poa.create_reference_with_id(oid, CoordinatorHelper.id()));
-
- // Reuse the oid array to create CORBA reference to the Terminnator
- oid[0] = TERMINATOR;
- Terminator term = TerminatorHelper.narrow(
- poa.create_reference_with_id(oid, TerminatorHelper.id()));
-
- // Create and initialize PropagationContext object
- PropagationContext pc = new PropagationContext();
- pc.current = createTransIdentity(xid, coord, term);
- pc.timeout = timeout;
- pc.parents = new TransIdentity[0];
- pc.implementation_specific_data = orb.create_any();
-
- // Create and initialize TransactionDesc object
- TransactionDesc td = new TransactionDesc();
- td.control = ControlHelper.narrow(
- poa.create_reference_with_id(oid, ControlHelper.id()));
- td.propagationContext = pc;
-
- // Return TransactionDesc
- return td;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
-
- }
- catch (NotSupportedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- BAD_INV_ORDER ex = new BAD_INV_ORDER();
- ex.initCause(e);
- throw ex;
- }
- }
-
- // CosTransactions::TransactionFactory operations ----------------
-
- public Control create(int timeout)
- {
- log.trace("TransactionFactory.create");
- checkInvocationTarget(TX_FACTORY);
- try
- {
- TransactionManager tm = TMUtil.getTransactionManager();
-
- // Set timeout value
- if (timeout != 0)
- tm.setTransactionTimeout(timeout);
-
- // Start tx
- tm.begin();
-
- // Suspend thread association
- // and get the xid and the local id the transaction
- TransactionImpl tx = (TransactionImpl)tm.suspend();
- XidImpl xid = tx.getXid();
- long localId = xid.getLocalIdValue();
-
- // Set up oid byte array to create CORBA reference to the Control
- byte[] oid = new byte[9];
- oid[0] = CONTROL;
- LocalId.toByteArray(localId, oid, 1);
-
- // Return CORBA reference to the control
- return ControlHelper.narrow(
- poa.create_reference_with_id(oid, ControlHelper.id()));
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- catch (NotSupportedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- BAD_INV_ORDER ex = new BAD_INV_ORDER();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public Control recreate(PropagationContext pc)
- {
- log.trace("TransactionFactory.recreate");
- checkInvocationTarget(TX_FACTORY);
-
- if (pc == null)
- throw new BAD_PARAM(
- "recreate: PropagationContext parameter cannot be null");
-
- // prune the branch qualifier part of the OTS tid
- byte[] globalId =
- new byte[pc.current.otid.tid.length - pc.current.otid.bqual_length];
- System.arraycopy(pc.current.otid.tid, 0, globalId, 0, globalId.length);
-
- // import the transaction
- TxManager tm = (TxManager) TMUtil.getTransactionManager();
- TransactionImpl tx =
- tm.importExternalTransaction(pc.current.otid.formatID,
- globalId,
- new OTSCoordinatorWrapper(pc.current.coord),
- pc.timeout * 1000);
-
- // Set up oid byte array to create CORBA reference to the Control
- byte[] oid = new byte[9];
- oid[0] = CONTROL;
- LocalId.toByteArray(tx.getLocalIdValue(), oid, 1);
-
- // Return CORBA reference to the control
- return ControlHelper.narrow(
- poa.create_reference_with_id(oid, ControlHelper.id()));
-
- }
-
- // CosTransactions::Control operations ---------------------------
-
- public Terminator get_terminator()
- throws Unavailable
- {
- byte[] oid = getTargetId();
- if (oid[0] != CONTROL)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Control.get_terminator, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx.isImported())
- throw new Unavailable("Terminator not available " +
- "for imported transactions");
- oid[0] = TERMINATOR;
- return TerminatorHelper.narrow(
- poa.create_reference_with_id(oid, TerminatorHelper.id()));
- }
-
- public Coordinator get_coordinator()
- throws Unavailable
- {
- byte[] oid = getTargetId();
-
- if (log.isTraceEnabled())
- {
- long localIdValue = LocalId.fromByteArray(oid, 1);
- log.trace("Control.get_coordinator, targetId=" +
- Long.toHexString(localIdValue));
- }
-
- if (oid[0] != CONTROL)
- throw new BAD_OPERATION();
- oid[0] = COORDINATOR;
- return CoordinatorHelper.narrow(
- poa.create_reference_with_id(oid, CoordinatorHelper.id()));
- }
-
- // CosTransactions::Terminator operations ------------------------
-
- public void commit(boolean reportHeuristics)
- throws HeuristicHazard, HeuristicMixed
- {
- byte[] oid = getTargetId();
- if (oid[0] != TERMINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Terminator.commit, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in commit: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.commit();
- }
- catch (RollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex = new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- if (reportHeuristics)
- {
- HeuristicMixed ex = new HeuristicMixed();
- ex.initCause(e);
- throw ex;
- }
- }
- catch (HeuristicRollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex = new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (SecurityException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- NO_PERMISSION ex = new NO_PERMISSION();
- ex.initCause(e);
- throw ex;
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- BAD_INV_ORDER ex = new BAD_INV_ORDER();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void rollback()
- {
- byte[] oid = getTargetId();
- if (oid[0] != TERMINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Terminator.rollback, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in rollback: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.rollback();
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- BAD_INV_ORDER ex = new BAD_INV_ORDER();
- ex.initCause(e);
- throw ex;
- }
- catch (SecurityException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- NO_PERMISSION ex = new NO_PERMISSION();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- // CoordinatorExt operation --------------------------------------
-
- public TransactionId get_transaction_id()
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("CoordinatorExt.get_transaction_id, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in get_transaction_id: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- Xid xid = tx.getXid();
- return new TransactionId(xid.getFormatId(),
- xid.getGlobalTransactionId());
- }
-
- // CosTransactions::Coordinator operations -----------------------
-
- public Status get_status()
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.get_status, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in get_status: transaction not found");
- // Not sure if here I should return StatusNoTransaction
- // instead of throwing OBJECT_NOT_EXIST... (Francisco)
- throw new OBJECT_NOT_EXIST("No transaction.");
- // return org.omg.CosTransactions.Status.StatusNoTransaction; // ?
- }
-
- int status;
-
- try
- {
- status = tx.getStatus();
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- return javaxToCosTransactions(status);
- }
-
- public Status get_parent_status()
- {
- // The target coordinator is associated with a top-level
- // transaction, because we do not support nested transactions.
- // Therefore get_parent_status() is equivalent to get_status().
- return get_status();
- }
-
- public Status get_top_level_status()
- {
- // The target coordinator is associated with a top-level
- // transaction, because we do not support nested transactions.
- // Therefore get_top_level_status() is equivalent to get_status().
- return get_status();
- }
-
- public boolean is_same_transaction(Coordinator other)
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.is_same_transaction, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in is_same_transaction: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- Xid xid = tx.getXid();
-
- try
- {
- CoordinatorExt otherExt = CoordinatorExtHelper.narrow(other);
- TransactionId otherId = otherExt.get_transaction_id();
- return compare(xid,
- otherId.formatId,
- otherId.globalId,
- otherId.globalId.length);
- }
- catch (BAD_PARAM e)
- {
- // narrow failed: foreign transaction case
- try
- {
- otid_t otherOtid = other.get_txcontext().current.otid;
- return compare(xid,
- otherOtid.formatID,
- otherOtid.tid,
- otherOtid.tid.length - otherOtid.bqual_length);
- }
- catch (Unavailable u)
- {
- if (log.isTraceEnabled())
- log.trace(
- "Foreign Coordinator do not support get_txcontext(): ", e);
- BAD_PARAM ex = new BAD_PARAM();
- ex.initCause(e);
- throw ex;
- }
- }
- }
-
- public boolean is_ancestor_transaction(Coordinator other)
- {
- // We do not support nested transactions. In this case
- // is_ancestor_transaction() is equivalent to is_same_transaction().
- return is_same_transaction(other);
- }
-
- public boolean is_descendant_transaction(Coordinator other)
- {
- // We do not support nested transactions. In this case
- // is_descendant_transaction() is equivalent to is_same_transaction().
- return is_same_transaction(other);
- }
-
- public boolean is_related_transaction(Coordinator other)
- {
- // We do not support nested transactions. In this case
- // is_descendant_transaction() is equivalent to is_same_transaction().
- return is_same_transaction(other);
- }
-
- public boolean is_top_level_transaction()
- {
- checkInvocationTarget(COORDINATOR);
- return true; // because we do not support nested transactions.
- }
-
- public int hash_transaction()
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.hash_transaction, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in is_same_transaction: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
- return tx.getGlobalId().hashCode();
- }
-
- public int hash_top_level_tran()
- {
- // We do not support nested transactions. In this case
- // hash_top_level_transaction() is equivalent to hash_transaction().
- return hash_transaction();
- }
-
- public RecoveryCoordinator register_resource(Resource r)
- throws Inactive
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.register_resource, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in register_resource: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.enlistRemoteResource(new OTSResourceWrapper(r));
- }
- catch (RollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex = new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- Inactive ex = new Inactive();
- ex.initCause(e);
- throw ex;
- }
-
- // Create and return a RecoveryCoordinator reference
- oid[0] = RECOVERY_COORDINATOR;
- return RecoveryCoordinatorHelper.narrow(
- poa.create_reference_with_id(oid,
- RecoveryCoordinatorHelper.id()));
- }
-
- public void register_synchronization(final Synchronization sync)
- throws SynchronizationUnavailable, Inactive
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.register_synchronization, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in register_synchronization: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.registerSynchronization(
- new javax.transaction.Synchronization()
- {
- public void beforeCompletion()
- {
- sync.before_completion();
- }
- public void afterCompletion(int status)
- {
- sync.after_completion(javaxToCosTransactions(status));
- }
- });
- }
- catch (RollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex = new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- Inactive ex = new Inactive();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void register_subtran_aware(SubtransactionAwareResource r)
- throws NotSubtransaction, Inactive
- {
- checkInvocationTarget(COORDINATOR);
- throw new NotSubtransaction("Nested transactions are not supported");
- }
-
- public void rollback_only()
- throws Inactive
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.rollback_only, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in rollback_only: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.setRollbackOnly();
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- Inactive ex = new Inactive();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public String get_transaction_name()
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.get_transaction_name, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- Transaction tx = TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in get_transaction_name: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
- return tx.toString();
- }
-
- public Control create_subtransaction()
- throws SubtransactionsUnavailable, Inactive
- {
- checkInvocationTarget(COORDINATOR);
- throw new SubtransactionsUnavailable(
- "Nested transactions are not supported");
- }
-
- public PropagationContext get_txcontext()
- throws Unavailable
- {
- byte[] oid = getTargetId();
- if (oid[0] != COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Coordinator.get_txcontext, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in get_txcontext: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
- Xid xid = tx.getXid();
-
- // Create CORBA reference to the Coordinator (the target of this call)
- Coordinator coord = CoordinatorHelper.narrow(
- poa.create_reference_with_id(oid, CoordinatorHelper.id()));
-
- // Create and initialize PropagationContext object
- PropagationContext pc = new PropagationContext();
- pc.current = createTransIdentity(xid, coord, null);
- try
- {
- pc.timeout =
- TMUtil.divideAndRoundUp(tx.getTimeLeftBeforeTimeout(true), 1000);
- }
- catch (RollbackException e)
- {
- throw new BAD_INV_ORDER("get_txcontext(), but the transaction is " +
- "not in the active state.");
- }
- pc.parents = new TransIdentity[0];
- pc.implementation_specific_data = orb.create_any();
-
- // Return PropagationContext
- return pc;
- }
-
- // CosTransactions::RecoveryCoordinator operation ----------------
-
- public Status replay_completion(final Resource r)
- throws NotPrepared
- {
- byte[] oid = getTargetId();
- if (oid[0] != RECOVERY_COORDINATOR)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("RecoveryCoordinator.replay_completion, targetId=" +
- Long.toHexString(localIdValue));
-
- TxManager tm = (TxManager) TMUtil.getTransactionManager();
- if (tm.isRecoveryPending())
- {
- if (log.isTraceEnabled())
- log.trace("RecoveryCoordinator.replay_completion called on" +
- " targetId=" + Long.toHexString(localIdValue) +
- " before recovery is complete.\n" +
- " Throwing TRANSIENT exception.");
-
- throw new TRANSIENT("Transaction manager not ready.");
- }
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
-
- if (tx == null)
- {
- log.trace("RuntimeException in replay_completion: " +
- "transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- int status = tx.replayCompletion(new OTSResourceWrapper(r));
-
- if (status == javax.transaction.Status.STATUS_MARKED_ROLLBACK ||
- status == javax.transaction.Status.STATUS_NO_TRANSACTION ||
- status == javax.transaction.Status.STATUS_ROLLEDBACK ||
- status == javax.transaction.Status.STATUS_ROLLING_BACK)
- {
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- try
- {
- r.rollback();
- }
- catch (Exception ignore)
- {
- // We can ignore this exception. If the resource
- // didn't get the rollback then it will eventually
- // call replay_completion again.
- if (log.isTraceEnabled())
- log.trace("Ignoring exception in resource rollback",
- ignore);
- }
- }
- };
- Thread t = new Thread(runnable, "resourceRollbackThread");
-
- t.start();
- }
- return javaxToCosTransactions(status);
- }
-
- // CosTransactions::Resource operations in inner class below -----
-
- /**
- * Default servant class for OTS <code>Resource</code> objects.
- * OTS <code>Resource</code>s cannot share a default servant with all other
- * OTS objects, because there is a name clash between
- * <code>Terminator::rollback</code> and <code>Resource::rollback</code>.
- */
- public class ResourceImpl
- extends ResourcePOA
- {
- public Vote prepare()
- throws HeuristicHazard, HeuristicMixed
- {
- byte[] oid = getTargetId();
- if (oid[0] != RESOURCE)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Resource.prepare, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in prepare: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- TransactionManager tm = TMUtil.getTransactionManager();
- try
- {
- tm.resume(tx);
- int vote = tx.prepare(null);
-
- if (vote == XAResource.XA_OK)
- return Vote.VoteCommit;
- else // (vote == XAResource.XA_RDONLY)
- return Vote.VoteReadOnly;
- }
- catch (RollbackException e)
- {
- return Vote.VoteRollback;
- }
- catch (HeuristicHazardException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicHazard ex = new HeuristicHazard();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicMixed ex = new HeuristicMixed();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicRollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- return Vote.VoteRollback;
- }
- catch (Exception e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- finally
- {
- try
- {
- tm.suspend();
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
- }
-
- public void rollback()
- throws HeuristicHazard, HeuristicMixed, HeuristicCommit
- {
- byte[] oid = getTargetId();
- if (oid[0] != RESOURCE)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Resource.rollback, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx = (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in rollback: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.rollbackBranch();
- }
- catch (HeuristicHazardException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicHazard ex = new HeuristicHazard();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicMixed ex = new HeuristicMixed();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicCommitException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicCommit ex = new HeuristicCommit();
- ex.initCause(e);
- throw ex;
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- BAD_INV_ORDER ex = new BAD_INV_ORDER();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void commit()
- throws NotPrepared, HeuristicHazard, HeuristicMixed, HeuristicRollback
- {
- byte[] oid = getTargetId();
- if (oid[0] != RESOURCE)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Resource.commit, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx =
- (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in commit: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.commit(false);
- }
- catch (IllegalStateException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- NotPrepared ex = new NotPrepared();
- ex.initCause(e);
- throw ex;
- }
- catch (RollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex =
- new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicHazardException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicHazard ex = new HeuristicHazard();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicMixed ex = new HeuristicMixed();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicRollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicRollback ex = new HeuristicRollback();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void commit_one_phase()
- throws HeuristicHazard
- {
- byte[] oid = getTargetId();
- if (oid[0] != RESOURCE)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Resource.commit_one_phase, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx =
- (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in commit: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- try
- {
- tx.commit(true);
- }
- catch (RollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- TRANSACTION_ROLLEDBACK ex =
- new TRANSACTION_ROLLEDBACK();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicHazardException e)
- {
- if (log.isTraceEnabled())
- log.trace("Exception: ", e);
- HeuristicHazard ex = new HeuristicHazard();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixedException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicRollbackException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- catch (SystemException e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: ", e);
- UNKNOWN ex = new UNKNOWN();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void forget()
- {
- byte[] oid = getTargetId();
- if (oid[0] != RESOURCE)
- throw new BAD_OPERATION();
-
- long localIdValue = LocalId.fromByteArray(oid, 1);
-
- if (log.isTraceEnabled())
- log.trace("Resource.forget, targetId=" +
- Long.toHexString(localIdValue));
-
- LocalId localId = new LocalId(localIdValue);
- TransactionImpl tx =
- (TransactionImpl)TMUtil.getTransaction(localId);
- if (tx == null)
- {
- log.trace("RuntimeException in forget: transaction not found");
- throw new OBJECT_NOT_EXIST("No transaction.");
- }
-
- tx.forget();
- }
- }
-
- // ResourceFactory implementation --------------------------------
-
- /**
- * Creates a wrapped reference for the OTS resource with the given
- * <code>localId</code>.
- * @see org.jboss.tm.ResourceFactory#createResource(long)
- */
- public org.jboss.tm.remoting.interfaces.Resource createResource(long localId)
- {
- // Set up oid byte array to create CORBA reference to the Resource
- byte[] oid = new byte[9];
- oid[0] = RESOURCE;
- LocalId.toByteArray(localId, oid, 1);
-
- // Create CORBA reference to the Resource
- Resource r = ResourceHelper.narrow(
- resourcePoa.create_reference_with_id(oid, ResourceHelper.id()));
-
- // Return an OTSResourceWrapper containing the CORBA reference
- return new OTSResourceWrapper(r);
- }
-
- // OTSContextFactory implementation ------------------------------
-
- /**
- * Creates an OTS context with the specified <code>formatId</code>,
- * <code>globalId</code>, and <code>coordinator</code>. The OTS context
- * will contain a null <code>Terminator</code> reference and an
- * <code>org.omg.CosTransactions.Coordinator</code> reference extracted from
- * the <code>coordinator</code> parameter, which must be an instance of
- * <code>org.jboss.tm.iiop.wrapper.OTSCoordinatorWrapper</code>.
- * It will contain zero in its timeout field. The caller should use the
- * method <code>setTimeout</code> to set the timeout field of the newly
- * created OTS context.
- *
- * @param formatId the format id to be stored in the OTS context
- * @param globalId the global id to be stored in the OTS context
- * @param coordinator an <code>org.jboss.tm.iiop.wrapper.OTSCoordinatorWrapper</code>
- * containing the <code>org.omg.CosTransactions.Coordinator</code>
- * reference to be stored in the OTS context
- * @return an instance of <code>org.omg.CosTransactions.PropagationContext</code>.
- * @see org.jboss.tm.OTSContextFactory#createOTSContext(int, byte[], org.jboss.tm.remoting.interfaces.Coordinator)
- */
- public Object createOTSContext(int formatId, byte[] globalId,
- org.jboss.tm.remoting.interfaces.Coordinator coordinator)
- {
- if (!(coordinator instanceof OTSCoordinatorWrapper))
- throw new IllegalArgumentException("createOTSContext: " +
- "coordinator parameter must be an OTSCoordinatorWrapper");
-
- Coordinator coord = ((OTSCoordinatorWrapper) coordinator).getWrappedCoordinator();
-
- // Create and initialize PropagationContext object
- PropagationContext pc = new PropagationContext();
- pc.current = createTransIdentity(formatId, globalId, coord);
- pc.timeout = 0;
- pc.parents = new TransIdentity[0];
- pc.implementation_specific_data = orb.create_any();
-
- return pc;
- }
-
- /**
- * Creates an OTS context with the specified <code>formatId</code> and
- * <code>globalId</code>, and with an
- * <code>org.omg.CosTransactions.Coordinator</code> reference that
- * corresponds to the local transaction whose local id is
- * <code>coordinatorLocalId</code>. The OTS context will contain a null
- * <code>Terminator</code> reference and zero in its timeout field.
- * The caller should use the method <code>setTimeout</code> to set the
- * timeout field of the newly created OTS context.
- *
- * @param formatId the format id to be stored in the OTS context
- * @param globalId the global id to be stored in the OTS context
- * @param coordinatorLocalId the local id of the transaction associated with
- * the coordinator reference to be stored in the OTS context
- * @return an instance of <code>org.omg.CosTransactions.PropagationContext</code>.
- * @see org.jboss.tm.OTSContextFactory#createOTSContext(int, byte[], long)
- */
- public Object createOTSContext(int formatId, byte[] globalId, long coordinatorLocalId)
- {
- // Set up oid byte array to create CORBA reference to the Coordinator
- byte[] oid = new byte[9];
- oid[0] = COORDINATOR;
- LocalId.toByteArray(coordinatorLocalId, oid, 1);
-
- // Create CORBA reference to the Coordinator
- Coordinator coord = CoordinatorHelper.narrow(
- poa.create_reference_with_id(oid, CoordinatorHelper.id()));
-
- // Create and initialize PropagationContext object
- PropagationContext pc = new PropagationContext();
- pc.current = createTransIdentity(formatId, globalId, coord);
- pc.timeout = 0;
- pc.parents = new TransIdentity[0];
- pc.implementation_specific_data = orb.create_any();
-
- return pc;
- }
-
- /**
- * Sets the timeout field of the specified OTS context.
- * @param otsContext an instance of <code>org.omg.CosTransactions.PropagationContext</code>
- * @param timeout the timeout value to be stored in the OTS context.
- * @see org.jboss.tm.OTSContextFactory#setTimeout(java.lang.Object, long)
- */
- public void setTimeout(Object otsContext, int timeout)
- {
- if (!(otsContext instanceof PropagationContext))
- throw new IllegalArgumentException("setTimeout: " +
- "otsContext parameter must be a PropagationContext");
-
- PropagationContext pc = (PropagationContext) otsContext;
- pc.timeout = timeout;
- }
-
- // StringRemoteRefConverter implementation ---------------
-
- /**
- * Converts a stringfied reference to a remote resource back to a remote
- * reference.
- *
- * @param strResource a stringfied reference to a remote resource
- * @return a remote reference to the resource.
- */
- public org.jboss.tm.remoting.interfaces.Resource
- stringToResource(String strResource)
- {
- return OTSResourceWrapper.fromString(strResource);
- }
-
- /**
- * Converts a stringfied reference to a remote recovery coordinator back
- * to a remote reference.
- *
- * @param strRecCoordinator a stringfied reference to a remote recovery
- * coordinator
- * @return a remote reference to the recovery coordinator.
- */
- public org.jboss.tm.remoting.interfaces.RecoveryCoordinator
- stringToRecoveryCoordinator(String strRecCoordinator)
- {
- return OTSRecoveryCoordinatorWrapper.fromString(strRecCoordinator);
- }
-
- /**
- * Takes a remote reference to a resource and converts it to a string.
- *
- * @param res a remote reference to a resource
- * @return a string that represents the remote resource.
- */
- public String resourceToString(org.jboss.tm.remoting.interfaces.Resource res)
- {
- if (res instanceof OTSResourceWrapper)
- return res.toString();
- else
- throw new IllegalArgumentException();
-
- }
-
- /**
- * Takes a remote reference to recovery coordinator and converts it to a
- * string.
- *
- * @param recoveryCoord a remote reference to a recovery coordinator
- * @return a string that represents the remote recovery coordinator.
- */
- public String recoveryCoordinatorToString(
- org.jboss.tm.remoting.interfaces.RecoveryCoordinator recoveryCoord)
- {
- if (recoveryCoord instanceof OTSRecoveryCoordinatorWrapper)
- return recoveryCoord.toString();
- else
- throw new IllegalArgumentException();
- }
-
- // Private -------------------------------------------------------
-
- private byte[] getTargetId()
- {
- byte[] id = null;
- try
- {
- id = poaCurrent.get_object_id();
- }
- catch (NoContext e)
- {
- if (log.isTraceEnabled())
- log.trace("Unexpected exception: " + e);
- throw new RuntimeException("Unexpected exception: ", e);
- }
- return id;
- }
-
- private void checkInvocationTarget(int targetType)
- {
- if (getTargetId()[0] != targetType)
- throw new BAD_OPERATION();
- }
-
- /**
- * Create and initialize TransIdentity object.
- */
- private static TransIdentity createTransIdentity(Xid xid,
- Coordinator coord,
- Terminator term)
- {
- // Concatenate global transaction id and branch qualifier
- byte gtrid[] = xid.getGlobalTransactionId();
- byte bqual[] = xid.getBranchQualifier();
- byte[] trid = new byte[gtrid.length + bqual.length];
- System.arraycopy(gtrid, 0, trid, 0, gtrid.length);
- System.arraycopy(bqual, 0, trid, gtrid.length, bqual.length);
-
- // Create TransIdentity instance and set its fields
- TransIdentity ti = new TransIdentity();
- ti.coord = coord;
- ti.term = term;
- ti.otid = new otid_t(xid.getFormatId(), bqual.length, trid);
- return ti;
- }
-
- /**
- * Create and initialize TransIdentity object.
- */
- private static TransIdentity createTransIdentity(int formatId,
- byte[] globalId,
- Coordinator coord)
- {
- // Concatenate the globalId and a zero-valued branch qualifier of length
- // 1, just because the OTS and XA specs insist that the branch qualifier
- // cannot have lenght zero.
- byte[] trid = new byte[globalId.length + 1];
- // The branch qualifier part of the trid is trid[globalId.length], which
- // already contains 0. We only need to fill the global transaction id
- // part.
- System.arraycopy(globalId, 0, trid, 0, globalId.length);
-
- // Create TransIdentity instance and set its fields
- TransIdentity ti = new TransIdentity();
- ti.coord = coord;
- ti.term = null;
- ti.otid = new otid_t(formatId,
- 1, /* bqual length */
- trid);
- return ti;
- }
-
- private static Status javaxToCosTransactions(int status)
- {
- switch (status)
- {
- case javax.transaction.Status.STATUS_ACTIVE:
- return org.omg.CosTransactions.Status.StatusActive;
- case javax.transaction.Status.STATUS_COMMITTED:
- return org.omg.CosTransactions.Status.StatusCommitted;
- case javax.transaction.Status.STATUS_COMMITTING:
- return org.omg.CosTransactions.Status.StatusCommitting;
- case javax.transaction.Status.STATUS_MARKED_ROLLBACK:
- return org.omg.CosTransactions.Status.StatusMarkedRollback;
- case javax.transaction.Status.STATUS_NO_TRANSACTION:
- return org.omg.CosTransactions.Status.StatusNoTransaction;
- case javax.transaction.Status.STATUS_PREPARED:
- return org.omg.CosTransactions.Status.StatusPrepared;
- case javax.transaction.Status.STATUS_PREPARING:
- return org.omg.CosTransactions.Status.StatusPreparing;
- case javax.transaction.Status.STATUS_ROLLEDBACK:
- return org.omg.CosTransactions.Status.StatusRolledBack;
- case javax.transaction.Status.STATUS_ROLLING_BACK:
- return org.omg.CosTransactions.Status.StatusRollingBack;
- case javax.transaction.Status.STATUS_UNKNOWN:
- return org.omg.CosTransactions.Status.StatusUnknown;
- default:
- log.trace("Invalid transaction status.");
- return org.omg.CosTransactions.Status.StatusUnknown;
- }
- }
-
- private static boolean compare(Xid xid,
- int otherFormatId,
- byte[] otherGlobalId,
- int otherLength)
- {
- if (xid.getFormatId() != otherFormatId)
- return false;
-
- byte[] globalId = xid.getGlobalTransactionId();
- int len = globalId.length;
-
- if (len != otherLength)
- return false;
-
- for (int i = 0; i < len; ++i)
- if (globalId[i] != otherGlobalId[i])
- return false;
-
- return true;
- }
-
-}
Modified: trunk/iiop/src/main/org/jboss/tm/iiop/TxServerClientInterceptor.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/TxServerClientInterceptor.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/TxServerClientInterceptor.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -24,11 +24,11 @@
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.jboss.iiop.CorbaORB;
import org.jboss.iiop.CorbaORBService;
import org.jboss.logging.Logger;
-import org.jboss.tm.TransactionImpl;
import org.jboss.tm.TxUtils;
import org.jboss.util.NestedRuntimeException;
import org.omg.CORBA.Any;
@@ -179,7 +179,7 @@
{
PropagationContext pc = null;
TransactionManager tm = getTransactionManager();
- TransactionImpl tx = (TransactionImpl) tm.getTransaction();
+ Transaction tx = tm.getTransaction();
if (!TxUtils.isUncommitted(tx))
{
if (traceEnabled)
@@ -187,18 +187,9 @@
return null;
}
- if (CorbaORBService.getOTSContextPropagationEnabledFlag() == true)
- {
- if (traceEnabled)
- log.trace("Propagating actual OTS context");
- pc = (PropagationContext) tx.getOTSPropagationContext();
- }
- else
- {
- if (traceEnabled)
- log.trace("Propagating empty OTS context");
- pc = getEmptyPropagationContext();
- }
+ if (traceEnabled)
+ log.trace("Propagating empty OTS context");
+ pc = getEmptyPropagationContext();
Any any = CorbaORB.getInstance().create_any();
PropagationContextHelper.insert(any, pc);
Modified: trunk/iiop/src/main/org/jboss/tm/iiop/TxServerInterceptor.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/TxServerInterceptor.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/TxServerInterceptor.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -43,10 +43,6 @@
import org.jboss.logging.Logger;
import org.jboss.proxy.ejb.ForeignTransaction;
-import org.jboss.tm.TransactionPropagationContextImporter;
-import org.jboss.tm.iiop.wrapper.OTSCoordinatorWrapper;
-import org.jboss.tm.remoting.interfaces.Coordinator;
-import org.jboss.tm.remoting.interfaces.TxPropagationContext;
/**
* This implementation of
@@ -75,7 +71,6 @@
private static int slotId;
private static Codec codec;
private static org.omg.PortableInterceptor.Current piCurrent = null;
- private static TransactionPropagationContextImporter tpcImporter = null;
// Static methods ------------------------------------------------
@@ -107,46 +102,8 @@
Any any = piCurrent.get_slot(slotId);
if (any.type().kind().value() != TCKind._tk_null)
{
- // Yes, there is a TPC
- PropagationContext pc = PropagationContextHelper.extract(any);
- if (pc.current.coord != null)
- {
- // In order to import the CosTransactions PropagationContext
- // we need to convert it to a DTM TxPropagationContext.
-
- // Get the global id from the PropagationContext
- byte[] globalId;
- otid_t otid = pc.current.otid;
-
- if (otid.bqual_length == 0)
- globalId = otid.tid;
- else
- {
- // Strip the branch qualifier part
- int len = otid.tid.length - otid.bqual_length;
- globalId = new byte[len];
- System.arraycopy(otid.tid, 0, globalId, 0, len);
- }
-
- // Wrap the coordinator into a DTM Coordinator instance
- Coordinator coordinatorWrapper =
- new OTSCoordinatorWrapper(pc.current.coord);
-
- // Create the DTM TPC
- TxPropagationContext tpc =
- new TxPropagationContext(otid.formatID,
- globalId,
- pc.timeout,
- coordinatorWrapper,
- null);
-
- // Import the TPC
- tx = getTPCImporter().importTransactionPropagationContext(tpc);
- }
-
- // No transaction propagation (add the marker)
- if (tx == null)
- tx = ForeignTransaction.instance;
+ // Yes, there is a TPC: add the foreign transaction marker
+ tx = ForeignTransaction.instance;
}
}
catch (InvalidSlot e)
@@ -159,29 +116,6 @@
return tx;
}
- /**
- * Get a reference to the transaction importer.
- */
- private static TransactionPropagationContextImporter getTPCImporter()
- {
- if (tpcImporter == null)
- {
- try
- {
- Context ctx = new InitialContext();
- tpcImporter = (TransactionPropagationContextImporter)ctx.lookup(
- "java:/TransactionPropagationContextImporter");
- }
- catch (NamingException e)
- {
- throw new RuntimeException(
- "java:/TransactionPropagationContextImporter lookup failed",
- e);
- }
- }
- return tpcImporter;
- }
-
// Constructor ---------------------------------------------------
public TxServerInterceptor()
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransaction.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransaction.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransaction.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,496 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.client;
-
-import java.io.Serializable;
-
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-
-import org.omg.CORBA.BAD_INV_ORDER;
-import org.omg.CORBA.NO_PERMISSION;
-import org.omg.CORBA.OBJECT_NOT_EXIST;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.TRANSACTION_ROLLEDBACK;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosTransactions.Control;
-import org.omg.CosTransactions.Coordinator;
-import org.omg.CosTransactions.HeuristicMixed;
-import org.omg.CosTransactions.HeuristicHazard;
-import org.omg.CosTransactions.Inactive;
-import org.omg.CosTransactions.NoTransaction;
-import org.omg.CosTransactions.PropagationContext;
-import org.omg.CosTransactions.Terminator;
-
-import org.jboss.iiop.CorbaORB;
-import org.jboss.tm.iiop.TransactionDesc;
-import org.jboss.tm.iiop.TransactionFactoryExt;
-import org.jboss.tm.iiop.TransactionFactoryExtHelper;
-import org.jboss.tm.iiop.TxClientInterceptor;
-
-/**
- * The client-side UserTransaction implementation for RMI/IIOP clients.
- * This will delegate all UserTransaction calls to the server.
- *
- * <em>Warning:</em> This is only for stand-alone RMI/IIOP clients that
- * do not have their own transaction service. No local work is done in
- * the context of transactions started here, only work done in beans
- * at the server.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @author <a href="mailto:ivanneto at ime.usp.br">Ivan Neto</a>
- * @version $Revision$
- */
-public class IIOPClientUserTransaction
- implements UserTransaction,
- Referenceable,
- Serializable
-{
- // Static --------------------------------------------------------
- static final long serialVersionUID = 6653800687253055416L;
-
- /** Our singleton instance. */
- private static IIOPClientUserTransaction singleton = null;
-
- /** CORBA reference to the server's transaction factory. */
- private static TransactionFactoryExt txFactory;
-
- /** Transaction information associated with the current thread. */
- private static ThreadLocal threadLocalData = new ThreadLocal() {
- protected synchronized Object initialValue()
- {
- return new TransactionInfo(); // see nested class below
- }
- };
-
- // Nested class -------------------------------------------------
-
- /**
- * The <code>TransactionInfo</code> class holds transaction information
- * associated with the current thread. The <code>threadLocalData</code>
- * field contains an instance of this class. The field timeout applies
- * to new transactions started by the current thread; its value is not
- * necessarily equal to the time out of the currrent transaction. The
- * three remaining fields refer to the currrent transaction.
- */
- private static class TransactionInfo
- {
- int timeout = 0; // for new transactions started by the current thread
- Control control; // null if no current transaction
- PropagationContext pc; // null if no current transaction
- }
-
- // Static accessors to thread-local data -------------------------
-
- private static void setThreadLocalTimeout(int timeout)
- {
- ((TransactionInfo)threadLocalData.get()).timeout = timeout;
- }
-
- private static int getThreadLocalTimeout()
- {
- return ((TransactionInfo)threadLocalData.get()).timeout;
- }
-
- private static void setThreadLocalControl(Control control)
- {
- ((TransactionInfo)threadLocalData.get()).control = control;
- }
-
- private static Control getThreadLocalControl()
- {
- return ((TransactionInfo)threadLocalData.get()).control;
- }
-
- private static void setThreadLocalPropagationContext(PropagationContext pc)
- {
- ((TransactionInfo)threadLocalData.get()).pc = pc;
- }
-
- private static PropagationContext getThreadLocalPropagationContext()
- {
- return ((TransactionInfo)threadLocalData.get()).pc;
- }
-
- private static Coordinator getThreadLocalCoordinator()
- {
- PropagationContext pc = ((TransactionInfo)threadLocalData.get()).pc;
- return pc == null ? null : pc.current.coord;
- }
-
- private static Terminator getThreadLocalTerminator()
- throws NoTransaction
- {
- PropagationContext pc = ((TransactionInfo)threadLocalData.get()).pc;
- Terminator term = (pc == null ? null : pc.current.term);
-
- if (term == null)
- throw new NoTransaction();
-
- return term;
- }
-
- // Management of the transaction-thread association --------------
-
- /**
- * Auxiliary method that sets the current transaction.
- */
- private static void setCurrentTransaction(Control control,
- PropagationContext pc)
- {
- setThreadLocalControl(control);
- setThreadLocalPropagationContext(pc);
- TxClientInterceptor.setOutgoingPropagationContext(pc);
- }
-
- /**
- * Auxiliary method that unsets the current transaction.
- */
- private static void unsetCurrentTransaction()
- {
- setThreadLocalControl(null);
- setThreadLocalPropagationContext(null);
- TxClientInterceptor.unsetOutgoingPropagationContext();
- }
-
- // Other auxiliary (and static) methods -------------------------
-
- /**
- * Returns a CORBA reference to the TransactionFactory implemented by
- * the JBoss server.
- */
- private static TransactionFactoryExt getTxFactory()
- {
- if (txFactory == null)
- {
- try
- {
- ORB orb = CorbaORB.getInstance();
- org.omg.CORBA.Object obj =
- orb.resolve_initial_references("NameService");
- NamingContextExt rootContext = NamingContextExtHelper.narrow(obj);
- org.omg.CORBA.Object txFactoryObj =
- rootContext.resolve_str("TransactionService");
- txFactory = TransactionFactoryExtHelper.narrow(txFactoryObj);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not get transaction factory: "
- + e);
- }
- }
- return txFactory;
- }
-
- /**
- * Converts transaction status from org.omg.CosTransactions format
- * to javax.transaction format.
- */
- private static int cosTransactionsToJavax(
- org.omg.CosTransactions.Status status)
- {
- switch (status.value())
- {
- case org.omg.CosTransactions.Status._StatusActive:
- return javax.transaction.Status.STATUS_ACTIVE;
- case org.omg.CosTransactions.Status._StatusCommitted:
- return javax.transaction.Status.STATUS_COMMITTED;
- case org.omg.CosTransactions.Status._StatusCommitting:
- return javax.transaction.Status.STATUS_COMMITTING;
- case org.omg.CosTransactions.Status._StatusMarkedRollback:
- return javax.transaction.Status.STATUS_MARKED_ROLLBACK;
- case org.omg.CosTransactions.Status._StatusNoTransaction:
- return javax.transaction.Status.STATUS_NO_TRANSACTION;
- case org.omg.CosTransactions.Status._StatusPrepared:
- return javax.transaction.Status.STATUS_PREPARED;
- case org.omg.CosTransactions.Status._StatusPreparing:
- return javax.transaction.Status.STATUS_PREPARING;
- case org.omg.CosTransactions.Status._StatusRolledBack:
- return javax.transaction.Status.STATUS_ROLLEDBACK;
- case org.omg.CosTransactions.Status._StatusRollingBack:
- return javax.transaction.Status.STATUS_ROLLING_BACK;
- case org.omg.CosTransactions.Status._StatusUnknown:
- return javax.transaction.Status.STATUS_UNKNOWN;
- default:
- return javax.transaction.Status.STATUS_UNKNOWN;
- }
- }
-
- // Constructors --------------------------------------------------
-
- /**
- * Create a new instance.
- */
- private IIOPClientUserTransaction()
- {
- }
-
- // Public --------------------------------------------------------
-
- /**
- * Returns a reference to the singleton instance.
- */
- public static IIOPClientUserTransaction getSingleton()
- {
- if (singleton == null)
- singleton = new IIOPClientUserTransaction();
- return singleton;
- }
-
- //
- // Implementation of interface UserTransaction
- //
-
- public void begin()
- throws NotSupportedException, SystemException
- {
- if (getThreadLocalControl() != null)
- throw new NotSupportedException();
- try
- {
- TransactionDesc td =
- getTxFactory().create_transaction(getThreadLocalTimeout());
- setCurrentTransaction(td.control, td.propagationContext);
- }
- catch (RuntimeException e)
- {
- SystemException se = new SystemException("Failed to create tx");
- se.initCause(e);
- throw se;
- }
- }
-
- public void commit()
- throws RollbackException,
- HeuristicMixedException,
- HeuristicRollbackException,
- SecurityException,
- IllegalStateException,
- SystemException
- {
- try
- {
- Terminator term = getThreadLocalTerminator();
- // Requests to the Terminator should not propagate the transaction
- // context.
- TxClientInterceptor.unsetOutgoingPropagationContext();
- term.commit(true /* reportHeuristics */);
- }
- catch (NoTransaction e)
- {
- IllegalStateException ex = new IllegalStateException();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicMixed e)
- {
- HeuristicMixedException ex = new HeuristicMixedException();
- ex.initCause(e);
- throw ex;
- }
- catch (HeuristicHazard e)
- {
- HeuristicRollbackException ex = new HeuristicRollbackException();
- ex.initCause(e);
- throw ex;
- }
- catch (TRANSACTION_ROLLEDBACK e)
- {
- RollbackException ex = new RollbackException();
- ex.initCause(e);
- throw ex;
- }
- catch (BAD_INV_ORDER e)
- {
- IllegalStateException ex = new IllegalStateException();
- ex.initCause(e);
- throw ex;
- }
- catch (NO_PERMISSION e)
- {
- SecurityException ex = new SecurityException();
- ex.initCause(e);
- throw ex;
- }
- catch (RuntimeException e)
- {
- SystemException ex = new SystemException();
- ex.initCause(e);
- throw ex;
- }
- finally
- {
- unsetCurrentTransaction();
- }
- }
-
- public void rollback()
- throws SecurityException,
- IllegalStateException,
- SystemException
- {
- try
- {
- Terminator term = getThreadLocalTerminator();
- // Requests to the Terminator should not propagate the transaction
- // context.
- TxClientInterceptor.unsetOutgoingPropagationContext();
- term.rollback();
- }
- catch (NoTransaction e)
- {
- IllegalStateException ex = new IllegalStateException();
- ex.initCause(e);
- throw ex;
- }
- catch (BAD_INV_ORDER e)
- {
- IllegalStateException ex = new IllegalStateException();
- ex.initCause(e);
- throw ex;
- }
- catch (NO_PERMISSION e)
- {
- SecurityException ex = new SecurityException();
- ex.initCause(e);
- throw ex;
- }
- catch (RuntimeException e)
- {
- SystemException ex = new SystemException();
- ex.initCause(e);
- throw ex;
- }
- finally
- {
- unsetCurrentTransaction();
- }
- }
-
- public void setRollbackOnly()
- throws IllegalStateException,
- SystemException
- {
- Coordinator coord = getThreadLocalCoordinator();
-
- if (coord == null)
- throw new IllegalStateException();
-
- try
- {
- // Requests to the Coordinator should not propagate the transaction
- // context.
- TxClientInterceptor.suspendOutgoingPropagationContext();
- coord.rollback_only();
- }
- catch (Inactive e)
- {
- SystemException ex = new SystemException();
- ex.initCause(e);
- throw ex;
- }
- catch (BAD_INV_ORDER e)
- {
- IllegalStateException ex = new IllegalStateException();
- ex.initCause(e);
- throw ex;
- }
- catch (RuntimeException e)
- {
- SystemException ex = new SystemException();
- ex.initCause(e);
- throw ex;
- }
- finally
- {
- TxClientInterceptor.resumeOutgoingPropagationContext();
- }
- }
-
- public int getStatus()
- throws SystemException
- {
- try
- {
- Coordinator coord = getThreadLocalCoordinator();
- if (coord == null)
- {
- return Status.STATUS_NO_TRANSACTION;
- }
- else
- {
- try
- {
- // Requests to the Coordinator should not propagate the
- // transaction context.
- TxClientInterceptor.suspendOutgoingPropagationContext();
- return cosTransactionsToJavax(coord.get_status());
- }
- finally
- {
- TxClientInterceptor.resumeOutgoingPropagationContext();
- }
- }
- }
- catch (OBJECT_NOT_EXIST e)
- {
- return Status.STATUS_NO_TRANSACTION;
- }
- catch (RuntimeException e)
- {
- SystemException ex = new SystemException();
- ex.initCause(e);
- throw ex;
- }
- }
-
- public void setTransactionTimeout(int seconds)
- throws SystemException
- {
- setThreadLocalTimeout(seconds);
- }
-
- //
- // Implementation of interface Referenceable
- //
-
- public Reference getReference()
- throws NamingException
- {
- Reference ref = new Reference(
- "org.jboss.tm.iiop.client.IIOPClientUserTransaction",
- "org.jboss.tm.iiop.client.IIOPClientUserTransactionObjectFactory",
- null);
- return ref;
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransactionObjectFactory.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransactionObjectFactory.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/client/IIOPClientUserTransactionObjectFactory.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.jboss.tm.iiop.client;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.spi.ObjectFactory;
-import javax.transaction.UserTransaction;
-
-import org.omg.CORBA.BAD_PARAM;
-
-import org.jboss.logging.Logger;
-import org.jboss.tm.iiop.TransactionFactoryExtHelper;
-import org.jboss.tm.usertx.client.ServerVMClientUserTransaction;
-
-/**
- * This is an object factory for producing client-side UserTransactions
- * for standalone RMI/IIOP clients.
- *
- * @author <a href="mailto:osh at sparre.dk">Ole Husgaard</a>
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class IIOPClientUserTransactionObjectFactory
- implements ObjectFactory
-{
- private static final Logger log =
- Logger.getLogger(IIOPClientUserTransactionObjectFactory.class);
- private static final boolean traceEnabled = log.isTraceEnabled();
-
- /**
- * The <code>UserTransaction</code> this factory will return.
- * This is evaluated lazily in {@link #getUserTransaction()}.
- */
- private static UserTransaction userTransaction = null;
-
- /**
- * Get the <code>UserTransaction</code> this factory will return.
- * This may return a cached value from a previous call.
- */
- private static UserTransaction getUserTransaction()
- {
- if (userTransaction == null)
- {
- // See if we have a local TM
- try
- {
- new InitialContext().lookup("java:/TransactionManager");
-
- // We execute in the server.
- userTransaction = ServerVMClientUserTransaction.getSingleton();
- }
- catch (NamingException ex)
- {
- // We execute in a stand-alone client.
- userTransaction = IIOPClientUserTransaction.getSingleton();
- }
- }
- return userTransaction;
- }
-
- public Object getObjectInstance(Object obj, Name name,
- Context nameCtx, Hashtable environment)
- throws Exception
- {
-
- if (traceEnabled)
- log.trace("getObjectInstance: obj=" + obj +
- "\n name=" + name +
- "\n nameCtx= " + nameCtx);
-
- if (!name.toString().equals("UserTransaction"))
- return null;
- if (!(obj instanceof org.omg.CORBA.Object))
- return null;
- try
- {
- TransactionFactoryExtHelper.narrow((org.omg.CORBA.Object)obj);
- }
- catch (BAD_PARAM e)
- {
- return null;
- }
- return getUserTransaction();
- }
-}
-
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrent.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrent.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrent.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,354 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.client;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import org.omg.CORBA.LocalObject;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextPackage.CannotProceed;
-import org.omg.CosNaming.NamingContextPackage.InvalidName;
-import org.omg.CosNaming.NamingContextPackage.NotFound;
-import org.omg.CosTransactions.Control;
-import org.omg.CosTransactions.Coordinator;
-import org.omg.CosTransactions.Current;
-import org.omg.CosTransactions.HeuristicHazard;
-import org.omg.CosTransactions.HeuristicMixed;
-import org.omg.CosTransactions.Inactive;
-import org.omg.CosTransactions.InvalidControl;
-import org.omg.CosTransactions.NoTransaction;
-import org.omg.CosTransactions.PropagationContext;
-import org.omg.CosTransactions.Status;
-import org.omg.CosTransactions.SubtransactionsUnavailable;
-import org.omg.CosTransactions.Terminator;
-import org.omg.CosTransactions.Unavailable;
-
-import org.jboss.tm.iiop.TransactionDesc;
-import org.jboss.tm.iiop.TransactionFactoryExt;
-import org.jboss.tm.iiop.TransactionFactoryExtHelper;
-import org.jboss.tm.iiop.TxClientInterceptor;
-
-/**
- * This class implements <code>org.omg.CosTransactions.Current</code>.
- *
- * @author Francisco Reverbel
- */
-
-public class TransactionCurrent
- extends LocalObject
- implements Current
-{
- // Static fields -------------------------------------------------
-
- private static TransactionCurrent instance = null; // singleton instance
- private static TransactionFactoryExt txFactory;
- private static Set suspendedTransactions =
- Collections.synchronizedSet (new HashSet());
- private static ThreadLocal threadLocalData = new ThreadLocal() {
- protected synchronized Object initialValue()
- {
- return new TransactionInfo(); // see nested class below
- }
- };
-
- // Nested class -------------------------------------------------
-
- /**
- * The <code>TransactionInfo</code> class holds transaction information
- * associated with the current thread. The <code>threadLocalData</code>
- * field contains an instance of this class. The field timeout applies
- * to new transactions started by the current thread; its value is not
- * necessarily equal to the time out of the currrent transaction. The
- * three remaining fields refer to the currrent transaction.
- */
- private static class TransactionInfo
- {
- int timeout = 0; // for new transactions started by the current thread
- Control control; // null if no current transaction
- Coordinator coord; // null if no current transaction
- Terminator term; // null if no current transaction
- }
-
- // Static accessors to thread-local data -------------------------
-
- private static void setThreadLocalTimeout(int timeout)
- {
- ((TransactionInfo)threadLocalData.get()).timeout = timeout;
- }
-
- private static int getThreadLocalTimeout()
- {
- return ((TransactionInfo)threadLocalData.get()).timeout;
- }
-
- private static void setThreadLocalControl(Control control)
- {
- ((TransactionInfo)threadLocalData.get()).control = control;
- }
-
- private static Control getThreadLocalControl()
- {
- return ((TransactionInfo)threadLocalData.get()).control;
- }
-
- private static void setThreadLocalCoordinator(Coordinator coord)
- {
- ((TransactionInfo)threadLocalData.get()).coord = coord;
- }
-
- private static Coordinator getThreadLocalCoordinator()
- {
- return ((TransactionInfo)threadLocalData.get()).coord;
- }
-
- private static void setThreadLocalTerminator(Terminator term)
- {
- ((TransactionInfo)threadLocalData.get()).term = term;
- }
-
- private static Terminator getThreadLocalTerminator()
- throws NoTransaction
- {
- Terminator term = ((TransactionInfo)threadLocalData.get()).term;
-
- if (term == null)
- throw new NoTransaction();
-
- return term;
- }
-
- // Management of the transaction-thread association --------------
-
- /**
- * Auxiliary method that sets the current transaction.
- */
- private static void setCurrentTransaction(Control control,
- PropagationContext pc)
- {
- setThreadLocalControl(control);
- setThreadLocalCoordinator(pc.current.coord);
- setThreadLocalTerminator(pc.current.term);
- TxClientInterceptor.setOutgoingPropagationContext(pc);
- }
-
- /**
- * Auxiliary method that unsets the current transaction.
- */
- private static void unsetCurrentTransaction()
- {
- setThreadLocalControl(null);
- setThreadLocalCoordinator(null);
- setThreadLocalTerminator(null);
- TxClientInterceptor.unsetOutgoingPropagationContext();
- }
-
- // Initialization of static fields -------------------------------
-
- public static void init(NamingContextExt nc)
- {
- try
- {
- org.omg.CORBA.Object txFactoryObj =
- nc.resolve_str("TransactionService");
- txFactory = TransactionFactoryExtHelper.narrow(txFactoryObj);
- }
- catch (CannotProceed e)
- {
- throw new RuntimeException(
- "Exception initializing TransactionCurrent: " + e);
- }
- catch (NotFound e)
- {
- throw new RuntimeException(
- "Exception initializing TransactionCurrent: " + e);
- }
- catch (InvalidName e)
- {
- throw new RuntimeException(
- "Exception initializing TransactionCurrent: " + e);
- }
- }
-
- // Singleton accessor --------------------------------------------
-
- public static synchronized TransactionCurrent getInstance()
- {
- if (instance == null)
- instance = new TransactionCurrent();
- return instance;
- }
-
- // org.omg.CosTransactions.Current operations --------------------
-
- /**
- * Begins a new transaction, which will become the current transaction
- * associated with the calling thread.
- *
- * @see org.omg.CosTransactions.CurrentOperations#begin()
- */
- public void begin()
- throws SubtransactionsUnavailable
- {
- if (getThreadLocalControl() != null)
- throw new SubtransactionsUnavailable();
- TransactionDesc td = txFactory.create_transaction(
- getThreadLocalTimeout());
- setCurrentTransaction(td.control, td.propagationContext);
- }
-
- /**
- * Commits the current transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#commit(boolean)
- */
- public void commit(boolean reportHeuristics)
- throws NoTransaction,
- HeuristicHazard,
- HeuristicMixed
- {
- getThreadLocalTerminator().commit(reportHeuristics);
- unsetCurrentTransaction();
- }
-
- /**
- * Rolls the current transaction back.
- *
- * @see org.omg.CosTransactions.CurrentOperations#rollback()
- */
- public void rollback()
- throws NoTransaction
- {
- getThreadLocalTerminator().rollback();
- unsetCurrentTransaction();
- }
-
- /**
- * Marks the current transaction as rollback only.
- *
- * @see org.omg.CosTransactions.CurrentOperations#rollback_only()
- */
- public void rollback_only()
- throws NoTransaction
- {
- try
- {
- Coordinator coord = getThreadLocalCoordinator();
-
- if (coord == null)
- throw new NoTransaction();
-
- coord.rollback_only();
- }
- catch (Inactive e)
- {
- throw new RuntimeException("Current transaction already prepared: "
- + e);
- }
- }
-
- /**
- * Gets the status of current transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#get_status()
- */
- public Status get_status()
- {
- Coordinator coord = getThreadLocalCoordinator();
- return (coord == null) ? Status.StatusNoTransaction : coord.get_status();
- }
-
- /**
- * Returns the name of the current transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#get_transaction_name()
- */
- public String get_transaction_name()
- {
- Coordinator coord = getThreadLocalCoordinator();
- return (coord == null) ? "" : coord.get_transaction_name();
- }
-
- /**
- * Sets the transaction time out that will be in effect for
- * transactions created after this call.
- *
- * @see org.omg.CosTransactions.CurrentOperations#set_timeout(int)
- */
- public void set_timeout(int timeOut)
- {
- setThreadLocalTimeout(timeOut);
- }
-
- /**
- * Returns the Control associated with the current transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#get_control()
- */
- public Control get_control()
- {
- return getThreadLocalControl();
- }
-
- /**
- * Suspends the current transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#suspend()
- */
- public Control suspend()
- {
- Control control = getThreadLocalControl();
- if (control != null)
- {
- unsetCurrentTransaction();
- suspendedTransactions.add(control);
- }
- return control;
- }
-
- /**
- * Resumes the specified transaction.
- *
- * @see org.omg.CosTransactions.CurrentOperations#resume(org.omg.CosTransactions.Control)
- */
- public void resume(Control whichTransaction)
- throws InvalidControl
- {
- try
- {
- if (whichTransaction == null)
- throw new InvalidControl();
- if (!suspendedTransactions.remove(whichTransaction))
- throw new InvalidControl();
- Coordinator coord = whichTransaction.get_coordinator();
- if (coord == null)
- throw new InvalidControl();
- PropagationContext pc = coord.get_txcontext(); // throws Unavailable
- setCurrentTransaction(whichTransaction, pc);
- }
- catch (Unavailable e)
- {
- throw new InvalidControl();
- }
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrentInitializer.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrentInitializer.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/client/TransactionCurrentInitializer.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,79 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.client;
-
-import org.omg.CORBA.LocalObject;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.PortableInterceptor.ORBInitInfo;
-import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
-import org.omg.PortableInterceptor.ORBInitializer;
-
-/**
- * This is an <code>org.omg.PortableInterceptor.ORBInitializer</code> that
- * initializes the <code>TransactionCurrent</code>.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class TransactionCurrentInitializer
- extends LocalObject
- implements ORBInitializer
-{
-
- public TransactionCurrentInitializer()
- {
- // do nothing
- }
-
- // org.omg.PortableInterceptor.ORBInitializer operations ---------
-
- public void pre_init(ORBInitInfo info)
- {
- try
- {
- info.register_initial_reference("TransactionCurrent",
- TransactionCurrent.getInstance());
- }
- catch (InvalidName e)
- {
- throw new RuntimeException("Could not register initial " +
- "reference for TransactionCurrent: " + e);
- }
- }
-
- public void post_init(ORBInitInfo info)
- {
- try
- {
- org.omg.CORBA.Object obj =
- info.resolve_initial_references("NameService");
- NamingContextExt rootContext = NamingContextExtHelper.narrow(obj);
- TransactionCurrent.init(rootContext);
- }
- catch (Exception e)
- {
- throw new RuntimeException("Unexpected " + e);
- }
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSCoordinatorWrapper.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSCoordinatorWrapper.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSCoordinatorWrapper.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,237 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.wrapper;
-
-import java.rmi.RemoteException;
-
-import org.jboss.iiop.CorbaORB;
-import org.jboss.tm.GlobalId;
-import org.jboss.tm.remoting.interfaces.Coordinator;
-import org.jboss.tm.remoting.interfaces.RecoveryCoordinator;
-import org.jboss.tm.remoting.interfaces.Resource;
-import org.jboss.tm.remoting.interfaces.Status;
-import org.jboss.tm.remoting.interfaces.Synchronization;
-import org.jboss.tm.remoting.interfaces.SynchronizationUnavailableException;
-import org.jboss.tm.remoting.interfaces.TransactionInactiveException;
-import org.jboss.tm.remoting.interfaces.TxPropagationContext;
-
-/**
- * Implements <code>org.jboss.tm.remoting.interfaces.Coordinator</code> by
- * wrapping an OTS resource and forwarding all method calls to the wrapped
- * resource.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class OTSCoordinatorWrapper implements Coordinator
-{
-
- // Private field -------------------------------------------------
-
- /**
- * The wrapped OTS resource.
- */
- private org.omg.CosTransactions.Coordinator otsCoordinator;
-
- // Constructor ---------------------------------------------------
-
- /**
- * Creates an <code>OTSCoordinatorWrapper</code> for a given OTS resource.
- * @param otsCoordinator the OTS resource to be wrapped.
- */
- public OTSCoordinatorWrapper(
- org.omg.CosTransactions.Coordinator otsCoordinator)
- {
- this.otsCoordinator = otsCoordinator;
- }
-
- // Attribute -----------------------------------------------------
-
- public org.omg.CosTransactions.Coordinator getWrappedCoordinator()
- {
- return otsCoordinator;
- }
-
- // Conversion to string ------------------------------------------
-
- public String toString()
- {
- return CorbaORB.getInstance().object_to_string(otsCoordinator);
- }
-
- // Static --------------------------------------------------------
-
- public static OTSCoordinatorWrapper fromString(String s)
- {
- org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(s);
- org.omg.CosTransactions.Coordinator otsCoord =
- org.omg.CosTransactions.CoordinatorHelper.narrow(obj);
- return new OTSCoordinatorWrapper(otsCoord);
- }
-
- // org.jboss.tm.remoting.interfaces.Coordinator methods ----------
-
- /**
- * Calls <code>get_status</code> on the wrapped OTS coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#getStatus()
- */
- public Status getStatus() throws RemoteException
- {
- try
- {
- return Util.cosTransactionsToJBoss(otsCoordinator.get_status());
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>is_same_transaction</code> on the wrapped OTS coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#isSameTransaction(org.jboss.tm.remoting.interfaces.Coordinator)
- */
- public boolean isSameTransaction(Coordinator c) throws RemoteException
- {
- try
- {
- org.omg.CosTransactions.Coordinator otherOtsCoord =
- ((OTSCoordinatorWrapper) c).getWrappedCoordinator();
- return otsCoordinator.is_same_transaction(otherOtsCoord);
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>hash_transaction</code> on the wrapped OTS coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#hashTransaction()
- */
- public int hashTransaction() throws RemoteException
- {
- try
- {
- return otsCoordinator.hash_transaction();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>register_resource</code> on the wrapped OTS coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#registerResource(org.jboss.tm.remoting.interfaces.Resource)
- */
- public RecoveryCoordinator registerResource(Resource r)
- throws RemoteException, TransactionInactiveException
- {
- try
- {
- org.omg.CosTransactions.Resource otsResource =
- ((OTSResourceWrapper) r).getWrappedResource();
- org.omg.CosTransactions.RecoveryCoordinator otsRecCoord =
- otsCoordinator.register_resource(otsResource);
- return new OTSRecoveryCoordinatorWrapper(otsRecCoord);
- }
- catch (org.omg.CosTransactions.Inactive i)
- {
- throw new TransactionInactiveException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>register_synchronization</code> on the wrapped OTS
- * coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#registerSynchronization(org.jboss.tm.remoting.interfaces.Synchronization)
- */
- public void registerSynchronization(Synchronization sync)
- throws RemoteException,
- TransactionInactiveException,
- SynchronizationUnavailableException
- {
- try
- {
- org.omg.CosTransactions.Synchronization otsSynch =
- ((OTSSynchronizationWrapper) sync).getWrappedSynchronization();
- otsCoordinator.register_synchronization(otsSynch);
- }
- catch (org.omg.CosTransactions.Inactive i)
- {
- throw new TransactionInactiveException();
- }
- catch (org.omg.CosTransactions.SynchronizationUnavailable sa)
- {
- throw new SynchronizationUnavailableException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls<code>rollback_only</code> on the wrapped OTS coordinator.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#rollbackOnly()
- */
- public void rollbackOnly() throws RemoteException,
- TransactionInactiveException
- {
- try
- {
- otsCoordinator.rollback_only();
- }
- catch (org.omg.CosTransactions.Inactive i)
- {
- throw new TransactionInactiveException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Not supported.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#getTransactionContext()
- */
- public TxPropagationContext getTransactionContext() throws RemoteException
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported.
- * @see org.jboss.tm.remoting.interfaces.Coordinator#getTransactionId()
- */
- public GlobalId getTransactionId() throws RemoteException
- {
- throw new UnsupportedOperationException();
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSRecoveryCoordinatorWrapper.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSRecoveryCoordinatorWrapper.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSRecoveryCoordinatorWrapper.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,113 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.wrapper;
-
-import java.rmi.RemoteException;
-
-import org.jboss.iiop.CorbaORB;
-import org.jboss.tm.remoting.interfaces.RecoveryCoordinator;
-import org.jboss.tm.remoting.interfaces.Resource;
-import org.jboss.tm.remoting.interfaces.Status;
-import org.jboss.tm.remoting.interfaces.TransactionNotPreparedException;
-
-/**
- * Implements <code>org.jboss.tm.remoting.interfaces.RecoveryCoordinator</code>
- * by wrapping an OTS recovery coordinator and forwarding all method calls to
- * the wrapped recovery coordinator.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class OTSRecoveryCoordinatorWrapper implements RecoveryCoordinator
-{
- // Private field -------------------------------------------------
-
- /**
- * The wrapped OTS recovery coordinator
- */
- private org.omg.CosTransactions.RecoveryCoordinator otsRecoveryCoordinator;
-
- // Constructor ---------------------------------------------------
-
- /**
- * Creates an <code>OTSRecoveryCoordinatorWrapper</code> for a given OTS
- * recovery coordinator.
- * @param otsRecoveryCoordinator the OTS recovery coordinator to be wrapped.
- */
- public OTSRecoveryCoordinatorWrapper(
- org.omg.CosTransactions.RecoveryCoordinator otsRecoveryCoordinator)
- {
- this.otsRecoveryCoordinator = otsRecoveryCoordinator;
- }
-
- // Attribute -----------------------------------------------------
-
- public org.omg.CosTransactions.RecoveryCoordinator getWrappedRecoveryCoordinator()
- {
- return otsRecoveryCoordinator;
- }
-
- // Conversion to string ------------------------------------------
-
- public String toString()
- {
- return CorbaORB.getInstance().object_to_string(otsRecoveryCoordinator);
- }
-
- // Static --------------------------------------------------------
-
- public static OTSRecoveryCoordinatorWrapper fromString(String s)
- {
- org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(s);
- org.omg.CosTransactions.RecoveryCoordinator otsRecCoord =
- org.omg.CosTransactions.RecoveryCoordinatorHelper.narrow(obj);
- return new OTSRecoveryCoordinatorWrapper(otsRecCoord);
- }
-
- // org.jboss.tm.remoting.interfaces.RecoveryCoordinator methods --
-
- /**
- * Calls <code>replay_completion</code> on the wrapped recovery coordinator.
- * @see org.jboss.tm.remoting.interfaces.RecoveryCoordinator#replayCompletion(org.jboss.tm.remoting.interfaces.Resource)
- */
- public Status replayCompletion(Resource r) throws RemoteException,
- TransactionNotPreparedException
- {
- try
- {
- org.omg.CosTransactions.Resource otsResource =
- ((OTSResourceWrapper) r).getWrappedResource();
- return Util.cosTransactionsToJBoss(
- otsRecoveryCoordinator.replay_completion(otsResource));
- }
- catch (org.omg.CosTransactions.NotPrepared np)
- {
- throw new TransactionNotPreparedException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
-
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSResourceWrapper.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSResourceWrapper.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSResourceWrapper.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,233 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.wrapper;
-
-import java.rmi.RemoteException;
-
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-
-import org.jboss.iiop.CorbaORB;
-import org.jboss.tm.remoting.interfaces.HeuristicHazardException;
-import org.jboss.tm.remoting.interfaces.Resource;
-import org.jboss.tm.remoting.interfaces.TransactionNotPreparedException;
-import org.jboss.tm.remoting.interfaces.TransactionAlreadyPreparedException;
-import org.jboss.tm.remoting.interfaces.Vote;
-
-
-/**
- * Implements <code>org.jboss.tm.remoting.interfaces.Resource</code> by
- * wrapping an OTS resource and forwarding all method calls to the wrapped
- * resource.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class OTSResourceWrapper implements Resource
-{
- // Private field -------------------------------------------------
-
- /**
- * The wrapped OTS resource.
- */
- private org.omg.CosTransactions.Resource otsResource;
-
- // Constructor ---------------------------------------------------
-
- /**
- * Creates an <code>OTSResourceWrapper</code> for a given OTS resource.
- * @param otsResource the OTS resource to be wrapped.
- */
- public OTSResourceWrapper(org.omg.CosTransactions.Resource otsResource)
- {
- this.otsResource = otsResource;
- }
-
- // Attribute -----------------------------------------------------
-
- public org.omg.CosTransactions.Resource getWrappedResource()
- {
- return otsResource;
- }
-
- // Conversion to string ------------------------------------------
-
- public String toString()
- {
- return CorbaORB.getInstance().object_to_string(otsResource);
- }
-
- // Static --------------------------------------------------------
-
- public static OTSResourceWrapper fromString(String s)
- {
- org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(s);
- org.omg.CosTransactions.Resource otsRes =
- org.omg.CosTransactions.ResourceHelper.narrow(obj);
- return new OTSResourceWrapper(otsRes);
- }
-
- // org.jboss.tm.remoting.interfaces.Resource methods -------------
-
- /**
- * Calls <code>prepare</code> on the wrapped OTS resource.
- * @see org.jboss.tm.remoting.interfaces.Resource#prepare()
- */
- public Vote prepare()
- throws RemoteException,
- TransactionAlreadyPreparedException,
- HeuristicMixedException,
- HeuristicHazardException
- {
- try
- {
- org.omg.CosTransactions.Vote otsVote = otsResource.prepare();
- if (otsVote == org.omg.CosTransactions.Vote.VoteCommit)
- return Vote.COMMIT;
- else if (otsVote == org.omg.CosTransactions.Vote.VoteReadOnly)
- return Vote.READONLY;
- else // (otsVote == org.omg.CosTransactions.Vote.VoteRollback)
- return Vote.ROLLBACK;
- }
- catch (org.omg.CosTransactions.HeuristicMixed hm)
- {
- throw new HeuristicMixedException();
- }
- catch (org.omg.CosTransactions.HeuristicHazard hz)
- {
- throw new HeuristicHazardException();
- }
- catch (org.omg.CORBA.BAD_INV_ORDER bio)
- {
- throw new TransactionAlreadyPreparedException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>rollback</code> on the wrapper OTS resource.
- * @see org.jboss.tm.remoting.interfaces.Resource#rollback()
- */
- public void rollback()
- throws RemoteException,
- HeuristicCommitException,
- HeuristicMixedException,
- HeuristicHazardException
- {
- try
- {
- otsResource.rollback();
- }
- catch (org.omg.CosTransactions.HeuristicCommit hc)
- {
- throw new HeuristicCommitException();
- }
- catch (org.omg.CosTransactions.HeuristicMixed hm)
- {
- throw new HeuristicMixedException();
- }
- catch (org.omg.CosTransactions.HeuristicHazard hz)
- {
- throw new HeuristicHazardException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>commit</code> on the wrapped OTS resource.
- * @see org.jboss.tm.remoting.interfaces.Resource#commit()
- */
- public void commit() throws RemoteException,
- TransactionNotPreparedException, HeuristicRollbackException,
- HeuristicMixedException, HeuristicHazardException
- {
- try
- {
- otsResource.commit();
- }
- catch (org.omg.CosTransactions.NotPrepared np)
- {
- throw new TransactionNotPreparedException();
- }
- catch (org.omg.CosTransactions.HeuristicRollback hr)
- {
- throw new HeuristicRollbackException();
- }
- catch (org.omg.CosTransactions.HeuristicMixed hm)
- {
- throw new HeuristicMixedException();
- }
- catch (org.omg.CosTransactions.HeuristicHazard hz)
- {
- throw new HeuristicHazardException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>commit_one_phase</code> on the wrapped OTS resource.
- * @see org.jboss.tm.remoting.interfaces.Resource#commitOnePhase()
- */
- public void commitOnePhase() throws RemoteException,
- HeuristicHazardException
- {
- try
- {
- otsResource.commit_one_phase();
- }
- catch (org.omg.CosTransactions.HeuristicHazard hz)
- {
- throw new HeuristicHazardException();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>forget</code> on the wrapped OTS resource.
- * @see org.jboss.tm.remoting.interfaces.Resource#forget()
- */
- public void forget() throws RemoteException
- {
- try
- {
- otsResource.forget();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSSynchronizationWrapper.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSSynchronizationWrapper.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/OTSSynchronizationWrapper.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,117 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.wrapper;
-
-import java.rmi.RemoteException;
-
-import org.jboss.iiop.CorbaORB;
-import org.jboss.tm.remoting.interfaces.Status;
-import org.jboss.tm.remoting.interfaces.Synchronization;
-
-/**
- * Implements <code>org.jboss.tm.remoting.interfaces.Synchronization</code> by
- * wrapping an OTS synchronization and forwarding all method calls to the
- * wrapped synchronization.
- *
- * @author <a href="mailto:reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class OTSSynchronizationWrapper implements Synchronization
-{
- // Private field -------------------------------------------------
-
- /**
- * The wrapped OTS synchronization.
- */
- private org.omg.CosTransactions.Synchronization otsSynchronization;
-
- // Constructor ---------------------------------------------------
-
- /**
- * Creates an <code>OTSSynchronizationWrapper</code> for a given OTS
- * synchronization.
- * @param otsSynchronization the OTS synchronization to be wrapped.
- */
- public OTSSynchronizationWrapper(org.omg.CosTransactions.Synchronization otsSynchronization)
- {
- this.otsSynchronization = otsSynchronization;
- }
-
- // Attribute -----------------------------------------------------
-
- public org.omg.CosTransactions.Synchronization getWrappedSynchronization()
- {
- return otsSynchronization;
- }
-
- // Conversion to string ------------------------------------------
-
- public String toString()
- {
- return CorbaORB.getInstance().object_to_string(otsSynchronization);
- }
-
- // Static --------------------------------------------------------
-
- public static OTSSynchronizationWrapper fromString(String s)
- {
- org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(s);
- org.omg.CosTransactions.Synchronization otsSynch =
- org.omg.CosTransactions.SynchronizationHelper.narrow(obj);
- return new OTSSynchronizationWrapper(otsSynch);
- }
-
- // org.jboss.tm.remoting.interfaces.Synchronization methods ------
-
- /**
- * Calls <code>before_completion</code> on the wrapped OTS synchronization.
- * @see org.jboss.tm.remoting.interfaces.Synchronization#beforeCompletion()
- */
- public void beforeCompletion() throws RemoteException
- {
- try
- {
- otsSynchronization.before_completion();
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
- /**
- * Calls <code>after_completion</code> on the wrapped OTS synchronization.
- * @see org.jboss.tm.remoting.interfaces.Synchronization#afterCompletion()
- */
- public void afterCompletion(Status s) throws RemoteException
- {
- try
- {
- otsSynchronization.after_completion(Util.jbossToCosTransactions(s));
- }
- catch (org.omg.CORBA.SystemException se)
- {
- throw javax.rmi.CORBA.Util.mapSystemException(se);
- }
- }
-
-}
Deleted: trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/Util.java
===================================================================
--- trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/Util.java 2007-10-03 21:28:29 UTC (rev 65811)
+++ trunk/iiop/src/main/org/jboss/tm/iiop/wrapper/Util.java 2007-10-03 21:43:20 UTC (rev 65812)
@@ -1,65 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
-package org.jboss.tm.iiop.wrapper;
-
-import org.jboss.tm.remoting.interfaces.Status;
-
-/**
- * Utility class with methods for converting between
- * <code>org.jboss.tm.remoting.interfaces.Status</code> and
- * <code>org.omg.CosTransactions.Status</code> instances.
- *
- * @author <a href="mailto)reverbel at ime.usp.br">Francisco Reverbel</a>
- * @version $Revision$
- */
-public class Util
-{
- // Enforce non-instantiability.
- private Util()
- {
- }
-
- /**
- * Converts an <code>org.jboss.tm.remoting.interfaces.Status</code> instance
- * into an <code>org.omg.CosTransactions.Status</code> instance.
- * @param s the <code>org.jboss.tm.remoting.interfaces.Status</code> instance
- * @return the corresponding <code>org.omg.CosTransactions.Status</code>
- * instance.
- */
- public static final org.omg.CosTransactions.Status jbossToCosTransactions(Status s)
- {
- return org.omg.CosTransactions.Status.from_int(s.toInteger());
- }
-
- /**
- * Converts an <code>org.omg.CosTransactions.Status</code> instance
- * into an <code>org.jboss.tm.remoting.interfaces.Status</code> instance.
- * @param s the <code>org.omg.CosTransactions.Status</code> instance
- * @return the corresponding
- * <code>org.jboss.tm.remoting.interfaces.Status</code>
- * instance.
- */
- public static final Status cosTransactionsToJBoss(org.omg.CosTransactions.Status s)
- {
- return Status.fromInteger(s.value());
- }
-}
More information about the jboss-cvs-commits
mailing list