1 23 24 28 package com.sun.jts.jta; 29 30 import java.util.*; 31 import javax.transaction.Synchronization ; 32 33 import org.omg.CORBA.*; 34 import org.omg.CosTransactions.*; 35 import org.omg.PortableServer.POA ; 36 import com.sun.jts.CosTransactions.Configuration; 37 import java.util.logging.Logger ; 38 import java.util.logging.Level ; 39 import com.sun.logging.LogDomains; 40 41 48 public class SynchronizationImpl extends SynchronizationPOA 49 implements org.omg.CosTransactions.Synchronization { 50 51 private Vector syncs; 52 private Vector interposedSyncs; 53 private POA poa; 54 private org.omg.CosTransactions.Synchronization corbaRef = null; 55 private TransactionState state = null; 56 59 static Logger _logger = LogDomains.getLogger(LogDomains.TRANSACTION_LOGGER); 60 61 public SynchronizationImpl() { 62 syncs = new Vector(); 63 interposedSyncs = new Vector(); 64 poa = Configuration.getPOA("transient"); 65 } 66 67 public SynchronizationImpl(TransactionState state) { 68 this(); 69 this.state = state; 70 } 71 72 public void addSynchronization(Synchronization sync, 73 boolean interposed) { 74 if (!interposed) 75 syncs.addElement(sync); 76 else 77 interposedSyncs.addElement(sync); 78 } 79 80 public void before_completion() { 81 Enumeration e = syncs.elements(); 83 while (e.hasMoreElements()) { 84 Synchronization sync = (Synchronization ) e.nextElement(); 85 try { 86 sync.beforeCompletion(); 87 } catch (RuntimeException rex) { 88 try { 89 state.setRollbackOnly(); 90 } catch (Exception ex1) { 91 _logger.log(Level.WARNING, 92 "jts.unexpected_error_occurred_in_after_completion",ex1); 93 } 94 _logger.log(Level.WARNING, 95 "jts.unexpected_error_occurred_in_after_completion",rex); 96 } catch (Exception ex) { 97 _logger.log(Level.WARNING, 98 "jts.unexpected_error_occurred_in_after_completion",ex); 99 } 100 } 101 Enumeration e1 = interposedSyncs.elements(); 102 while (e1.hasMoreElements()) { 103 Synchronization sync = (Synchronization ) e1.nextElement(); 104 try { 105 sync.beforeCompletion(); 106 } catch (RuntimeException rex) { 107 try { 108 state.setRollbackOnly(); 109 } catch (Exception ex1) { 110 _logger.log(Level.WARNING, 111 "jts.unexpected_error_occurred_in_after_completion",ex1); 112 } 113 _logger.log(Level.WARNING, 114 "jts.unexpected_error_occurred_in_after_completion",rex); 115 } catch (Exception ex) { 116 _logger.log(Level.WARNING, 117 "jts.unexpected_error_occurred_in_after_completion",ex); 118 } 119 } 120 state.beforeCompletion(); 121 } 122 123 public void after_completion(Status status) { 124 try { 125 int result = TransactionManagerImpl.mapStatus(status); 126 Enumeration e1 = interposedSyncs.elements(); 128 while (e1.hasMoreElements()) { 129 Synchronization sync = (Synchronization ) e1.nextElement(); 130 try { 131 sync.afterCompletion(result); 132 } catch (Exception ex) { 133 _logger.log(Level.WARNING, 134 "jts.unexpected_error_occurred_in_after_completion",ex); 135 } 136 } 137 Enumeration e = syncs.elements(); 138 while (e.hasMoreElements()) { 139 Synchronization sync = (Synchronization ) e.nextElement(); 140 try { 141 sync.afterCompletion(result); 142 } catch (Exception ex) { 143 _logger.log(Level.WARNING, 144 "jts.unexpected_error_occurred_in_after_completion",ex); 145 } 146 } 147 } finally { 148 try { 149 if (corbaRef != null) { 151 if (poa == null) { 152 poa = Configuration.getPOA("transient"); 153 } 154 poa.deactivate_object(poa.reference_to_id(corbaRef)); 155 } 156 } catch (Exception ex) { 157 _logger.log(Level.WARNING, 158 "jts.unexpected_error_occurred_in_after_completion",ex); 159 } 160 } 161 } 162 163 public org.omg.CosTransactions.Synchronization getCORBAReference() { 164 if (poa == null) { 165 poa = Configuration.getPOA("transient"); 166 } 167 168 if (corbaRef == null) { 169 try { 170 poa.activate_object(this); 171 corbaRef = SynchronizationHelper.narrow( 172 poa.servant_to_reference(this)); 173 } catch (Exception ex) { 175 _logger.log(Level.SEVERE, 176 "jts.unexpected_error_in_getcorbareference",ex); 177 } 178 } 179 180 return corbaRef; 181 } 182 183 188 189 private static org.omg.CORBA.NO_IMPLEMENT no_implement = 190 new org.omg.CORBA.NO_IMPLEMENT ("This is a locally constrained object."); 191 192 193 public org.omg.CORBA.Object _duplicate() { 194 throw no_implement; 195 } 196 197 public void _release() { 198 throw no_implement; 199 } 200 201 public boolean _is_a(String repository_id) { 202 throw no_implement; 203 } 204 205 public boolean _is_equivalent(org.omg.CORBA.Object that) { 206 throw no_implement; 207 } 208 209 public boolean _non_existent() { 210 throw no_implement; 211 } 212 213 public int _hash(int maximum) { 214 throw no_implement; 215 } 216 217 public Request _request(String operation) { 218 throw no_implement; 219 } 220 221 public Request _create_request(Context ctx, 222 String operation, 223 NVList arg_list, 224 NamedValue result) { 225 throw no_implement; 226 } 227 228 public Request _create_request(Context ctx, 229 String operation, 230 NVList arg_list, 231 NamedValue result, 232 ExceptionList exceptions, 233 ContextList contexts) { 234 throw no_implement; 235 } 236 237 public org.omg.CORBA.Object _get_interface_def() { 238 throw no_implement; 239 } 240 241 public org.omg.CORBA.Policy _get_policy(int policy_type) { 242 throw no_implement; 243 } 244 245 public org.omg.CORBA.DomainManager [] _get_domain_managers() { 246 throw no_implement; 247 } 248 249 public org.omg.CORBA.Object _set_policy_override( 250 org.omg.CORBA.Policy [] policies, 251 org.omg.CORBA.SetOverrideType set_add) { 252 throw no_implement; 253 } 254 } 255 | Popular Tags |