1 22 package org.jboss.tm.iiop.wrapper; 23 24 import java.rmi.RemoteException ; 25 26 import org.jboss.iiop.CorbaORB; 27 import org.jboss.tm.GlobalId; 28 import org.jboss.tm.remoting.interfaces.Coordinator; 29 import org.jboss.tm.remoting.interfaces.RecoveryCoordinator; 30 import org.jboss.tm.remoting.interfaces.Resource; 31 import org.jboss.tm.remoting.interfaces.Status; 32 import org.jboss.tm.remoting.interfaces.Synchronization; 33 import org.jboss.tm.remoting.interfaces.SynchronizationUnavailableException; 34 import org.jboss.tm.remoting.interfaces.TransactionInactiveException; 35 import org.jboss.tm.remoting.interfaces.TxPropagationContext; 36 37 45 public class OTSCoordinatorWrapper implements Coordinator 46 { 47 48 50 53 private org.omg.CosTransactions.Coordinator otsCoordinator; 54 55 57 61 public OTSCoordinatorWrapper( 62 org.omg.CosTransactions.Coordinator otsCoordinator) 63 { 64 this.otsCoordinator = otsCoordinator; 65 } 66 67 69 public org.omg.CosTransactions.Coordinator getWrappedCoordinator() 70 { 71 return otsCoordinator; 72 } 73 74 76 public String toString() 77 { 78 return CorbaORB.getInstance().object_to_string(otsCoordinator); 79 } 80 81 83 public static OTSCoordinatorWrapper fromString(String s) 84 { 85 org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(s); 86 org.omg.CosTransactions.Coordinator otsCoord = 87 org.omg.CosTransactions.CoordinatorHelper.narrow(obj); 88 return new OTSCoordinatorWrapper(otsCoord); 89 } 90 91 93 97 public Status getStatus() throws RemoteException 98 { 99 try 100 { 101 return Util.cosTransactionsToJBoss(otsCoordinator.get_status()); 102 } 103 catch (org.omg.CORBA.SystemException se) 104 { 105 throw javax.rmi.CORBA.Util.mapSystemException(se); 106 } 107 } 108 109 113 public boolean isSameTransaction(Coordinator c) throws RemoteException 114 { 115 try 116 { 117 org.omg.CosTransactions.Coordinator otherOtsCoord = 118 ((OTSCoordinatorWrapper) c).getWrappedCoordinator(); 119 return otsCoordinator.is_same_transaction(otherOtsCoord); 120 } 121 catch (org.omg.CORBA.SystemException se) 122 { 123 throw javax.rmi.CORBA.Util.mapSystemException(se); 124 } 125 } 126 127 131 public int hashTransaction() throws RemoteException 132 { 133 try 134 { 135 return otsCoordinator.hash_transaction(); 136 } 137 catch (org.omg.CORBA.SystemException se) 138 { 139 throw javax.rmi.CORBA.Util.mapSystemException(se); 140 } 141 } 142 143 147 public RecoveryCoordinator registerResource(Resource r) 148 throws RemoteException , TransactionInactiveException 149 { 150 try 151 { 152 org.omg.CosTransactions.Resource otsResource = 153 ((OTSResourceWrapper) r).getWrappedResource(); 154 org.omg.CosTransactions.RecoveryCoordinator otsRecCoord = 155 otsCoordinator.register_resource(otsResource); 156 return new OTSRecoveryCoordinatorWrapper(otsRecCoord); 157 } 158 catch (org.omg.CosTransactions.Inactive i) 159 { 160 throw new TransactionInactiveException(); 161 } 162 catch (org.omg.CORBA.SystemException se) 163 { 164 throw javax.rmi.CORBA.Util.mapSystemException(se); 165 } 166 } 167 168 173 public void registerSynchronization(Synchronization sync) 174 throws RemoteException , 175 TransactionInactiveException, 176 SynchronizationUnavailableException 177 { 178 try 179 { 180 org.omg.CosTransactions.Synchronization otsSynch = 181 ((OTSSynchronizationWrapper) sync).getWrappedSynchronization(); 182 otsCoordinator.register_synchronization(otsSynch); 183 } 184 catch (org.omg.CosTransactions.Inactive i) 185 { 186 throw new TransactionInactiveException(); 187 } 188 catch (org.omg.CosTransactions.SynchronizationUnavailable sa) 189 { 190 throw new SynchronizationUnavailableException(); 191 } 192 catch (org.omg.CORBA.SystemException se) 193 { 194 throw javax.rmi.CORBA.Util.mapSystemException(se); 195 } 196 } 197 198 202 public void rollbackOnly() throws RemoteException , 203 TransactionInactiveException 204 { 205 try 206 { 207 otsCoordinator.rollback_only(); 208 } 209 catch (org.omg.CosTransactions.Inactive i) 210 { 211 throw new TransactionInactiveException(); 212 } 213 catch (org.omg.CORBA.SystemException se) 214 { 215 throw javax.rmi.CORBA.Util.mapSystemException(se); 216 } 217 } 218 219 223 public TxPropagationContext getTransactionContext() throws RemoteException 224 { 225 throw new UnsupportedOperationException (); 226 } 227 228 232 public GlobalId getTransactionId() throws RemoteException 233 { 234 throw new UnsupportedOperationException (); 235 } 236 237 } 238 | Popular Tags |