1 39 package org.objectweb.jotm.ots; 40 41 import org.objectweb.jotm.Current; 43 import org.objectweb.jotm.TransactionContext; 44 import org.omg.IOP.ServiceContext ; 45 import org.omg.PortableInterceptor.ClientRequestInfo ; 46 import org.omg.PortableInterceptor.ClientRequestInterceptor ; 47 import org.omg.PortableInterceptor.ForwardRequest ; 48 import org.omg.PortableInterceptor.ORBInitInfo ; 49 50 57 public class OTSClientTransactionInterceptor 58 extends OTSInterceptor 59 implements ClientRequestInterceptor { 60 61 64 private static Current current = null; 65 66 69 private String interceptorName = "OTSClientTransactionInteceptor"; 70 71 74 public OTSClientTransactionInterceptor(ORBInitInfo info) { 75 super(info); 76 } 77 78 82 public String name() { 83 return interceptorName; 84 } 85 86 public void destroy() { 87 } 88 89 95 public void send_request(ClientRequestInfo jri) throws ForwardRequest { 96 97 if (current == null) 98 current = Current.getCurrent(); 99 if (current != null) { 100 try { 101 TransactionContext txCtx = current.getPropagationContext(true); 103 ServiceContext pContext = null ; 104 105 if (txCtx != null) { 106 107 pContext = buildCorbaPropagationContext(txCtx); 109 jri.add_request_service_context(pContext, true); 110 } else { 111 112 } 115 116 } catch (Exception e) { 117 throw new ForwardRequest (); 118 } 119 } 120 } 121 122 123 128 public void receive_reply(ClientRequestInfo jri) { 129 130 if (current == null) 131 current = Current.getCurrent(); 132 133 if (current != null) { 134 135 try { 136 TransactionContext txCtx = decodeCorbaPropagationContext(jri.get_reply_service_context(TX_CTX_ID)) ; 137 138 if ( txCtx != null ) { 139 140 current.setPropagationContext(txCtx, true); 142 143 current.associateThreadTx(txCtx.getXid()); 145 } 146 147 } catch (org.omg.CORBA.BAD_PARAM b) { 148 150 } catch (Exception e) { 151 152 } 153 } 154 } 155 156 public void send_poll(ClientRequestInfo jri) { 158 } 159 160 public void receive_exception(ClientRequestInfo jri) throws ForwardRequest { 161 if (current == null) 162 current = Current.getCurrent(); 163 164 if (current != null) { 165 try { 166 TransactionContext txCtx = decodeCorbaPropagationContext(jri.get_reply_service_context(TX_CTX_ID)) ; 167 168 if ( txCtx != null ) { 169 170 current.setPropagationContext(txCtx, true); 172 173 current.associateThreadTx(txCtx.getXid()); 175 } 176 177 } catch (org.omg.CORBA.BAD_PARAM b) { 178 180 } catch (Exception e) { 181 } 182 } 183 } 184 185 public void receive_other(ClientRequestInfo jri) throws ForwardRequest { 186 } 187 188 } 189 | Popular Tags |