1 24 package org.objectweb.jalisto.se.impl.trace; 25 26 import java.util.Collection ; 27 import java.util.HashSet ; 28 29 public class TraceContext { 30 private HashSet moduleNames; 31 private boolean isEnable; 32 private Trace tracer; 33 34 public TraceContext(boolean enable, Collection moduleNamesToAdd) { 35 isEnable = enable; 36 moduleNames = new HashSet (moduleNamesToAdd); 37 if (isEnable) { 38 moduleNames.add("TRACE"); 39 } 40 } 41 42 public boolean isTracing(Trace.Module component) { 43 return (isEnable && moduleNames.contains(component.getName())); 44 } 45 46 public Trace getTracer() { 47 if (tracer == null) { 48 if (moduleNames.isEmpty()) { 49 tracer = new TraceNull(); 50 } else { 51 tracer = new TraceErr(this); 52 tracer.enableTrace(isEnable); 53 tracer.init(moduleNames.iterator()); 54 } 55 } 56 return tracer; 57 } 58 } 59 | Popular Tags |