1 package org.jacorb.concurrency; 2 3 4 5 42 43 44 45 import org.omg.CosConcurrencyControl.*; 46 47 import org.omg.CosTransactions.*; 48 49 import org.omg.PortableServer.POA ; 50 51 import java.util.*; 52 53 54 public class LockSetFactoryImpl extends LockSetFactoryPOA { 55 56 public static final int REQUEST = 1; 57 58 public static final int SATISFIED = 2; 59 60 public static final int COMMIT = 3; 61 62 public static final int ROLLBACK = 4; 63 64 public static final int NO_TRANS = 5; 65 66 public static final int REJECT = 6; 67 68 69 70 71 72 private Hashtable coordinators = new Hashtable(); 73 74 private POA poa; 75 76 77 78 public LockSetFactoryImpl( POA poa ){ 79 80 this.poa = poa; 81 82 }; 83 84 85 86 87 88 public LockSet create(){ 89 90 throw new org.omg.CORBA.NO_IMPLEMENT (); 91 92 }; 93 94 95 96 public LockSet create_related(LockSet which){ 97 98 throw new org.omg.CORBA.NO_IMPLEMENT (); 99 100 }; 101 102 103 104 public TransactionalLockSet create_transactional(){ 105 106 TransactionalLockSetImpl ls = new TransactionalLockSetImpl( this ); 107 108 try { 109 110 return TransactionalLockSetHelper.narrow( poa.servant_to_reference( ls ) ); 111 112 } catch ( Exception e ){ 113 114 e.printStackTrace( System.out ); 115 116 throw new org.omg.CORBA.INTERNAL (); 117 118 } 119 120 }; 121 122 123 124 public TransactionalLockSet create_transactional_related(TransactionalLockSet which){ 125 126 TransactionalLockSetImpl ls = new TransactionalLockSetImpl( this ); 127 128 ls.add_related( which ); 129 130 try { 131 132 return TransactionalLockSetHelper.narrow( poa.servant_to_reference( ls ) ); 133 134 } catch ( Exception e ){ 135 136 e.printStackTrace( System.out ); 137 138 throw new org.omg.CORBA.INTERNAL (); 139 140 } 141 142 }; 143 144 145 146 synchronized TransactionCoordinator get_transaction_coordinator( Coordinator current ){ 147 148 if( coordinators.containsKey( current.get_transaction_name() ) ){ 149 150 return (TransactionCoordinator)coordinators.get( current.get_transaction_name() ); 151 152 } else { 153 154 TransactionCoordinator c = new TransactionCoordinator( this, current, poa ); 155 156 try { 157 158 Resource res = ResourceHelper.narrow( poa.servant_to_reference( c ) ); 159 160 current.register_resource( res ); 161 162 } catch ( Exception e ){ 163 164 e.printStackTrace( System.out ); 165 166 } 167 168 coordinators.put( current.get_transaction_name(), c ); 169 170 return c; 171 172 } 173 174 175 176 }; 177 178 179 180 synchronized void remove_me( TransactionCoordinator i_am ){ 181 182 coordinators.remove( i_am.get_coordinator() ); 183 184 try { 185 186 byte [] ObjId = poa.servant_to_id( i_am ); 187 188 poa.deactivate_object( ObjId ); 189 190 } catch ( Exception e ){ 191 192 e.printStackTrace( System.out ); 193 194 throw new org.omg.CORBA.INTERNAL (); 195 196 } 197 198 } 199 200 201 202 synchronized void remove_me( TransactionalLockSetImpl i_am ){ 203 204 Enumeration enumeration = coordinators.elements(); 205 206 while( enumeration.hasMoreElements() ){ 207 208 TransactionCoordinator tc = (TransactionCoordinator)enumeration.nextElement(); 209 210 tc.remove_coordinator( i_am ); 211 212 } 213 214 try { 215 216 byte [] ObjId = poa.servant_to_id( i_am ); 217 218 poa.deactivate_object( ObjId ); 219 220 } catch ( Exception e ){ 221 222 e.printStackTrace( System.out ); 223 224 throw new org.omg.CORBA.INTERNAL (); 225 226 } 227 228 }; 229 230 }; 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | Popular Tags |