FileDocCategorySizeDatePackage
Utility.javaAPI DocGlassfish v2 API5167Fri May 04 22:36:40 BST 2007com.sun.jts.jtsxa

Utility

public class Utility extends Object
This is an Utility class containing helper functions.

Fields Summary
private static org.omg.CosTransactions.Current
current
Constructors Summary
private Utility()


    /*
     * All Utility methods are static.
     * It is not possible to create a JTSXA instance variable.
     */
      
Methods Summary
public static ControlgetControl()
Obtain the current Control object.

return
the current control object, or null if the Control cannot be obtained.
see
org.omg.CosTransactions.Control

        Control control = null;

        try {
            if (current == null) {
                current = (org.omg.CosTransactions.Current) Configuration.
                    getORB().resolve_initial_references("TransactionCurrent"/*#Frozen*/);
            }
            control = current.get_control();
        } catch(Exception e) {
            // empty
        }

        return control;
    
public static CoordinatorgetCoordinator(Control control)
Obtain the coordinator object from the supplied control.

If a null control is supplied, an null coordinator will be returned.

param
control the control object for which the coordinator will be returned
return
the coordinator, or null if no coordinator can be obtained.
see
org.omg.CosTransactions.Control
see
org.omg.CosTransactions.Coordinator

        Coordinator coordinator = null;

        if (control == null) {
            return null;
        }

        try {
            coordinator = control.get_coordinator();
        } catch(Exception e) {
            coordinator = null;
        }

        return coordinator;
    
public static XIDgetXID(Coordinator coordinator)
Obtain the global transaction identifier for the supplied coordinator.

param
coordinator the coordinator representing the transaction for which the global transaction identifier is required
return
the global transaction identifier.
see
com.sun.jts.jtsxa.XID

        otid_t tid = null;
        XID xid = new XID();

        if (coordinator == null) {
            return null;
        }

        try {
            tid = JCoordinatorHelper.narrow(coordinator).getGlobalTID();
            xid.copy(tid);
        } catch(Exception e) {
            return null;
        }

        return xid;
    
public static XIDgetXID()
Obtain the global transaction identifier for the current transaction.

return
the global transaction identifier.
see
com.sun.jts.jtsxa.XID

        Control control = null;
        Coordinator coordinator = null;

        control = getControl();
        coordinator = getCoordinator(control);

        XID xid = getXID(coordinator);

        return xid;