FileDocCategorySizeDatePackage
RegisteredSyncs.javaAPI DocGlassfish v2 API8980Wed Jun 13 23:03:48 BST 2007com.sun.jts.CosTransactions

RegisteredSyncs

public class RegisteredSyncs extends Object
The RegisteredSyncs class provides operations that manage a set of Synchronization objects involved in a transaction. In order to avoid sending multiple synchronization requests to the same resource we require some way to perform Synchronization reference comparisons.
version
0.01
author
Simon Holdsworth, IBM Corporation
see

Fields Summary
private Vector
registered
static Logger
_logger
Constructors Summary
RegisteredSyncs()
Default RegisteredSyncs constructor.

param
return
see


               
     
Methods Summary
voidaddSync(Synchronization obj)
Adds a reference to a Synchronization object to the set.

If there is no such set then a new one is created with the single Synchronization reference.

param
obj The Synchronization object to be added.
return
see

        registered.addElement(obj);
    
voiddistributeAfter(Status status)
Distributes after completion operations to all registered Synchronization objects.

param
status Indicates whether the transaction committed.
return
see


        for (int i = 0; i < registered.size(); i++) {
            boolean isProxy = false;
            Synchronization sync = (Synchronization) registered.elementAt(i);

            // COMMENT(Ram J) the instanceof operation should be replaced
            // by a is_local() call, once the local object contract is
            // implemented.
            if (!(sync instanceof com.sun.jts.jta.SynchronizationImpl)) {
                isProxy = Configuration.getProxyChecker().isProxy(sync);
            }

            try {
 				if(_logger.isLoggable(Level.FINEST))
                {
					_logger.logp(Level.FINEST,"RegisterdSyncs","distributeAfter()",
							"Before invoking after_completion() on synchronization object " + sync);
                }

                sync.after_completion(status);

		 		if(_logger.isLoggable(Level.FINEST))
                {
					_logger.logp(Level.FINEST,"RegisterdSyncs","distributeAfter()",
							"After invoking after_completion() on"+
							"synchronization object"+ sync);
                }
            } catch (Throwable exc) {
                // Discard any exceptions at this point.
                if (exc instanceof OBJECT_NOT_EXIST ||
                        exc instanceof COMM_FAILURE) {
                    // ignore i.e., no need to log this error (Ram J)
                    // this can happen normally during after_completion flow,
                    // since remote sync objects would go away when the
                    // subordinate cleans up (i.e, the subordinate would have
                    // called afterCompletions locally before going away).
                } else {
					_logger.log(Level.WARNING,
							"jts.exception_in_synchronization_operation",
	                        new java.lang.Object[] { exc.toString(),
							"after_completion"});
                }
            }

            // Release the object if it is a proxy.
            if (isProxy) {
                sync._release();
            }
        }
    
booleandistributeBefore()
Distributes before completion operations to all registered Synchronization objects.

Returns a boolean to indicate success/failure.

param
return
Indicates success of the operation.
see


        boolean result = true;

        for (int i = 0; i < registered.size() && result == true; i++) {
            Synchronization sync = (Synchronization) registered.elementAt(i);
            try {
		 		if(_logger.isLoggable(Level.FINEST))
                {
					_logger.logp(Level.FINEST,"RegisterdSyncs","distributeBefore()",
							"Before invoking before_completion() on synchronization object " + sync);
                }

                sync.before_completion();

		 		if(_logger.isLoggable(Level.FINEST))
                {
					_logger.logp(Level.FINEST,"RegisterdSyncs","distributeBefore()", 
					 		 "After invoking before_completion() on synchronization object " + sync);
                }
            } catch (Throwable exc) {

                // Discard any exceptions at this point and return false.
                if (!(exc instanceof INVALID_TRANSACTION)) {
					_logger.log(Level.WARNING,
							"jts.exception_in_synchronization_operation",
		                    new java.lang.Object[] { exc.toString(),"before_completion"});
                }
                result = false;
            }
        }

        return result;
    
voidempty()
Empties the set of registered Synchronization objects.

param
return
see

        registered.removeAllElements();
    
booleaninvolved()
Checks whether there are any Synchronization objects registered.

If there are, the operation returns true, otherwise false.

param
return
Indicates whether any objects are registered.
see


        boolean result = (registered.size() != 0);
        return result;