1 package org.jacorb.util.tracing; 2 3 23 24 import org.omg.CosNaming.NamingContextExt ; 25 import org.omg.CosNaming.NamingContextExtHelper ; 26 import org.omg.IOP.Codec ; 27 import org.omg.IOP.ENCODING_CDR_ENCAPS ; 28 import org.omg.IOP.Encoding ; 29 import org.omg.PortableInterceptor.ORBInitInfo ; 30 import org.omg.PortableInterceptor.ORBInitializer ; 31 32 35 public class TraceInitializer 36 extends org.omg.CORBA.LocalObject 37 implements ORBInitializer 38 { 39 public TraceInitializer() 40 { 41 } 42 43 46 public void post_init(ORBInitInfo info) 47 { 48 try 49 { 50 int slot_id = info.allocate_slot_id(); 51 52 NamingContextExt nc = 53 NamingContextExtHelper.narrow( 54 info.resolve_initial_references("NameService")); 55 56 TracingService tracer = 57 TracingServiceHelper.narrow( 58 nc.resolve( nc.to_name("tracing.service"))); 59 60 61 if( tracer == null ) 62 { 63 System.err.println("No Tracing Service, cannot register tracer interceptor!"); 64 return; 65 } 66 67 Encoding encoding = new Encoding (ENCODING_CDR_ENCAPS.value, 68 (byte) 1, (byte) 0); 69 Codec codec = info.codec_factory().create_codec(encoding); 70 71 ClientTraceInterceptor interceptor = 72 new ClientTraceInterceptor(codec, slot_id , tracer); 73 info.add_client_request_interceptor(interceptor); 74 75 info.add_server_request_interceptor( new ServerTraceInterceptor( slot_id, 76 codec)); 77 78 } 79 catch (Exception e) 80 { 81 e.printStackTrace(); 82 } 83 } 84 85 public void pre_init(ORBInitInfo info) 86 { 87 } 88 89 } 90 | Popular Tags |