in src/main/java/org/apache/bsf/BSF_Log.java [72:151]
static { // try to demand load the apache commons logging LogFactory
Class oac_LogFactory_ = null;
//NOTUSED Method oac_LogFactoryGetLog_Clazz_ = null;
Method oac_LogFactoryGetLog_String_ = null;
try // rgf, 20070917: o.k., if not found, try definedClassLoader instead
{
ClassLoader cl= Thread.currentThread().getContextClassLoader();
final String str4Log="org.apache.commons.logging.Log";
Class logClass = null;
if (cl!=null) // use current Thread's context class loader, if set
{
try {
logClass = cl.loadClass(str4Log);
}
catch (final ClassNotFoundException e1) // not found by contextClassLoader
{}
}
if (logClass==null) // not found, try defined class loader instead
{
final ClassLoader defCL=BSFManager.getDefinedClassLoader();
logClass = defCL.loadClass(str4Log);
cl=defCL; // class found, hence we use the definedClassLoader here
}
oac_LogFactory_ = cl.loadClass("org.apache.commons.logging.LogFactory");
// get method with Class object argument
//NOTUSED oac_LogFactoryGetLog_Clazz_ = oac_LogFactory_.getMethod("getLog", new Class[] {Class.class});
// get method with String object argument
oac_LogFactoryGetLog_String_ = oac_LogFactory_.getMethod("getLog", new Class[] {String.class});
// get the Log methods
final String str[][]={{"debug", "isDebugEnabled"},
{"error", "isErrorEnabled"},
{"fatal", "isFatalEnabled"},
{"info", "isInfoEnabled" },
{"trace", "isTraceEnabled"},
{"warn", "isWarnEnabled" }};
int i=0;
for ( ; i<6; i++)
{
final int j=i*3;
meths[j ]=logClass.getMethod(str[i][0], new Class[] {Object.class});
meths[j+1]=logClass.getMethod(str[i][0], new Class[] {Object.class, Throwable.class});
meths[j+2]=logClass.getMethod(str[i][1], new Class[] {} );
}
}
catch (final ClassNotFoundException e)// o.k., so we do not use org.apache.commons.logging in this run
{
if (iDebug>1) {
e.printStackTrace();
}
oac_LogFactory_=null; // make sure it does not get used
oac_LogFactoryGetLog_String_=null; // make sure it does not get used
}
catch (final NoSuchMethodException e)// o.k., so we do not use org.apache.commons.logging in this run
{
if (iDebug>1) {
e.printStackTrace();
}
oac_LogFactory_=null; // make sure it does not get used
oac_LogFactoryGetLog_String_=null; // make sure it does not get used
}
// Set up final fields
oac_LogFactory = oac_LogFactory_;
//NOTUSED oac_LogFactoryGetLog_Clazz = oac_LogFactoryGetLog_Clazz_;
oac_LogFactoryGetLog_String = oac_LogFactoryGetLog_String_;
}