1 39 package org.objectweb.jotm.jta.rmi; 40 41 import java.io.IOException ; 43 44 import org.objectweb.carol.rmi.jrmp.interceptor.JClientRequestInfo; 45 import org.objectweb.carol.rmi.jrmp.interceptor.JClientRequestInterceptor; 46 import org.objectweb.jotm.Current; 47 import org.objectweb.jotm.TransactionContext; 48 49 55 public class JTAClientTransactionInterceptor 56 implements JClientRequestInterceptor { 57 58 64 67 public static int TX_CTX_ID = 0; 68 69 72 private static Current current = null; 73 74 77 private static String interceptorName = "JTAClientTransactionInterceptor"; 78 79 82 public JTAClientTransactionInterceptor() { 83 } 85 86 90 public String name() { 91 return interceptorName; 92 } 93 94 100 public void send_request(JClientRequestInfo jri) throws IOException { 101 try { 103 if (current == null) 104 current = Current.getCurrent(); 105 if (current != null) { 106 TransactionContext txCtx = current.getPropagationContext(true); 108 if (txCtx != null) { 109 JTATransactionServiceContext jtasc = 110 new JTATransactionServiceContext(); 111 jtasc.setContext(txCtx, false); 112 jri.add_request_service_context(jtasc); 113 } 114 } 115 } catch (Exception e) { 116 e.printStackTrace(); 117 } 118 } 119 120 125 public void receive_reply(JClientRequestInfo jri) throws IOException { 126 if (current == null) 127 current = Current.getCurrent(); 128 if (current != null) { 129 JTATransactionServiceContext jtasc = 130 (JTATransactionServiceContext) jri.get_reply_service_context( 131 TX_CTX_ID); 132 if (jtasc != null) { 133 current.setPropagationContext( 135 jtasc.getTransactionContext(), 136 true); 137 } 138 } 139 } 141 142 public void send_poll(JClientRequestInfo jri) throws IOException { 144 } 146 147 public void receive_exception(JClientRequestInfo jri) throws IOException { 148 if (current == null) 150 current = Current.getCurrent(); 151 if (current != null) { 152 JTATransactionServiceContext jtasc = 153 (JTATransactionServiceContext) jri.get_reply_service_context( 154 TX_CTX_ID); 155 if (jtasc != null) { 156 current.setPropagationContext( 158 jtasc.getTransactionContext(), 159 true); 160 } 161 } 162 } 163 164 public void receive_other(JClientRequestInfo jri) throws IOException { 165 if (current == null) 166 current = Current.getCurrent(); 167 if (current != null) { 168 JTATransactionServiceContext jtasc = 169 (JTATransactionServiceContext) jri.get_reply_service_context( 170 TX_CTX_ID); 171 if (jtasc != null) { 172 current.setPropagationContext( 174 jtasc.getTransactionContext(), 175 true); 176 } 177 } 178 } 180 } 181 | Popular Tags |