FileDocCategorySizeDatePackage
SynchronizationImpl.javaAPI DocGlassfish v2 API9096Fri May 04 22:36:40 BST 2007com.sun.jts.jta

SynchronizationImpl

public class SynchronizationImpl extends SynchronizationPOA implements org.omg.CosTransactions.Synchronization
An implementation of org.omg.CosTransactions.Synchronization this object is activated at creation time and de-activated when after_completion is called
author
Tony Ng

Fields Summary
private Vector
syncs
private Vector
interposedSyncs
private org.omg.PortableServer.POA
poa
private org.omg.CosTransactions.Synchronization
corbaRef
private TransactionState
state
static Logger
_logger
private static org.omg.CORBA.NO_IMPLEMENT
no_implement
Constructors Summary
public SynchronizationImpl()


      
        syncs = new Vector();
        interposedSyncs = new Vector();
        poa = Configuration.getPOA("transient"/*#Frozen*/);
    
public SynchronizationImpl(TransactionState state)

        this();
        this.state = state;
    
Methods Summary
public Request_create_request(Context ctx, java.lang.String operation, NVList arg_list, NamedValue result)

        throw no_implement;
    
public Request_create_request(Context ctx, java.lang.String operation, NVList arg_list, NamedValue result, ExceptionList exceptions, ContextList contexts)

        throw no_implement;
    
public org.omg.CORBA.Object_duplicate()



       
        throw no_implement;
    
public org.omg.CORBA.DomainManager[]_get_domain_managers()

        throw no_implement;
    
public org.omg.CORBA.Object_get_interface_def()

        throw no_implement;
    
public org.omg.CORBA.Policy_get_policy(int policy_type)

        throw no_implement;
    
public int_hash(int maximum)

        throw no_implement;
    
public boolean_is_a(java.lang.String repository_id)

        throw no_implement;
    
public boolean_is_equivalent(org.omg.CORBA.Object that)

        throw no_implement;
    
public boolean_non_existent()

        throw no_implement;
    
public void_release()

        throw no_implement;
    
public Request_request(java.lang.String operation)

        throw no_implement;
    
public org.omg.CORBA.Object_set_policy_override(org.omg.CORBA.Policy[] policies, org.omg.CORBA.SetOverrideType set_add)

        throw no_implement;
    
public voidaddSynchronization(javax.transaction.Synchronization sync, boolean interposed)

        if (!interposed)
            syncs.addElement(sync);
        else
            interposedSyncs.addElement(sync);
    
public voidafter_completion(Status status)

        try {
            int result = TransactionManagerImpl.mapStatus(status);
            // Interposed Syncs First and then the regular syncs
            Enumeration e1 = interposedSyncs.elements();
            while (e1.hasMoreElements()) {
                Synchronization sync = (Synchronization) e1.nextElement();
                try {
                    sync.afterCompletion(result);
                } catch (Exception ex) {
					_logger.log(Level.WARNING,
							"jts.unexpected_error_occurred_in_after_completion",ex);
                }
            }
            Enumeration e = syncs.elements();
            while (e.hasMoreElements()) {
                Synchronization sync = (Synchronization) e.nextElement();
                try {
                    sync.afterCompletion(result);
                } catch (Exception ex) {
					_logger.log(Level.WARNING,
							"jts.unexpected_error_occurred_in_after_completion",ex);
                }
            }
        } finally {
            try {
                // deactivate object
                if (corbaRef != null) {
                    if (poa == null) {
                        poa = Configuration.getPOA("transient"/*#Frozen*/);
                    }
                    poa.deactivate_object(poa.reference_to_id(corbaRef));
                }
            } catch (Exception ex) {
				_logger.log(Level.WARNING,
						"jts.unexpected_error_occurred_in_after_completion",ex);
            }
        }
    
public voidbefore_completion()

        // Regular syncs first then the interposed syncs
        Enumeration e = syncs.elements();
        while (e.hasMoreElements()) {
            Synchronization sync = (Synchronization) e.nextElement();
            try {
                sync.beforeCompletion();
            } catch (RuntimeException rex) {
                try {
                    state.setRollbackOnly();
                } catch (Exception ex1) {
		    _logger.log(Level.WARNING,
		        "jts.unexpected_error_occurred_in_after_completion",ex1);
                }
		_logger.log(Level.WARNING,
		    "jts.unexpected_error_occurred_in_after_completion",rex);
            } catch (Exception ex) {
				_logger.log(Level.WARNING,
						"jts.unexpected_error_occurred_in_after_completion",ex);
            }
        }
        Enumeration e1 = interposedSyncs.elements();
        while (e1.hasMoreElements()) {
            Synchronization sync = (Synchronization) e1.nextElement();
            try {
                sync.beforeCompletion();
            } catch (RuntimeException rex) {
                try {
                    state.setRollbackOnly();
                } catch (Exception ex1) {
		    _logger.log(Level.WARNING,
		        "jts.unexpected_error_occurred_in_after_completion",ex1);
                }
		_logger.log(Level.WARNING,
		    "jts.unexpected_error_occurred_in_after_completion",rex);
            } catch (Exception ex) {
				_logger.log(Level.WARNING,
						"jts.unexpected_error_occurred_in_after_completion",ex);
            }
        }
        state.beforeCompletion();
    
public org.omg.CosTransactions.SynchronizationgetCORBAReference()

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

        if (corbaRef == null) {
            try {
                poa.activate_object(this);
                corbaRef = SynchronizationHelper.narrow(
                            poa.servant_to_reference(this));
                //corbaRef = (org.omg.CosTransactions.Synchronization) this;
            } catch (Exception ex) {
				_logger.log(Level.SEVERE,
						"jts.unexpected_error_in_getcorbareference",ex);
            }
        }

        return corbaRef;