1 21 package org.jacorb.transaction; 22 23 import org.apache.avalon.framework.logger.Logger; 24 25 import org.omg.PortableInterceptor.*; 26 import org.omg.CosTransactions.*; 27 import org.omg.IOP.ServiceContext ; 28 import org.omg.IOP.TransactionService ; 29 import org.omg.IOP.Codec ; 30 31 51 52 public class ServerContextTransferInterceptor 53 extends org.omg.CORBA.LocalObject 54 implements ServerRequestInterceptor 55 { 56 private Codec codec = null; 57 private int slot_id = -1; 58 private org.omg.CosTransactions.Current ts_current; 59 private org.omg.CORBA.ORB orb; 60 private Logger logger; 61 62 public ServerContextTransferInterceptor(Codec codec, 63 int slot_id, 64 org.omg.CosTransactions.Current ts_current, 65 org.omg.CORBA.ORB orb) 66 { 67 this.codec = codec; 68 this.slot_id = slot_id; 69 this.ts_current = ts_current; 70 this.orb = orb; 71 this.logger = 72 ((org.jacorb.orb.ORB)orb).getConfiguration().getNamedLogger("jacorb.tx_service.interceptor"); 73 } 74 75 public String name() 77 { 78 return "ServerContextTransferInterceptor"; 79 } 80 81 public void destroy() 82 { 83 } 84 85 89 public void receive_request_service_contexts(ServerRequestInfo ri) 90 throws ForwardRequest 91 { 92 try 93 { 94 ServiceContext ctx = ri.get_request_service_context(TransactionService.value); 95 ri.set_slot(slot_id, codec.decode(ctx.context_data)); 96 } 97 catch (Exception e) 98 { 99 if (logger.isDebugEnabled()) 100 logger.debug("Exception", e); 101 } 102 } 103 104 public void receive_request(ServerRequestInfo ri) 105 throws ForwardRequest 106 { 107 try 108 { 109 org.omg.PortableInterceptor.Current pi_current = 110 (org.omg.PortableInterceptor.Current ) 111 orb.resolve_initial_references("PICurrent"); 112 113 PropagationContext context = PropagationContextHelper.extract 114 (pi_current.get_slot(slot_id)); 115 116 Control control = ControlHelper.extract(context.implementation_specific_data); 117 ts_current.resume(control); 118 } 119 catch(Exception e) 120 { 121 if (logger.isDebugEnabled()) 122 logger.debug("Exception", e); 123 } 124 } 125 126 public void send_reply(ServerRequestInfo ri) 127 { 128 ts_current.suspend(); 129 } 130 131 public void send_exception(ServerRequestInfo ri) 132 throws ForwardRequest 133 { 134 ts_current.suspend(); 135 } 136 137 public void send_other(ServerRequestInfo ri) 138 throws ForwardRequest 139 { 140 ts_current.suspend(); 141 } 142 } 144 145 | Popular Tags |