FileDocCategorySizeDatePackage
CoordinatorSynchronizationImpl.javaAPI DocGlassfish v2 API10153Wed Jun 13 23:03:46 BST 2007com.sun.jts.CosTransactions

CoordinatorSynchronizationImpl

public class CoordinatorSynchronizationImpl extends SynchronizationPOA
The CoordinatorSynchronizationImpl interface allows a subordinate Coordinator to be informed of the completion of a transaction, both before the transaction is prepared, and after it is committed or rolled back. Every Synchronization object registered with the subordinate should be called before the operation returns to the superior. An instance of this class should be accessed from only one thread within a process.
version
0.01
author
Simon Holdsworth, IBM Corporation
see

Fields Summary
private static POA
poa
private Synchronization
thisRef
private Long
localTID
private TopCoordinator
coordinator
static Logger
_logger
Constructors Summary
CoordinatorSynchronizationImpl()
Default CoordinatorSynchronizationImpl constructor.

param
return
see


              
     
    
CoordinatorSynchronizationImpl(TopCoordinator coord)
Sets up a new CoordinatorSynchronizationImpl object with the Coordinator reference so that it can pass on synchronization requests.

param
coord The Coordinator for the transaction.
return
see


        // Set the instance variables to the values passed in.

        coordinator = coord;
        try {
            localTID = new Long(coord.getLocalTID()); 
        } catch( SystemException exc ) {}

    
Methods Summary
public voidafter_completion(Status status)
Passes on the after completion operation to the Coordinator.

param
status The state of the transaction.
return
exception
SystemException The operation failed. The minor code provides a reason for the failure.
see


        // If there is no Coordinator reference, raise an exception.

        if( coordinator == null ) {
            INTERNAL exc = new INTERNAL(MinorCode.NoCoordinator,
                                        CompletionStatus.COMPLETED_NO);
            throw exc;
        }

        // Pass the after completion operation on to the coordinator.
        // Destroy myself.

        coordinator.afterCompletion(status);
        destroy();

    
public voidbefore_completion()
Passes on the before completion operation to the Coordinator.

param
return
exception
SystemException The operation failed. The minor code provides a reason for the failure.
see


        // If there is no Coordinator reference, raise an exception.

        if( coordinator == null ) {
            INTERNAL exc = new INTERNAL(MinorCode.NoCoordinator,
                                        CompletionStatus.COMPLETED_NO);
            throw exc;
        }

        // Pass the before completion operation on to the coordinator.

        coordinator.beforeCompletion();

    
voiddestroy()
Destroys the CoordinatorSynchronizationImpl object.

param
return
see

        if( poa != null &&
            thisRef != null )
            try {
                poa.deactivate_object(poa.reference_to_id(thisRef));
                thisRef = null;
            } catch( Exception exc ) {
				 _logger.log(Level.WARNING,"jts.object_destroy_error",
				 		"CoordinatorResource");
            }

        //finalize();
        coordinator = null;
    
Synchronizationobject()
Returns the CORBA Object which represents this object.

param
return
The CORBA object.
see

        if( poa == null ) poa = Configuration.getPOA("transient"/*#Frozen*/);
        if( thisRef == null ) {
            if( poa == null )
                poa = Configuration.getPOA("transient"/*#Frozen*/);

            try {
                poa.activate_object(this);
                thisRef = SynchronizationHelper.
                            narrow(poa.servant_to_reference(this));
                //thisRef = (Synchronization)this;
            } catch( ServantAlreadyActive saexc ) {
				_logger.log(Level.SEVERE,
						"jts.create_CoordinatorSynchronization_object_error");
				 String msg = LogFormatter.getLocalizedMessage(_logger,
	 						  "jts.create_CoordinatorSynchronization_object_error");
				  throw  new org.omg.CORBA.INTERNAL(msg);
            } catch( ServantNotActive snexc ) {
				_logger.log(Level.SEVERE,
						"jts.create_CoordinatorSynchronization_object_error");
				 String msg = LogFormatter.getLocalizedMessage(_logger,
	 						  "jts.create_CoordinatorSynchronization_object_error");
				  throw  new org.omg.CORBA.INTERNAL(msg);
            } catch( Exception exc ) {
				_logger.log(Level.SEVERE,
						"jts.create_CoordinatorSynchronization_object_error");
				 String msg = LogFormatter.getLocalizedMessage(_logger,
	 						  "jts.create_CoordinatorSynchronization_object_error");
				  throw  new org.omg.CORBA.INTERNAL(msg);
            }
        }

        return thisRef;
    
static final synchronized com.sun.jts.CosTransactions.CoordinatorSynchronizationImplservant(Synchronization sync)
Returns the CoordinatorSynchronizationImpl which serves the given object.

param
The CORBA Object.
return
The CoordinatorSynchronizationImpl object which serves it.
see

        CoordinatorSynchronizationImpl result = null;

        // we will not be able to obtain the
        // servant from our local POA for a proxy sync object.
        // so return null
        if (sync != null && Configuration.getProxyChecker().isProxy(sync)) {
            return result;
        }

        if (sync instanceof CoordinatorSynchronizationImpl ) {
            result = (CoordinatorSynchronizationImpl) sync;
        } else if (poa != null) {
            try {
                result = (CoordinatorSynchronizationImpl) poa.reference_to_servant(sync);
                if( result.thisRef == null )
                    result.thisRef = sync;
            } catch( Exception exc ) {
			    _logger.log(Level.WARNING,"jts.cannot_locate_servant",
							"CoordinatorSynchronization");
            }
        }

        return result;