@@ -56,38 +56,27 @@ public class DefaultTrace extends AbstractTrace { | |||
} | |||
} | |||
public void debug (String message) { | |||
if (traceEnabled) { | |||
println(formatMessage("?",message,null)); | |||
} | |||
println(formatMessage("?",message,null)); | |||
} | |||
public void info(String message) { | |||
if (traceEnabled) { | |||
println(formatMessage("I",message,null)); | |||
} | |||
println(formatMessage("I",message,null)); | |||
} | |||
public void warn (String message, Throwable th) { | |||
if (traceEnabled) { | |||
println(formatMessage("W",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
println(formatMessage("W",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
public void error (String message, Throwable th) { | |||
if (traceEnabled) { | |||
println(formatMessage("E",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
println(formatMessage("E",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
public void fatal (String message, Throwable th) { | |||
if (traceEnabled) { | |||
println(formatMessage("X",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
println(formatMessage("X",message,th)); | |||
if (th != null) th.printStackTrace(); | |||
} | |||
/** |
@@ -16,9 +16,10 @@ public abstract class TraceFactory { | |||
public final static String DEBUG_PROPERTY = "org.aspectj.tracing.debug"; | |||
public final static String FACTORY_PROPERTY = "org.aspectj.tracing.factory"; | |||
public final static String DEFAULT_FACTORY_NAME = "default"; | |||
private static boolean debug = getBoolean(DEBUG_PROPERTY,false); | |||
private static TraceFactory instance = new DefaultTraceFactory(); | |||
private static TraceFactory instance; | |||
public Trace getTrace (Class clazz) { | |||
return instance.getTrace(clazz); | |||
@@ -35,7 +36,28 @@ public abstract class TraceFactory { | |||
} | |||
static { | |||
try { | |||
/* | |||
* Allow user to override default behaviour or specify their own factory | |||
*/ | |||
String factoryName = System.getProperty(FACTORY_PROPERTY); | |||
if (factoryName != null) try { | |||
if (factoryName.equals(DEFAULT_FACTORY_NAME)) { | |||
instance = new DefaultTraceFactory(); | |||
} | |||
else { | |||
Class factoryClass = Class.forName(factoryName); | |||
instance = (TraceFactory)factoryClass.newInstance(); | |||
} | |||
} | |||
catch (Throwable th) { | |||
if (debug) th.printStackTrace(); | |||
} | |||
/* | |||
* Try to load external trace infrastructure using supplied factories | |||
*/ | |||
if (instance == null) try { | |||
if (LangUtil.is15VMOrGreater()) { | |||
Class factoryClass = Class.forName("org.aspectj.weaver.tools.Jdk14TraceFactory"); | |||
instance = (TraceFactory)factoryClass.newInstance(); | |||
@@ -47,6 +69,13 @@ public abstract class TraceFactory { | |||
catch (Throwable th) { | |||
if (debug) th.printStackTrace(); | |||
} | |||
/* | |||
* Use default trace | |||
*/ | |||
if (instance == null) { | |||
instance = new DefaultTraceFactory(); | |||
} | |||
if (debug) System.out.println("TraceFactory.instance=" + instance); | |||
} |