1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package org.coach.tracing.service.pi; 26 27 import org.omg.IOP.Codec ; 28 import org.omg.IOP.CodecFactory ; 29 import org.omg.IOP.CodecFactoryHelper ; 30 import org.omg.IOP.Encoding ; 31 import org.omg.PortableInterceptor.*; 32 import org.omg.CORBA.LocalObject ; 33 import org.coach.tracing.api.pi.*; 34 35 public class TracingServiceORBInitializer extends LocalObject implements ORBInitializer 36 { 37 private TracingServiceImpl aServiceImpl; 38 private TracingServiceInterceptor aServiceInterceptor; 39 40 public void pre_init(ORBInitInfo info) 41 { 42 try 43 { 44 46 int id = info.allocate_slot_id(); 47 48 aServiceInterceptor = new TracingServiceInterceptor(id); 49 50 info.add_client_request_interceptor(aServiceInterceptor); 51 info.add_server_request_interceptor(aServiceInterceptor); 52 53 aServiceImpl = new TracingServiceImpl(id); 56 info.register_initial_reference("TracingService", aServiceImpl); 57 } 58 catch (Throwable t) 59 { 60 t.printStackTrace(); 61 } 62 } 63 64 public void post_init(ORBInitInfo info) 65 { 66 try 67 { 68 Current piCurrent = CurrentHelper.narrow(info.resolve_initial_references("PICurrent")); 70 CodecFactory codecFactory = CodecFactoryHelper.narrow(info.resolve_initial_references("CodecFactory")); 71 Encoding encoding = new Encoding ((short)0, (byte)1, (byte)0); 73 Codec codec = codecFactory.create_codec(encoding); 74 aServiceInterceptor.init(piCurrent, codec); 75 aServiceImpl.setPICurrent(piCurrent); 76 } 77 catch (Throwable t) 78 { 79 t.printStackTrace(); 80 } 81 } 82 } 83 | Popular Tags |