com.sun.jts.CosTransactions
Class TopCoordinator

java.lang.Object
  extended by org.omg.PortableServer.Servant
      extended by com.sun.jts.codegen.otsidl.JCoordinatorPOA
          extended by com.sun.jts.CosTransactions.TopCoordinator
All Implemented Interfaces:
JCoordinator, JCoordinatorOperations, java.io.Serializable, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity, org.omg.CORBA.portable.InvokeHandler, org.omg.CosTransactions.Coordinator, org.omg.CosTransactions.CoordinatorOperations

public class TopCoordinator
extends JCoordinatorPOA

The TopCoordinator interface is our implementation of the standard Coordinator interface that is used for top-level transactions. It allows Resources to be registered for participation in a top-level transaction. In addition the TopCoordinator recovery interface can be used if the connection to a superior Coordinator is lost after a transaction is prepared. As an instance of this class may be accessed from multiple threads within a process, serialisation for thread-safety is necessary in the implementation. The information managed should be reconstructible in the case of a failure.

Version:
0.02
Author:
Simon Holdsworth, IBM Corporation
See Also:
, Serialized Form

Method Summary
 org.omg.CORBA.Request _create_request(org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result)
           
 org.omg.CORBA.Request _create_request(org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result, org.omg.CORBA.ExceptionList exceptions, org.omg.CORBA.ContextList contexts)
           
 org.omg.CORBA.Object _duplicate()
           
 org.omg.CORBA.DomainManager[] _get_domain_managers()
           
 org.omg.CORBA.Object _get_interface_def()
           
 org.omg.CORBA.Policy _get_policy(int policy_type)
           
 int _hash(int maximum)
           
 boolean _is_a(java.lang.String repository_id)
           
 boolean _is_equivalent(org.omg.CORBA.Object that)
           
 boolean _non_existent()
           
 void _release()
           
 org.omg.CORBA.Request _request(java.lang.String operation)
           
 org.omg.CORBA.Object _set_policy_override(org.omg.CORBA.Policy[] policies, org.omg.CORBA.SetOverrideType set_add)
           
 org.omg.CosTransactions.Control create_subtransaction()
          Creates a subtransaction and returns a Control object that represents the child transaction.
 void doFinalize()
          Cleans up the objects state.
 boolean equals(java.lang.Object other)
          Determines equality of the object with the parameter.
 org.omg.CosTransactions.Status get_parent_status()
          Gets the local state of the transaction.
 org.omg.CosTransactions.Status get_status()
          Returns the local status of the target transaction.
 org.omg.CosTransactions.Status get_top_level_status()
          Gets the local state of the transaction.
 java.lang.String get_transaction_name()
          removed synchronization at method level since only tranState requires locking
 org.omg.CosTransactions.PropagationContext get_txcontext()
          Creates a PropagationContext which contains the information which would normally be passed implicitly via the CosTSPropagation interfaces.
 org.omg.CosTransactions.TransIdentity[] getAncestors()
          Returns the sequence of ancestors of the transaction.
 GlobalTID getGlobalTid()
           
 org.omg.CosTransactions.otid_t getGlobalTID()
          Returns a global identifier that represents the TopCoordinator's transaction.
 long getLocalTID()
          Returns the internal identifier for the transaction.
 int getParticipantCount()
           
 int hash_top_level_tran()
          Returns a hash value based on the top-level ancestor of the transaction associated with the target object.
 int hash_transaction()
          removed synchronization at method level since only tranState requires locking
 int hashCode()
          Returns a hash code for the object.
 boolean is_ancestor_transaction(org.omg.CosTransactions.Coordinator other)
          Determines whether the target TopCoordinator is an ancestor of the given Coordinator.
 boolean is_descendant_transaction(org.omg.CosTransactions.Coordinator other)
          Determines whether the target TopCoordinator is a descendant of the given Coordinator.
 boolean is_related_transaction(org.omg.CosTransactions.Coordinator other)
          Determines whether the target TopCoordinator is related to the given Coordinator (i.e.
 boolean is_root_transaction()
          Determines whether this TopCoordinator is the root TopCoordinator.
 boolean is_same_transaction(org.omg.CosTransactions.Coordinator other)
          removed synchronization at method level since only tranState requires locking
 boolean is_top_level_transaction()
          Determines whether the target TopCoordinator represents a top-level (non-nested) transaction.
 boolean isRollbackOnly()
          Checks whether the TopCoordinator is marked rollback-only.
 org.omg.CosTransactions.RecoveryCoordinator register_resource(org.omg.CosTransactions.Resource res)
          Enables a Resource to be registered as a participant in the completion of the top-level transaction represented by the TopCoordinator.
 void register_subtran_aware(org.omg.CosTransactions.SubtransactionAwareResource sares)
          Enables a SubtransactionAwareResource to be registered as a participant in the completion of a subtransaction.
 void register_synchronization(org.omg.CosTransactions.Synchronization sync)
          Informs the TopCoordinator that the given object requires synchronization before and after completion of the transaction.
 void rollback_only()
          Ensures that the transaction represented by the target TopCoordinator cannot be committed.
 
Methods inherited from class com.sun.jts.codegen.otsidl.JCoordinatorPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doFinalize

public void doFinalize()
Cleans up the objects state.

Parameters:
-
See Also:

get_status

public org.omg.CosTransactions.Status get_status()
Returns the local status of the target transaction.

Specified by:
get_status in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The status of the transaction.
See Also:

get_parent_status

public org.omg.CosTransactions.Status get_parent_status()
Gets the local state of the transaction. For a top-level transaction this operation is equivalent to the get_status method. This operation references no instance variables and so can be implemented locally in the proxy class.

Specified by:
get_parent_status in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The status of the transaction.
See Also:

get_top_level_status

public org.omg.CosTransactions.Status get_top_level_status()
Gets the local state of the transaction. For a top-level transaction this operation is equivalent to the get_status method. This operation references no instance variables and so can be implemented locally in a proxy class.

Specified by:
get_top_level_status in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The status of the transaction.
See Also:

is_same_transaction

public boolean is_same_transaction(org.omg.CosTransactions.Coordinator other)
                            throws org.omg.CORBA.SystemException
removed synchronization at method level since only tranState requires locking

Specified by:
is_same_transaction in interface org.omg.CosTransactions.CoordinatorOperations
Throws:
org.omg.CORBA.SystemException

is_related_transaction

public boolean is_related_transaction(org.omg.CosTransactions.Coordinator other)
                               throws org.omg.CORBA.SystemException
Determines whether the target TopCoordinator is related to the given Coordinator (i.e. is a member of the same transaction family). For a top-level transaction returns TRUE if and only if the transaction associated with the parameter object is a descendant of the transaction associated with the target object. This operation references no instance variables and so can be implemented locally in a proxy class.

Specified by:
is_related_transaction in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
other - The other Coordinator.
Returns:
Indicates the relationship.
Throws:
org.omg.CORBA.SystemException - The other Coordinator could not be reached.
See Also:

is_root_transaction

public boolean is_root_transaction()
Determines whether this TopCoordinator is the root TopCoordinator. the given Coordinator (i.e. is a member of the same transaction family). For a root transaction, this method returns TRUE. Otherwise it returns FALSE.

Returns:
Indicates if this is the root TopCoordinator.
See Also:

is_ancestor_transaction

public boolean is_ancestor_transaction(org.omg.CosTransactions.Coordinator other)
                                throws org.omg.CORBA.SystemException
Determines whether the target TopCoordinator is an ancestor of the given Coordinator. For a top-level transaction returns TRUE if and only if the transaction associated with the target object is an ancestor of the transaction associated with the parameter object. This operation references no instance variables and so can be implemented locally in a proxy class.

Specified by:
is_ancestor_transaction in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
other - The other Coordinator.
Returns:
Indicates the relationship.
Throws:
org.omg.CORBA.SystemException - The other Coordinator could not be reached.
See Also:

is_descendant_transaction

public boolean is_descendant_transaction(org.omg.CosTransactions.Coordinator other)
                                  throws org.omg.CORBA.SystemException
Determines whether the target TopCoordinator is a descendant of the given Coordinator. For a top-level transaction returns TRUE if and only if the transaction associated with the target object is the same as the transaction associated with the parameter object. This operation references no instance variables and so can be implemented locally in a proxy class.

Specified by:
is_descendant_transaction in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
other - The other Coordinator.
Returns:
Indicates the relationship.
Throws:
org.omg.CORBA.SystemException - The other Coordinator could not be reached.
See Also:

is_top_level_transaction

public boolean is_top_level_transaction()
Determines whether the target TopCoordinator represents a top-level (non-nested) transaction.

For a top-level transaction returns TRUE.

This operation references no instance variables and so can be implemented locally in a proxy class.

Specified by:
is_top_level_transaction in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
Indicates this is a top-level transaction.
See Also:

hash_transaction

public int hash_transaction()
removed synchronization at method level since only tranState requires locking

Specified by:
hash_transaction in interface org.omg.CosTransactions.CoordinatorOperations

hash_top_level_tran

public int hash_top_level_tran()
Returns a hash value based on the top-level ancestor of the transaction associated with the target object. This operation references only the global TID, and so can be implemented locally in a proxy class.

Specified by:
hash_top_level_tran in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The hash value for the transaction.
See Also:

register_resource

public org.omg.CosTransactions.RecoveryCoordinator register_resource(org.omg.CosTransactions.Resource res)
                                                              throws org.omg.CosTransactions.Inactive,
                                                                     org.omg.CORBA.TRANSACTION_ROLLEDBACK
Enables a Resource to be registered as a participant in the completion of the top-level transaction represented by the TopCoordinator. If the TopCoordinator is a subordinate, and has not registered with its superior, it creates a CoordinatorResource and registers it. The RecoveryCoordinator that is returned is stored in the SuperiorInfo.

Specified by:
register_resource in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
res - The Resource to be registered.
Returns:
The RecoveryCoordinator object from the registration with the top-level ancestor.
Throws:
org.omg.CosTransactions.Inactive - The Coordinator is completing the transaction and cannot accept this registration.
org.omg.CORBA.TRANSACTION_ROLLEDBACK - The transaction which the Coordinator represents has already been rolled back, or has been marked rollback-only.
See Also:

register_subtran_aware

public void register_subtran_aware(org.omg.CosTransactions.SubtransactionAwareResource sares)
                            throws org.omg.CosTransactions.NotSubtransaction
Enables a SubtransactionAwareResource to be registered as a participant in the completion of a subtransaction. For a top-level transaction this raises the NotSubtransaction exception.

Specified by:
register_subtran_aware in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
sares - The SubtransactionAwareResource to be registered.
Throws:
org.omg.CosTransactions.NotSubtransaction - The Coordinator represents a top-level transaction and cannot accept the registration.
See Also:

rollback_only

public void rollback_only()
                   throws org.omg.CosTransactions.Inactive
Ensures that the transaction represented by the target TopCoordinator cannot be committed.

Specified by:
rollback_only in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Throws:
org.omg.CosTransactions.Inactive - The Coordinator is already completing the transaction.
See Also:

get_transaction_name

public java.lang.String get_transaction_name()
removed synchronization at method level since only tranState requires locking

Specified by:
get_transaction_name in interface org.omg.CosTransactions.CoordinatorOperations

create_subtransaction

public org.omg.CosTransactions.Control create_subtransaction()
                                                      throws org.omg.CosTransactions.Inactive
Creates a subtransaction and returns a Control object that represents the child transaction.

Specified by:
create_subtransaction in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The Control object for the new child transaction.
Throws:
org.omg.CosTransactions.Inactive - The Coordinator is completing the subtransaction and cannot create a new child.
See Also:

getGlobalTID

public org.omg.CosTransactions.otid_t getGlobalTID()
Returns a global identifier that represents the TopCoordinator's transaction.

This operation references only the global identifier, and so can be implemented locally in a proxy class.

This method is currently not synchronized because that causes a deadlock in resync. I don't think this is a problem as the global identifier is allocated in the constructor and then never changes.

Specified by:
getGlobalTID in interface JCoordinatorOperations
Parameters:
-
Returns:
The global transaction identifier.
See Also:

getGlobalTid

public GlobalTID getGlobalTid()

getParticipantCount

public int getParticipantCount()

getLocalTID

public long getLocalTID()
Returns the internal identifier for the transaction. This method is currently not synchronized because that causes a deadlock in resync.

Specified by:
getLocalTID in interface JCoordinatorOperations
Parameters:
-
Returns:
The local identifier.
See Also:

isRollbackOnly

public boolean isRollbackOnly()
Checks whether the TopCoordinator is marked rollback-only.

Specified by:
isRollbackOnly in interface JCoordinatorOperations
Parameters:
-
Returns:
Indicates whether the transaction is rollback-only.
See Also:

getAncestors

public org.omg.CosTransactions.TransIdentity[] getAncestors()
Returns the sequence of ancestors of the transaction.

Specified by:
getAncestors in interface JCoordinatorOperations
Parameters:
-
Returns:
The sequence of ancestors.
See Also:

register_synchronization

public void register_synchronization(org.omg.CosTransactions.Synchronization sync)
                              throws org.omg.CORBA.SystemException,
                                     org.omg.CosTransactions.Inactive,
                                     org.omg.CosTransactions.SynchronizationUnavailable
Informs the TopCoordinator that the given object requires synchronization before and after completion of the transaction. If possible, a CoordinatorSync object is registered with the superior Coordinator. Otherwise this Coordinator becomes the root of a sub-tree for synchronization.

Specified by:
register_synchronization in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
sync - The Synchronization object to be registered.
Throws:
org.omg.CosTransactions.Inactive - The Coordinator is in the process of completing the transaction and cannot accept this registration.
org.omg.CosTransactions.SynchronizationUnavailable - The transaction service cannot support synchronization.
org.omg.CORBA.SystemException - The operation failed.
See Also:

get_txcontext

public org.omg.CosTransactions.PropagationContext get_txcontext()
                                                         throws org.omg.CosTransactions.Unavailable
Creates a PropagationContext which contains the information which would normally be passed implicitly via the CosTSPropagation interfaces.

Specified by:
get_txcontext in interface org.omg.CosTransactions.CoordinatorOperations
Parameters:
-
Returns:
The transaction context.
Throws:
org.omg.CosTransactions.Inactive - The Coordinator is in the process of completing the transaction and cannot return the information.
org.omg.CosTransactions.Unavailable
See Also:

hashCode

public int hashCode()
Returns a hash code for the object.

This very basic method is used by the trace facility and should not call any method which is traced.

Overrides:
hashCode in class java.lang.Object
Parameters:
-
Returns:
The hash code for the object.
See Also:

equals

public boolean equals(java.lang.Object other)
Determines equality of the object with the parameter.

Overrides:
equals in class java.lang.Object
Parameters:
other - The other object.
Returns:
Indicates equality.
See Also:

_duplicate

public org.omg.CORBA.Object _duplicate()
Specified by:
_duplicate in interface org.omg.CORBA.Object

_release

public void _release()
Specified by:
_release in interface org.omg.CORBA.Object

_is_a

public boolean _is_a(java.lang.String repository_id)
Specified by:
_is_a in interface org.omg.CORBA.Object
Overrides:
_is_a in class org.omg.PortableServer.Servant

_is_equivalent

public boolean _is_equivalent(org.omg.CORBA.Object that)
Specified by:
_is_equivalent in interface org.omg.CORBA.Object

_non_existent

public boolean _non_existent()
Specified by:
_non_existent in interface org.omg.CORBA.Object
Overrides:
_non_existent in class org.omg.PortableServer.Servant

_hash

public int _hash(int maximum)
Specified by:
_hash in interface org.omg.CORBA.Object

_request

public org.omg.CORBA.Request _request(java.lang.String operation)
Specified by:
_request in interface org.omg.CORBA.Object

_create_request

public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context ctx,
                                             java.lang.String operation,
                                             org.omg.CORBA.NVList arg_list,
                                             org.omg.CORBA.NamedValue result)
Specified by:
_create_request in interface org.omg.CORBA.Object

_create_request

public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context ctx,
                                             java.lang.String operation,
                                             org.omg.CORBA.NVList arg_list,
                                             org.omg.CORBA.NamedValue result,
                                             org.omg.CORBA.ExceptionList exceptions,
                                             org.omg.CORBA.ContextList contexts)
Specified by:
_create_request in interface org.omg.CORBA.Object

_get_interface_def

public org.omg.CORBA.Object _get_interface_def()
Specified by:
_get_interface_def in interface org.omg.CORBA.Object
Overrides:
_get_interface_def in class org.omg.PortableServer.Servant

_get_policy

public org.omg.CORBA.Policy _get_policy(int policy_type)
Specified by:
_get_policy in interface org.omg.CORBA.Object

_get_domain_managers

public org.omg.CORBA.DomainManager[] _get_domain_managers()
Specified by:
_get_domain_managers in interface org.omg.CORBA.Object

_set_policy_override

public org.omg.CORBA.Object _set_policy_override(org.omg.CORBA.Policy[] policies,
                                                 org.omg.CORBA.SetOverrideType set_add)
Specified by:
_set_policy_override in interface org.omg.CORBA.Object


Copyright © 2012 GlassFish Community. All Rights Reserved.