1 23 24 28 29 package com.sun.jts.jtsxa; 30 31 import java.io.*; 32 import java.util.*; 33 34 import org.omg.CosTransactions.*; 35 import com.sun.jts.otsidl.*; 36 import com.sun.jts.CosTransactions.*; 37 38 41 public class Utility { 42 43 45 private static org.omg.CosTransactions.Current current = null; 46 47 51 private Utility() {} 52 53 59 public static Control getControl() { 60 Control control = null; 61 62 try { 63 if (current == null) { 64 current = (org.omg.CosTransactions.Current) Configuration. 65 getORB().resolve_initial_references("TransactionCurrent"); 66 } 67 control = current.get_control(); 68 } catch(Exception e) { 69 } 71 72 return control; 73 } 74 75 87 public static Coordinator getCoordinator(Control control) { 88 Coordinator coordinator = null; 89 90 if (control == null) { 91 return null; 92 } 93 94 try { 95 coordinator = control.get_coordinator(); 96 } catch(Exception e) { 97 coordinator = null; 98 } 99 100 return coordinator; 101 } 102 103 113 public static XID getXID(Coordinator coordinator) { 114 otid_t tid = null; 115 XID xid = new XID(); 116 117 if (coordinator == null) { 118 return null; 119 } 120 121 try { 122 tid = JCoordinatorHelper.narrow(coordinator).getGlobalTID(); 123 xid.copy(tid); 124 } catch(Exception e) { 125 return null; 126 } 127 128 return xid; 129 } 130 131 138 public static XID getXID() { 139 Control control = null; 140 Coordinator coordinator = null; 141 142 control = getControl(); 143 coordinator = getCoordinator(control); 144 145 XID xid = getXID(coordinator); 146 147 return xid; 148 } 149 } 150 | Popular Tags |