1 package test.interceptor.ctx_passing; 2 3 import org.omg.PortableInterceptor.*; 4 5 import org.omg.IOP.Codec ; 6 import org.omg.IOP.ServiceContext ; 7 8 17 18 public class ClientInterceptor 19 extends org.omg.CORBA.LocalObject 20 implements ClientRequestInterceptor 21 { 22 private int slot_id = -1; 23 private Codec codec = null; 24 25 public ClientInterceptor(int slot_id, Codec codec) 26 { 27 this.slot_id = slot_id; 28 this.codec = codec; 29 } 30 31 public String name() 32 { 33 return "ClientInterceptor"; 34 } 35 36 public void destroy() 37 { 38 } 39 40 public void send_request( ClientRequestInfo ri ) 41 throws ForwardRequest 42 { 43 System.out.println("ClientInterceptor: send_request()"); 44 45 try 46 { 47 org.omg.CORBA.Any any = ri.get_slot( slot_id ); 48 49 if( any.type().kind().value() != org.omg.CORBA.TCKind._tk_null ) 50 { 51 ServiceContext ctx = 52 new ServiceContext (4711, codec.encode( any )); 53 54 ri.add_request_service_context( ctx, false ); 55 } 56 } 57 catch (Exception e) 58 { 59 e.printStackTrace(); 60 } 61 } 62 63 public void send_poll(ClientRequestInfo ri) 64 { 65 } 66 67 public void receive_reply(ClientRequestInfo ri) 68 { 69 } 70 71 public void receive_exception(ClientRequestInfo ri) 72 throws ForwardRequest 73 { 74 } 75 76 public void receive_other(ClientRequestInfo ri) 77 throws ForwardRequest 78 { 79 } 80 } | Popular Tags |