/*
* Jalisto - JAva LIght STOrage
* Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Xcalia
* 71, rue Desnouettes
* 75014 Paris - France
* http://www.xcalia.com
*/
package org.objectweb.jalisto.se.impl.trace;
import java.io.Serializable;
import java.util.*;
public abstract class Trace implements Serializable {
protected static final Map MODULE_REPOSITORY = new HashMap();
public static final Module TRACE_ON = new Module(MODULE_REPOSITORY, "TRACE", 1);
public static final Module SESSION = new Module(MODULE_REPOSITORY, "SESSION", 2);
public static final Module CACHE = new Module(MODULE_REPOSITORY, "CACHE", 3);
public static final Module OIDTABLE = new Module(MODULE_REPOSITORY, "OIDTABLE", 4);
public static final Module LOGICAL = new Module(MODULE_REPOSITORY, "LOGICAL", 5);
public static final Module PHYSICAL = new Module(MODULE_REPOSITORY, "PHYSICAL", 6);
public static final Module JCA = new Module(MODULE_REPOSITORY, "JCA", 8);
public static final Module JCAPOOL = new Module(MODULE_REPOSITORY, "JCAPOOL", 9);
public static final Module REMOTE = new Module(MODULE_REPOSITORY, "REMOTE", 10);
public static final Module DEBUG = new Module(MODULE_REPOSITORY, "DEBUG", 50);
static final long serialVersionUID = -7589377012769961459L;
private static Trace current;
protected boolean enabled;
public static Trace current() {
if (current == null) {
current = new TraceNull();
}
return current;
}
public abstract boolean isEnabled(Module component);
public abstract boolean isShowThread();
public abstract void enableShowThread();
public abstract void enableTrace(boolean enable);
public abstract Set enabledModules();
protected abstract void setEnabledModules(Set modules);
public abstract void init(Iterator traceModuleNames);
public abstract void printException(Object message, Throwable t);
public abstract void println(Module component, String message);
public abstract void println(Module component, String message,
Object parameter1);
public abstract void println(Module component, String message,
Object parameter1, Object parameter2);
public abstract void println(Module component, String message,
Object parameter1, Object parameter2,
Object parameter3);
public abstract void println(Module component, String message,
Object[] parameters);
public boolean isEnabled() {
return enabled;
}
public static class Module {
private String name;
private int flag;
public Module(Map registry, String name, int flag) {
this.name = name;
this.flag = flag;
registry.put(name, this);
}
public boolean isInMask(BitSet s) {
return s.get(flag);
}
public String getName() {
return name;
}
public boolean equals(Object obj) {
try {
return flag == (((Module) obj).flag);
} catch (Exception e) {
return false;
}
}
public int hashCode() {
return flag;
}
public void putInMask(BitSet s) {
s.set(flag);
}
public String toString() {
return "[" + name + "]";
}
}
}
|