1 39 package org.objectweb.jotm.jta.rmi; 40 41 import java.io.IOException ; 43 44 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInfo; 45 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInterceptor; 46 import org.objectweb.jotm.Current; 47 import org.objectweb.jotm.TransactionContext; 48 49 56 public class JTAServerTransactionInterceptor 57 implements JServerRequestInterceptor { 58 59 65 68 public static int TX_CTX_ID = 0; 69 70 73 private static Current current = null; 74 75 78 private static String interceptorName = "JTAServerTransactionInterceptor"; 79 80 83 public JTAServerTransactionInterceptor() { 84 } 86 87 92 public void receive_request(JServerRequestInfo jri) throws IOException { 93 if (current == null) 95 current = Current.getCurrent(); 96 if (current != null) { 97 JTATransactionServiceContext jtasc = 98 (JTATransactionServiceContext) jri.get_request_service_context( 99 TX_CTX_ID); 100 if (jtasc != null) { 101 current.setPropagationContext( 103 jtasc.getTransactionContext(), 104 false); 105 } 106 } 107 } 108 109 114 public void send_reply(JServerRequestInfo jri) throws IOException { 115 if (current == null) 116 current = Current.getCurrent(); 117 if (current != null) { 118 TransactionContext txCtx = current.getPropagationContext(false); 120 if (txCtx != null) { 121 JTATransactionServiceContext jtasc = 122 new JTATransactionServiceContext(); 123 jtasc.setContext(txCtx, true); 124 jri.add_reply_service_context(jtasc); 125 current.setPropagationContext(null, false); 126 } 127 } 128 } 130 131 135 public String name() { 136 return interceptorName; 137 } 138 139 public void send_exception(JServerRequestInfo jri) throws IOException { 140 if (current == null) 141 current = Current.getCurrent(); 142 if (current != null) { 143 TransactionContext txCtx = current.getPropagationContext(false); 145 if (txCtx != null) { 146 JTATransactionServiceContext jtasc = 147 new JTATransactionServiceContext(); 148 jtasc.setContext(txCtx, true); 149 jri.add_reply_service_context(jtasc); 150 current.setPropagationContext(null, false); 151 } 152 } 153 } 155 156 public void send_other(JServerRequestInfo jri) throws IOException { 157 if (current == null) 158 current = Current.getCurrent(); 159 if (current != null) { 160 TransactionContext txCtx = current.getPropagationContext(false); 162 if (txCtx != null) { 163 JTATransactionServiceContext jtasc = 164 new JTATransactionServiceContext(); 165 jtasc.setContext(txCtx, true); 166 jri.add_reply_service_context(jtasc); 167 current.setPropagationContext(null, false); 168 } 169 } 170 } 172 } 173 | Popular Tags |