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.CORBA.Any ; 28 import org.omg.CORBA.OctetSeqHelper ; 29 import org.omg.CORBA.TCKind ; 30 import org.omg.CORBA.LocalObject ; 31 import org.omg.CORBA.ORB ; 32 import org.omg.PortableInterceptor.Current ; 33 import org.omg.PortableInterceptor.CurrentHelper ; 34 import org.omg.PortableInterceptor.InvalidSlot ; 35 import java.util.Hashtable ; 36 import org.coach.tracing.service.*; 37 import org.coach.tracing.api.pi.*; 38 import java.io.*; 39 40 class TracingServiceImpl extends LocalObject implements TracingService 41 { 42 private int slotId; 43 private int currentServiceId = 0; 44 private Current piCurrent; 45 private Any NOT_IN_EFFECT; 46 private Hashtable dataTable = new Hashtable (); 47 private ORB orb; 48 49 public TracingServiceImpl(int slotId) 50 { 51 this.slotId = slotId; 52 } 54 55 void setPICurrent(Current piCurrent) 58 { 59 this.piCurrent = piCurrent; 60 } 61 62 private void init() 63 { 64 if (orb == null) 65 { 66 orb = ORB.init(new String [0], null); 68 NOT_IN_EFFECT = orb.create_any(); 69 TracingServiceInterceptor.init(); 70 } 71 } 72 73 public synchronized void start() 74 { 75 init(); 76 try 77 { 78 Any any = orb.create_any(); 80 ThreadContext tc = ThreadContext.getCurrentThreadContext(); 81 String tid = tc.getThreadId(); 82 any.insert_string(tid); 84 piCurrent.set_slot(slotId, any); 85 } 86 catch (Exception e) 87 { 88 e.printStackTrace(); 89 } 90 } 91 92 public void stop() 93 { 94 try 95 { 96 piCurrent.set_slot(slotId, NOT_IN_EFFECT); 97 } 98 catch (Exception e) 99 { 100 e.printStackTrace(); 101 } 102 } 103 } | Popular Tags |