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; 26 27 import java.util.*; 28 import java.awt.*; 29 import java.awt.event.*; 30 import org.coach.tracing.api.pi.*; 31 32 public class ComponentContext 33 { 34 private static TracingService tracingService; 35 private static boolean awtInitialized = false; 36 private static int componentCount; 37 38 44 public static synchronized void setFrameContext(java.awt.Frame frame) 45 { 46 if (!awtInitialized) 47 { 48 try 49 { 50 System.err.println("Initializing COACH tracing service in FrameContext"); 52 tracingService = org.coach.tracing.api.pi.TracingServiceHelper.narrow(org.objectweb.openccm.corba.TheORB.getORB().resolve_initial_references("TracingService")); 53 javax.swing.SwingUtilities.invokeLater(new AwtInitializer(tracingService)); 55 awtInitialized = true; 56 } 57 catch (Throwable pix) 58 { 59 System.err.println("Failed to locate tracing service: " + pix); 60 } 61 } 62 ThreadContext.setFrameThreadContext(frame); 63 tracingService.start(); 65 } 66 67 public static synchronized void setComponentContext(Object ccmObject) 68 { 69 String componentName = "CCMComponent_" + ccmObject.hashCode(); 70 String componentType = ccmObject.getClass().getName(); 71 72 if (tracingService == null) 73 { 74 try 75 { 76 tracingService = org.coach.tracing.api.pi.TracingServiceHelper.narrow(org.objectweb.openccm.corba.TheORB.getORB().resolve_initial_references("TracingService")); 78 } 79 catch (Throwable pix) 80 { 81 System.err.println("Failed to locate tracing service: " + pix); 82 } 83 } 84 85 ThreadContext tc = ThreadContext.getCurrentThreadContext(); 86 tc.setComponentName(componentName); 88 tc.setComponentType(componentType); 89 tc.setContainerName("MyContainer"); 90 tc.setContainerType("MyContainerType"); 91 92 tracingService.start(); 94 } 95 } 96 97 100 class AwtInitializer implements Runnable 101 { 102 TracingService tracingService; 103 104 public AwtInitializer(TracingService tracingService) 105 { 106 this.tracingService = tracingService; 107 } 108 109 public void run() 110 { 111 tracingService.start(); 114 } 115 } 116 117 | Popular Tags |