1 23 24 28 50 package com.sun.jts.CosTransactions; 51 52 54 import org.omg.CORBA.*; 55 import org.omg.PortableServer.*; 56 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 57 import org.omg.PortableServer.POAPackage.ServantNotActive ; 58 import org.omg.CosTransactions.*; 59 60 import java.util.logging.Logger ; 61 import java.util.logging.Level ; 62 import com.sun.logging.LogDomains; 63 import com.sun.jts.utils.LogFormatter; 64 65 78 85 class CoordinatorSynchronizationImpl extends SynchronizationPOA { 86 87 private static POA poa = null; 88 private Synchronization thisRef = null; 89 90 private Long localTID = null; 91 private TopCoordinator coordinator = null; 92 95 static Logger _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER); 96 97 105 CoordinatorSynchronizationImpl() { 106 } 107 108 117 CoordinatorSynchronizationImpl( TopCoordinator coord ) { 118 119 121 coordinator = coord; 122 try { 123 localTID = new Long (coord.getLocalTID()); 124 } catch( SystemException exc ) {} 125 126 } 127 128 136 public void finalize() { 137 138 coordinator = null; 139 140 } 141 142 153 public void before_completion() 154 throws SystemException { 155 156 158 if( coordinator == null ) { 159 INTERNAL exc = new INTERNAL(MinorCode.NoCoordinator, 160 CompletionStatus.COMPLETED_NO); 161 throw exc; 162 } 163 164 166 coordinator.beforeCompletion(); 167 168 } 169 170 181 public void after_completion( Status status ) 182 throws SystemException { 183 184 186 if( coordinator == null ) { 187 INTERNAL exc = new INTERNAL(MinorCode.NoCoordinator, 188 CompletionStatus.COMPLETED_NO); 189 throw exc; 190 } 191 192 195 coordinator.afterCompletion(status); 196 destroy(); 197 198 } 199 200 208 Synchronization object() { 209 if( poa == null ) poa = Configuration.getPOA("transient"); 210 if( thisRef == null ) { 211 if( poa == null ) 212 poa = Configuration.getPOA("transient"); 213 214 try { 215 poa.activate_object(this); 216 thisRef = SynchronizationHelper. 217 narrow(poa.servant_to_reference(this)); 218 } catch( ServantAlreadyActive saexc ) { 220 _logger.log(Level.SEVERE, 221 "jts.create_CoordinatorSynchronization_object_error"); 222 String msg = LogFormatter.getLocalizedMessage(_logger, 223 "jts.create_CoordinatorSynchronization_object_error"); 224 throw new org.omg.CORBA.INTERNAL (msg); 225 } catch( ServantNotActive snexc ) { 226 _logger.log(Level.SEVERE, 227 "jts.create_CoordinatorSynchronization_object_error"); 228 String msg = LogFormatter.getLocalizedMessage(_logger, 229 "jts.create_CoordinatorSynchronization_object_error"); 230 throw new org.omg.CORBA.INTERNAL (msg); 231 } catch( Exception exc ) { 232 _logger.log(Level.SEVERE, 233 "jts.create_CoordinatorSynchronization_object_error"); 234 String msg = LogFormatter.getLocalizedMessage(_logger, 235 "jts.create_CoordinatorSynchronization_object_error"); 236 throw new org.omg.CORBA.INTERNAL (msg); 237 } 238 } 239 240 return thisRef; 241 } 242 243 251 void destroy() { 252 if( poa != null && 253 thisRef != null ) 254 try { 255 poa.deactivate_object(poa.reference_to_id(thisRef)); 256 thisRef = null; 257 } catch( Exception exc ) { 258 _logger.log(Level.WARNING,"jts.object_destroy_error", 259 "CoordinatorResource"); 260 } 261 262 finalize(); 263 } 264 265 274 synchronized static final CoordinatorSynchronizationImpl servant(Synchronization sync) { 275 CoordinatorSynchronizationImpl result = null; 276 277 if (sync != null && Configuration.getProxyChecker().isProxy(sync)) { 281 return result; 282 } 283 284 if (sync instanceof CoordinatorSynchronizationImpl ) { 285 result = (CoordinatorSynchronizationImpl) sync; 286 } else if (poa != null) { 287 try { 288 result = (CoordinatorSynchronizationImpl) poa.reference_to_servant(sync); 289 if( result.thisRef == null ) 290 result.thisRef = sync; 291 } catch( Exception exc ) { 292 _logger.log(Level.WARNING,"jts.cannot_locate_servant", 293 "CoordinatorSynchronization"); 294 } 295 } 296 297 return result; 298 } 299 } 300 | Popular Tags |