1 23 24 28 29 51 package com.sun.jts.CosTransactions; 52 53 import org.omg.CORBA.*; 54 import org.omg.PortableServer.*; 55 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 56 import org.omg.PortableServer.POAPackage.ServantNotActive ; 57 import org.omg.CosTransactions.*; 58 import java.util.logging.Logger ; 59 import java.util.logging.Level ; 60 import com.sun.logging.LogDomains; 61 import com.sun.jts.utils.LogFormatter; 62 76 77 84 class TerminatorImpl extends TerminatorPOA implements Terminator { 85 86 private static POA poa = null; 87 private org.omg.CosTransactions.Terminator thisRef = null; 88 89 CoordinatorTerm coordTerm = null; 90 91 ControlImpl control = null; 93 96 static Logger _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER); 97 106 TerminatorImpl() {} 107 108 120 TerminatorImpl (CoordinatorImpl coordinator, boolean subtran) { 121 122 124 coordTerm = new CoordinatorTerm(coordinator, subtran); 125 } 126 127 132 void setControl(ControlImpl control) { 133 134 this.control = control; 135 } 136 137 146 synchronized public void finalize() { 147 148 if (coordTerm != null) { 149 coordTerm.finalize(); 150 coordTerm = null; 151 } 152 } 153 154 158 private void PreCompletionCheck() 159 throws TRANSACTION_ROLLEDBACK, INVALID_TRANSACTION { 160 161 162 163 StatusHolder status = new StatusHolder(); 164 Long localTID = new Long (control.getLocalTID(status)); 165 166 168 if (status.value != Status.StatusActive) { 169 170 if( status.value == Status.StatusRolledBack) { 171 TRANSACTION_ROLLEDBACK exc = 172 new TRANSACTION_ROLLEDBACK(0, 173 CompletionStatus.COMPLETED_NO); 174 throw exc; 175 } 176 177 INVALID_TRANSACTION exc = 178 new INVALID_TRANSACTION(MinorCode.Completed, 179 CompletionStatus.COMPLETED_NO); 180 throw exc; 181 } 182 183 if (control.isOutgoing()) { 187 188 INVALID_TRANSACTION exc = 189 new INVALID_TRANSACTION(MinorCode.DeferredActivities, 190 CompletionStatus.COMPLETED_NO); 191 throw exc; 192 } 193 } 194 195 220 synchronized public void commit(boolean reportHeuristics) 221 throws HeuristicMixed, HeuristicHazard, TRANSACTION_ROLLEDBACK { 222 223 PreCompletionCheck(); 225 226 229 233 try { 234 coordTerm.commit(!reportHeuristics); 235 } catch (HeuristicMixed exc) { 236 if (reportHeuristics) { 237 control.destroy(); throw exc; 239 } 240 } catch (HeuristicHazard exc) { 241 if (reportHeuristics) { 242 control.destroy(); throw exc; 244 } 245 } catch (TRANSACTION_ROLLEDBACK exc) { 246 control.destroy(); throw exc; 248 } catch(LogicErrorException exc) { 249 control.destroy(); INTERNAL ex2 = new INTERNAL(MinorCode.LogicError, 251 CompletionStatus.COMPLETED_NO); 252 throw ex2; 253 } catch (INTERNAL exc) { control.destroy(); 255 throw (INTERNAL) exc; 256 } 257 258 control.destroy(); } 260 261 279 public void rollback() throws SystemException { 280 281 PreCompletionCheck(); 283 284 288 try { 289 coordTerm.rollback(); 290 } catch (HeuristicMixed exc) { 291 control.destroy(); } catch (HeuristicHazard exc) { 293 control.destroy(); } catch (TRANSACTION_ROLLEDBACK exc) { 295 control.destroy(); throw exc; 297 } catch (LogicErrorException exc) { 298 control.destroy(); INTERNAL ex2 = new INTERNAL(MinorCode.LogicError, 300 CompletionStatus.COMPLETED_NO); 301 throw ex2; 302 } catch (INTERNAL exc) { control.destroy(); 304 throw (INTERNAL) exc; 305 } 306 307 control.destroy(); 309 } 310 311 320 synchronized final Terminator object() { 321 if (thisRef == null) { 322 if (poa == null) { 323 poa = Configuration.getPOA("transient"); 324 } 325 326 try { 327 poa.activate_object(this); 328 thisRef = 329 TerminatorHelper.narrow(poa.servant_to_reference(this)); 330 } catch(ServantAlreadyActive saexc) { 332 _logger.log(Level.SEVERE,"jts.create_terminator_object_error",saexc); 333 String msg = LogFormatter.getLocalizedMessage(_logger, 334 "jts.create_terminator_object_error"); 335 throw new org.omg.CORBA.INTERNAL (msg); 336 } catch(ServantNotActive snexc) { 337 _logger.log(Level.SEVERE,"jts.create_terminator_object_error",snexc); 338 String msg = LogFormatter.getLocalizedMessage(_logger, 339 "jts.create_terminator_object_error"); 340 throw new org.omg.CORBA.INTERNAL (msg); 341 } catch(Exception exc) { 342 _logger.log(Level.SEVERE,"jts.create_terminator_object_error",exc); 343 String msg = LogFormatter.getLocalizedMessage(_logger, 344 "jts.create_terminator_object_error"); 345 throw new org.omg.CORBA.INTERNAL (msg); 346 } 347 } 348 349 return thisRef; 350 } 351 352 361 synchronized final void destroy() { 362 if (poa != null && thisRef != null) { 363 try { 364 poa.deactivate_object(poa.reference_to_id(thisRef)); 365 thisRef = null; 366 } catch (Exception exc) { 367 _logger.log(Level.WARNING,"jts.object_destroy_error","Terminator"); 368 } 369 } 370 371 finalize(); 372 } 373 374 379 380 public org.omg.CORBA.Object _duplicate() { 381 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 382 } 383 384 public void _release() { 385 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 386 } 387 388 public boolean _is_a(String repository_id) { 389 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 390 } 391 392 public boolean _is_equivalent(org.omg.CORBA.Object that) { 393 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 394 } 395 396 public boolean _non_existent() { 397 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 398 } 399 400 public int _hash(int maximum) { 401 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 402 } 403 404 public Request _request(String operation) { 405 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 406 } 407 408 public Request _create_request(Context ctx, 409 String operation, 410 NVList arg_list, 411 NamedValue result) { 412 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 413 } 414 415 public Request _create_request(Context ctx, 416 String operation, 417 NVList arg_list, 418 NamedValue result, 419 ExceptionList exceptions, 420 ContextList contexts) { 421 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 422 } 423 424 public org.omg.CORBA.Object _get_interface_def() { 425 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 426 } 427 428 public org.omg.CORBA.Policy _get_policy(int policy_type) { 429 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 430 } 431 432 public org.omg.CORBA.DomainManager [] _get_domain_managers() { 433 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 434 } 435 436 public org.omg.CORBA.Object _set_policy_override( 437 org.omg.CORBA.Policy [] policies, 438 org.omg.CORBA.SetOverrideType set_add) { 439 throw new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 440 } 441 } 442 | Popular Tags |