1 24 package org.objectweb.jalisto.se.impl.trace; 25 26 import java.io.Serializable ; 27 import java.util.*; 28 29 public abstract class Trace implements Serializable { 30 protected static final Map MODULE_REPOSITORY = new HashMap(); 31 public static final Module TRACE_ON = new Module(MODULE_REPOSITORY, "TRACE", 1); 32 public static final Module SESSION = new Module(MODULE_REPOSITORY, "SESSION", 2); 33 public static final Module CACHE = new Module(MODULE_REPOSITORY, "CACHE", 3); 34 public static final Module OIDTABLE = new Module(MODULE_REPOSITORY, "OIDTABLE", 4); 35 public static final Module LOGICAL = new Module(MODULE_REPOSITORY, "LOGICAL", 5); 36 public static final Module PHYSICAL = new Module(MODULE_REPOSITORY, "PHYSICAL", 6); 37 public static final Module JCA = new Module(MODULE_REPOSITORY, "JCA", 8); 38 public static final Module JCAPOOL = new Module(MODULE_REPOSITORY, "JCAPOOL", 9); 39 public static final Module REMOTE = new Module(MODULE_REPOSITORY, "REMOTE", 10); 40 public static final Module DEBUG = new Module(MODULE_REPOSITORY, "DEBUG", 50); 41 42 static final long serialVersionUID = -7589377012769961459L; 43 44 private static Trace current; 45 protected boolean enabled; 46 47 public static Trace current() { 48 if (current == null) { 49 current = new TraceNull(); 50 } 51 52 return current; 53 } 54 55 public abstract boolean isEnabled(Module component); 56 57 public abstract boolean isShowThread(); 58 59 public abstract void enableShowThread(); 60 61 public abstract void enableTrace(boolean enable); 62 63 public abstract Set enabledModules(); 64 65 protected abstract void setEnabledModules(Set modules); 66 67 public abstract void init(Iterator traceModuleNames); 68 69 public abstract void printException(Object message, Throwable t); 70 71 public abstract void println(Module component, String message); 72 73 public abstract void println(Module component, String message, 74 Object parameter1); 75 76 public abstract void println(Module component, String message, 77 Object parameter1, Object parameter2); 78 79 public abstract void println(Module component, String message, 80 Object parameter1, Object parameter2, 81 Object parameter3); 82 83 public abstract void println(Module component, String message, 84 Object [] parameters); 85 86 public boolean isEnabled() { 87 return enabled; 88 } 89 90 public static class Module { 91 private String name; 92 private int flag; 93 94 public Module(Map registry, String name, int flag) { 95 this.name = name; 96 this.flag = flag; 97 registry.put(name, this); 98 } 99 100 public boolean isInMask(BitSet s) { 101 return s.get(flag); 102 } 103 104 public String getName() { 105 return name; 106 } 107 108 public boolean equals(Object obj) { 109 try { 110 return flag == (((Module) obj).flag); 111 } catch (Exception e) { 112 return false; 113 } 114 } 115 116 public int hashCode() { 117 return flag; 118 } 119 120 public void putInMask(BitSet s) { 121 s.set(flag); 122 } 123 124 public String toString() { 125 return "[" + name + "]"; 126 } 127 } 128 } 129 | Popular Tags |