Hi there,

in the meantime I was able to work on the logging problem.

The problem: BSF 2.4.0 needs org.apache.commons.logging to be available.
Depending on the location where BSF and commons-logging gets installed,
problems may pop up (e.g. if commons-logging is located in an
ext-directory and an app is employing an own copy of commons-logging).

This solution creates a BSF_LogFactory and BSF_Log class which will by
default behave as an no-op logger. In case commons-logging LogFactory
and Log is available, it will be used. Hence the functionality remains
the same, but the change will allow BSF to run without commons-logging
present.

A build incorporating all the necessary changes can be downloaded from
<http://wi.wu-wien.ac.at/rgf/tmp/bsf.tmp/>.

The diff file is attached to this e-mail .

If I do not hear anything back until the end of the next week, I will
check the changes in.

Regards,

---rony

Index: src/org/apache/bsf/BSF_LogFactory.java
===================================================================
--- src/org/apache/bsf/BSF_LogFactory.java      (revision 0)
+++ src/org/apache/bsf/BSF_LogFactory.java      (revision 0)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bsf;
+
+/** This class is used in BSF as BSF_LogFactory returning a BSF_Log instance, 
which is
+ * a delegator for an <code>org.apache.commons.logging.Log</code> object.
+ *
+ It implements the static 
<code>org.apache.commons.logging.LogFactory.getLog({String|Class} object)</code>
+ * methods which return an instance of the class 
<code>org.apache.bsf.BSF_Log</code>, which in
+ * turn implements all the methods of the 
<code>org.apache.commons.logging.Log</code> interface class.
+ *
+
+   @author Rony G. Flatscher, 2006-12-08
+*/
+
+public class BSF_LogFactory
+{
+    protected BSF_LogFactory() {};              // mimickries 
org.apache.commons.logging.LogFactory
+
+    static public BSF_Log getLog (String name)
+    {
+        return new BSF_Log(name);
+    }
+
+    static public BSF_Log getLog (Class clz)
+    {
+        return new BSF_Log(clz);
+    }
+}
+

Property changes on: src/org/apache/bsf/BSF_LogFactory.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Rev Id URL

Index: src/org/apache/bsf/BSFManager.java
===================================================================
--- src/org/apache/bsf/BSFManager.java  (revision 483957)
+++ src/org/apache/bsf/BSFManager.java  (working copy)
@@ -34,9 +34,11 @@
 
 import org.apache.bsf.util.CodeBuffer;
 import org.apache.bsf.util.ObjectRegistry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
+    // org.apache.commons.logging is delegated to 
"org.apache.bsf.BSF_Log[Factory]"
+// import org.apache.commons.logging.Log;
+// import org.apache.commons.logging.LogFactory;
+
 /**
  * This class is the entry point to the bean scripting framework. An
  * application wishing to integrate scripting to a Java app would
@@ -54,14 +56,15 @@
  * @author   Sam Ruby
  * @author   Olivier Gruber (added original debugging support)
  * @author   Don Schwarz (added support for registering languages dynamically)
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 public class BSFManager {
     // version string is in the form "abc.yyyymmdd" where
     // "abc" represents a dewey decimal number (three levels, each between 0 
and 9),
     // and "yyyy" a four digit year, "mm" a two digit month, "dd" a two digit 
day.
     //
-    // Example: "240.20060925" stands for: BSF version "2.4.0" as of 
"2006-09-25"
-    protected static String version="240.20061006";
+    // Example: "241.20061208" stands for: BSF version "2.4.1" as of 
"2006-12-08"
+    protected static String version="241.20061208";
 
     // table of registered scripting engines
     protected static Hashtable registeredEngines = new Hashtable();
@@ -99,7 +102,8 @@
     // introduced by a client of BSFManager
     protected Vector declaredBeans = new Vector();
 
-    private Log logger = LogFactory.getLog(this.getClass().getName());
+    // private Log logger = LogFactory.getLog(this.getClass().getName());
+    private BSF_Log logger = null;
 
     //////////////////////////////////////////////////////////////////////
     //
@@ -154,6 +158,9 @@
 
     public BSFManager() {
         pcs = new PropertyChangeSupport(this);
+            // handle logger
+        // logger = LogFactory.getLog(this.getClass().getName());
+        logger = BSF_LogFactory.getLog(this.getClass().getName());
     }
 
 
@@ -164,8 +171,8 @@
        &quot;yyyy&quot; a four digit year, &quot;mm&quot; a two digit month,
        &quot;dd&quot; a two digit day.
     *
-       <br>Example: &quot;<code>240.20061006</code>&quot;
-       stands for: BSF version <code>2.4.0</code> as of 
<code>2006-10-06</code>.
+       <br>Example: &quot;<code>241.20061208</code>&quot;
+       stands for: BSF version <code>2.4.1</code> as of 
<code>2006-12-08</code>.
     *
     *
      * @since 2006-01-17
Index: src/org/apache/bsf/engines/java/JavaEngine.java
===================================================================
--- src/org/apache/bsf/engines/java/JavaEngine.java     (revision 483957)
+++ src/org/apache/bsf/engines/java/JavaEngine.java     (working copy)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,14 +25,15 @@
 
 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
+
 import org.apache.bsf.util.BSFEngineImpl;
 import org.apache.bsf.util.CodeBuffer;
 import org.apache.bsf.util.EngineUtils;
 import org.apache.bsf.util.JavaUtils;
 import org.apache.bsf.util.MethodUtils;
 import org.apache.bsf.util.ObjInfo;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * This is the interface to Java from the
@@ -80,6 +81,7 @@
  * provide better control over when and how much overhead occurs.
  * <p>
  * @author Joe Kesselman
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 public class JavaEngine extends BSFEngineImpl {
     Class javaclass = null;
@@ -87,9 +89,10 @@
     static String serializeCompilation = "";
     static String placeholder = "$$CLASSNAME$$";
     String minorPrefix;
-        
-    private Log logger = LogFactory.getLog(this.getClass().getName());
-    
+
+    // private Log logger = LogFactory.getLog(this.getClass().getName());
+    private BSF_Log logger = null;
+
     /**
      * Create a scratchfile, open it for writing, return its name.
      * Relies on the filesystem to provide us with uniqueness testing.
@@ -98,7 +101,7 @@
      * even if the classfile has been deleted.
      */
     private int uniqueFileOffset = -1;
-    
+
     private class GeneratedFile {
         File file = null;
         FileOutputStream fos = null;
@@ -109,33 +112,35 @@
             this.className = className;
         }
     }
-    
+
     /**
      * Constructor.
      */
     public JavaEngine () {
+            // handle logger
+        logger = BSF_LogFactory.getLog(this.getClass().getName());
         // Do compilation-possible check here??????????????
     }
-    
-    public Object call (Object object, String method, Object[] args) 
+
+    public Object call (Object object, String method, Object[] args)
     throws BSFException
     {
         throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
         "call() is not currently supported by JavaEngine");
     }
-    
+
     public void compileScript (String source, int lineNo, int columnNo,
             Object script, CodeBuffer cb) throws BSFException {
         ObjInfo oldRet = cb.getFinalServiceMethodStatement ();
-        
+
         if (oldRet != null && oldRet.isExecutable ()) {
             cb.addServiceMethodStatement (oldRet.objName + ";");
         }
-        
+
         cb.addServiceMethodStatement (script.toString ());
         cb.setFinalServiceMethodStatement (null);
     }
-    
+
     /**
      * This is used by an application to evaluate a string containing
      * some expression. It should store the "bsf" handle where the
@@ -153,20 +158,20 @@
      * We will attempt to use it, then if necessary fall back on invoking
      * javac via the command line.
      */
-    public Object eval (String source, int lineNo, int columnNo, 
+    public Object eval (String source, int lineNo, int columnNo,
             Object oscript) throws BSFException
             {
         Object retval = null;
         String classname = null;
         GeneratedFile gf = null;
-        
+
         String basescript = oscript.toString();
         String script = basescript;    // May be altered by $$CLASSNAME$$ 
expansion
-        
+
         try {
             // Do we already have a class exactly matching this code?
             javaclass = (Class)codeToClass.get(basescript);
-            
+
             if(javaclass != null) {
                 classname=javaclass.getName();
             } else {
@@ -176,14 +181,14 @@
                 }
                 // Obtain classname
                 classname = gf.className;
-                
+
                 // Write the kluge header to the file.
                 gf.fos.write(("import java.lang.*;"+
                         "import java.util.*;"+
                         "public class "+classname+" {\n" +
                 "  static public Object 
BSFJavaEngineEntry(org.apache.bsf.BSFManager bsf) {\n")
                 .getBytes());
-                
+
                 // Edit the script to replace placeholder with the generated
                 // classname. Note that this occurs _after_ the cache was 
checked!
                 int startpoint = script.indexOf(placeholder);
@@ -203,63 +208,63 @@
                         script = changed.toString();
                     }
                 }
-                
+
                 // MJD - debug
 //              BSFDeclaredBean tempBean;
 //              String          className;
-//              
+//
 //              for (int i = 0; i < declaredBeans.size (); i++) {
 //              tempBean  = (BSFDeclaredBean) declaredBeans.elementAt (i);
 //              className = StringUtils.getClassName (tempBean.bean.getClass 
());
-//              
+//
 //              gf.fos.write ((className + " " +
 //              tempBean.name + " = (" + className +
 //              ")bsf.lookupBean(\"" +
 //              tempBean.name + "\");").getBytes ());
 //              }
                 // MJD - debug
-                
+
                 // Copy the input to the file.
                 // Assumes all available -- probably mistake, but same as 
other engines.
                 gf.fos.write(script.getBytes());
                 // Close the method and class
                 gf.fos.write(("\n  }\n}\n").getBytes());
                 gf.fos.close();
-                
+
                 // Compile through Java to .class file
                 // May not be threadsafe. Serialize access on static object:
                 synchronized(serializeCompilation) {
                     JavaUtils.JDKcompile(gf.file.getPath(), classPath);
                 }
-                
+
                 // Load class.
                 javaclass = EngineUtils.loadClass(mgr, classname);
-                
+
                 // Stash class for reuse
                 codeToClass.put(basescript, javaclass);
             }
-            
-            Object[] callArgs = {mgr};      
+
+            Object[] callArgs = {mgr};
             retval = internalCall(this,"BSFJavaEngineEntry",callArgs);
         }
-        
-        
+
+
         catch(Exception e) {
             e.printStackTrace ();
             throw new BSFException (BSFException.REASON_IO_ERROR, e.getMessage 
());
         } finally {
             // Cleanup: delete the .java and .class files
-            
+
 //          if(gf!=null && gf.file!=null && gf.file.exists())
 //          gf.file.delete();  // .java file
-            
-            
+
+
             if(classname!=null) {
                 // Generated class
                 File file = new 
File(tempDir+File.separatorChar+classname+".class");
 //              if(file.exists())
 //              file.delete();
-                
+
                 // Search for and clean up minor classes, classname$xxx.class
                 file = new File(tempDir);  // ***** Is this required?
                 minorPrefix = classname+"$"; // Indirect arg to filter
@@ -281,7 +286,7 @@
         }
         return retval;
     }
-    
+
     public void initialize (BSFManager mgr, String lang,
             Vector declaredBeans) throws BSFException {
         super.initialize (mgr, lang, declaredBeans);
@@ -294,7 +299,7 @@
      * passed to the extension, which may be either
      * Vectors of Nodes, or Strings.
      */
-    Object internalCall (Object object, String method, Object[] args) 
+    Object internalCall (Object object, String method, Object[] args)
     throws BSFException
     {
         //***** ISSUE: Only static methods are currently supported
@@ -315,7 +320,7 @@
         }
         return retval;
     }
-    
+
     private GeneratedFile openUniqueFile(String directory,String prefix,String 
suffix) {
         File file = null;
         FileOutputStream fos = null;
Index: src/org/apache/bsf/engines/xslt/XSLTEngine.java
===================================================================
--- src/org/apache/bsf/engines/xslt/XSLTEngine.java     (revision 483957)
+++ src/org/apache/bsf/engines/xslt/XSLTEngine.java     (working copy)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,36 +31,45 @@
 import org.apache.bsf.BSFDeclaredBean;
 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
 import org.apache.bsf.util.BSFEngineImpl;
 import org.apache.bsf.util.BSFFunctions;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.xpath.objects.XObject;
 import org.w3c.dom.Node;
 
 /**
  * Xerces XSLT interface to BSF. Requires Xalan and Xerces from Apache.
- * 
+ *
  * This integration uses the BSF registry to pass in any src document
- * and stylesheet base URI that the user may wish to set. 
+ * and stylesheet base URI that the user may wish to set.
  *
  * @author   Sanjiva Weerawarana
  * @author   Sam Ruby
  *
  * Re-implemented for the Xalan 2 codebase
- * 
+ *
  * @author   Victor J. Orlikowski
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 public class XSLTEngine extends BSFEngineImpl {
     TransformerFactory tFactory;
     Transformer transformer;
-    
-    Log logger = LogFactory.getLog(this.getClass().getName());
 
+    // Log logger = LogFactory.getLog(this.getClass().getName());
+    BSF_Log logger = null;
+
+    public XSLTEngine ()
+    {
+            // handle logger
+        logger = BSF_LogFactory.getLog(this.getClass().getName());
+    }
+
+
     /**
      * call the named method of the given object.
      */
-    public Object call (Object object, String method, Object[] args) 
+    public Object call (Object object, String method, Object[] args)
         throws BSFException {
        throw new BSFException (BSFException.REASON_UNSUPPORTED_FEATURE,
                                 "BSF:XSLTEngine can't call methods");
@@ -77,7 +86,7 @@
      * Evaluate an expression. In this case, an expression is assumed
      * to be a stylesheet of the template style (see the XSLT spec).
      */
-    public Object eval (String source, int lineNo, int columnNo, 
+    public Object eval (String source, int lineNo, int columnNo,
                         Object oscript) throws BSFException {
        // get the style base URI (the place from where Xerces XSLT will
        // look for imported/included files and referenced docs): if a
@@ -90,7 +99,7 @@
        // Locate the stylesheet.
        StreamSource styleSource;
 
-        styleSource = 
+        styleSource =
             new StreamSource(new StringReader(oscript.toString ()));
         styleSource.setSystemId(styleBaseURI);
 
@@ -143,21 +152,21 @@
                }
             }
        } else {
-            // create an empty document - real src must come into the 
+            // create an empty document - real src must come into the
             // stylesheet using "doc(...)" [see XSLT spec] or the stylesheet
             // must be of literal result element type
             xis = new StreamSource();
        }
-       
+
        // set all declared beans as parameters.
        for (int i = 0; i < declaredBeans.size (); i++) {
             BSFDeclaredBean b = (BSFDeclaredBean) declaredBeans.elementAt (i);
             transformer.setParameter (b.name, new XObject (b.bean));
        }
 
-       // declare a "bsf" parameter which is the BSF handle so that 
+       // declare a "bsf" parameter which is the BSF handle so that
        // the script can do BSF stuff if it wants to
-       transformer.setParameter ("bsf", 
+       transformer.setParameter ("bsf",
                                   new XObject (new BSFFunctions (mgr, this)));
 
        // do it
Index: src/org/apache/bsf/engines/netrexx/NetRexxEngine.java
===================================================================
--- src/org/apache/bsf/engines/netrexx/NetRexxEngine.java       (revision 
483957)
+++ src/org/apache/bsf/engines/netrexx/NetRexxEngine.java       (working copy)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,13 +28,13 @@
 import org.apache.bsf.BSFDeclaredBean;
 import org.apache.bsf.BSFException;
 import org.apache.bsf.BSFManager;
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
 import org.apache.bsf.util.BSFEngineImpl;
 import org.apache.bsf.util.BSFFunctions;
 import org.apache.bsf.util.EngineUtils;
 import org.apache.bsf.util.MethodUtils;
 import org.apache.bsf.util.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * This is the interface to NetRexx from the
@@ -78,6 +78,7 @@
  *
  * @author  Joe Kesselman
  * @author  Sanjiva Weerawarana
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 public class NetRexxEngine extends BSFEngineImpl
 {
@@ -86,9 +87,10 @@
        static String serializeCompilation="";
        static String placeholder="$$CLASSNAME$$";
        String minorPrefix;
-       
-       private Log logger = LogFactory.getLog(this.getClass().getName());
-         
+
+       // private Log logger = LogFactory.getLog(this.getClass().getName());
+       private BSF_Log logger = null;
+
        /**
         * Create a scratchfile, open it for writing, return its name.
         * Relies on the filesystem to provide us with uniqueness testing.
@@ -100,41 +102,43 @@
         * of the NetRexx engine.
         */
   private static int uniqueFileOffset=0;
-  private class GeneratedFile 
+  private class GeneratedFile
   {
        File file=null;
        FileOutputStream fos=null;
        String className=null;
-       GeneratedFile(File file,FileOutputStream fos,String className) 
+       GeneratedFile(File file,FileOutputStream fos,String className)
          {
                  this.file=file;
                  this.fos=fos;
                  this.className=className;
          }
   }
-       
+
        // rexxclass used to be an instance variable, on the theory that
        // each NetRexxEngine was an instance of a specific script.
        // BSF is currently reusing Engines, so caching the class
        // no longer makes sense.
        // Class rexxclass;
-       
+
        /**
         * Constructor.
         */
        public NetRexxEngine ()
        {
+                    // handle logger
+                logger = BSF_LogFactory.getLog(this.getClass().getName());
                /*
                  The following line is intended to cause the constructor to
                  throw a NoClassDefFoundError if the NetRexxC.zip dependency
                  is not resolved.
-                 
+
                  If this line was not here, the problem would not surface until
                  the actual processing of a script. We want to know all is well
                  at the time the engine is instantiated, not when we attempt to
                  process a script.
                  */
-               
+
                new netrexx.lang.BadArgumentException();
        }
        /**
@@ -145,7 +149,7 @@
         * passed to the extension, which may be either
         * Vectors of Nodes, or Strings.
         */
-       public Object call (Object object, String method, Object[] args) 
+       public Object call (Object object, String method, Object[] args)
        throws BSFException
        {
                throw new BSFException(BSFException.REASON_UNSUPPORTED_FEATURE,
@@ -160,7 +164,7 @@
         * passed to the extension, which may be either
         * Vectors of Nodes, or Strings.
         */
-       Object callStatic(Class rexxclass, String method, Object[] args) 
+       Object callStatic(Class rexxclass, String method, Object[] args)
        throws BSFException
        {
                //***** ISSUE: Currently supports only static methods
@@ -173,7 +177,7 @@
                                Class[] argtypes=new Class[args.length];
                                for(int i=0;i<args.length;++i)
                                        argtypes[i]=args[i].getClass();
-                               
+
                                Method m=MethodUtils.getMethod(rexxclass, 
method, argtypes);
                                retval=m.invoke(null,args);
                        }
@@ -243,26 +247,26 @@
         * Nobody knows whether javac is threadsafe.
         * I'm going to serialize access to the compilers to protect it.
         */
-       public Object execEvalShared (String source, int lineNo, int columnNo, 
+       public Object execEvalShared (String source, int lineNo, int columnNo,
                                                          Object 
oscript,boolean returnsObject)
        throws BSFException
        {
                Object retval=null;
                String classname=null;
                GeneratedFile gf=null;
-               
+
                // Moved into the exec process; see comment above.
                Class rexxclass=null;
-               
+
                String basescript=oscript.toString();
                String script=basescript; // May be altered by $$CLASSNAME$$ 
expansion
-               
+
                try {
                     // Do we already have a class exactly matching this code?
                     rexxclass=(Class)codeToClass.get(basescript);
-                    
+
                     if(rexxclass!=null)
-                       
+
                        {
                             logger.debug("NetRexxEngine: Found pre-compiled 
class" +
                                                    " for script '" + 
basescript + "'");
@@ -273,15 +277,15 @@
                             gf=openUniqueFile(tempDir,"BSFNetRexx",".nrx");
                             if(gf==null)
                                 throw new BSFException("couldn't create 
NetRexx scratchfile");
-                            
+
                             // Obtain classname
                             classname=gf.className;
-                            
+
                             // Decide whether to declare a return type
                             String returnsDecl="";
                             if(returnsObject)
                                 returnsDecl="returns java.lang.Object";
-                            
+
                             // Write the kluge header to the file.
                             // ***** By doing so we give up the ability to use 
Property blocks.
                             gf.fos.write(("class "+classname+";\n")
@@ -290,7 +294,7 @@
                                          ("method 
BSFNetRexxEngineEntry(bsf=org.apache.bsf.util.BSFFunctions) "+
                                           " public static "+returnsDecl+";\n")
                                                                 .getBytes());
-                               
+
                             // Edit the script to replace placeholder with the 
generated
                             // classname. Note that this occurs _after_ the 
cache was
                             // checked!
@@ -312,50 +316,50 @@
                                             script=changed.toString();
                                        }
                                }
-                            
+
                             BSFDeclaredBean tempBean;
                             String          className;
-                            
+
                             for (int i = 0; i < declaredBeans.size (); i++)
                                {
                                     tempBean  = (BSFDeclaredBean) 
declaredBeans.elementAt (i);
                                     className = StringUtils.getClassName 
(tempBean.type);
-                                    
+
                                     gf.fos.write ((tempBean.name + " =" + 
className + "   bsf.lookupBean(\"" +
                                                    tempBean.name + 
"\");").getBytes());
                                }
-                            
+
                             if(returnsObject)
                                 gf.fos.write("return ".getBytes());
-                            
+
                             // Copy the input to the file.
                             // Assumes all available -- probably mistake, but 
same as
                             // other engines.
                             gf.fos.write(script.getBytes());
                             gf.fos.close();
-                            
-                            logger.debug("NetRexxEngine: wrote temp file " + 
+
+                            logger.debug("NetRexxEngine: wrote temp file " +
                                                    gf.file.getPath () + ", now 
compiling");
-                            
+
                             // Compile through Java to .class file
                     String command=gf.file.getPath(); //classname;
-                    if (logger.isDebugEnabled()) {  
+                    if (logger.isDebugEnabled()) {
                        command += " -verbose4";
                     } else {
                         command += " -noverbose";
                         command += " -noconsole";
                     }
-                    
+
                     netrexx.lang.Rexx cmdline= new netrexx.lang.Rexx(command);
                     int retValue;
-                    
+
                     // May not be threadsafe. Serialize access on static 
object:
                     synchronized(serializeCompilation)
                         {
                             // compile to a .java file
                             retValue =
                                 COM.ibm.netrexx.process.NetRexxC.main(cmdline,
-                                                                      new 
PrintWriter(System.err)); 
+                                                                      new 
PrintWriter(System.err));
                         }
 
                                // Check if there were errors while compiling 
the Rexx code.
@@ -396,27 +400,27 @@
                {
                        // Cleanup: delete the .nrx and .class files
                        // (if any) generated by NetRexx Trace requests.
-                       
+
                        if(gf!=null && gf.file!=null && gf.file.exists())
                                gf.file.delete();  // .nrx file
-                       
+
                        if(classname!=null)
                        {
                                // Generated src
                                File file=new 
File(tempDir+File.separatorChar+classname+".java");
                                if(file.exists())
                                        file.delete();
-                               
+
                                // Generated class
                                file=new File(classname+".class");
                                if(file.exists())
                                        file.delete();
-                               
+
                                // Can this be done without disrupting trace?
                                file=new 
File(tempDir+File.separatorChar+classname+".crossref");
                                if(file.exists())
                                        file.delete();
-                               
+
                                // Search for and clean up minor classes, 
classname$xxx.class
                                file=new File(tempDir);
                                minorPrefix=classname+"$"; // Indirect arg to 
filter
@@ -444,7 +448,7 @@
                                        }
                        }
                }
-               
+
                return retval;
        }
        public void initialize(BSFManager mgr, String lang,Vector declaredBeans)
@@ -463,7 +467,7 @@
                String className = null;
                for(i=max,++uniqueFileOffset;
                        fos==null && i>0;
-                       --i,++uniqueFileOffset)     
+                       --i,++uniqueFileOffset)
                {
                        // Probably a timing hazard here... ***************
                        try
Index: src/org/apache/bsf/BSF_Log.java
===================================================================
--- src/org/apache/bsf/BSF_Log.java     (revision 0)
+++ src/org/apache/bsf/BSF_Log.java     (revision 0)
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.bsf;
+import  java.lang.reflect.*;
+
+/** This class is used in BSF for logging (a delegator for 
<em>org.apache.commons.logging</em>,
+ *  which is needed for compilation) using the 
<code>org.apache.commons.logging.Log</code>
+ *  methods.
+
+ Therefore this class implements all the  
<code>org.apache.commons.logging.Log</code>
+ methods. If <code>org.apache.commons.logging.LogFactory</code> is available, 
then this
+ * class is used to get an <code>org.apache.commons.logging.Log</code> 
instance to which to
+ * forward the message.
+
+ *  Therefore, if Apache's common logging is available, then it is employed.
+ * If Apache's commons logging is <em>not</em> available then a <em>no-op</em> 
behaviour
+ is employed, modelled after 
<code>org.apache.commons.logging.impl.NoOpLog</code>.
+
+   @author Rony G. Flatscher, 2006-12-08
+*/
+
+public class BSF_Log // implements org.apache.commons.logging.Log
+{
+    static private Class       oac_LogFactory              = null;
+    static private Method      oac_LogFactoryGetLog_Clazz  = null;
+    static private Method      oac_LogFactoryGetLog_String = null;
+
+    {           // try to demand load the apache commons logging LogFactory
+        try
+        {
+            ClassLoader cl= Thread.currentThread().getContextClassLoader();
+            oac_LogFactory = 
cl.loadClass("org.apache.commons.logging.LogFactory");
+
+                // get method with Class object argument
+            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});
+        }
+
+        catch (ClassNotFoundException e) { ; }  // o.k., so we do not use 
org.apache.commons.logging in this run
+        catch (NoSuchMethodException  e) { ; }  // o.k., so we do not use 
org.apache.commons.logging in this run
+    }
+
+
+    /** Name of the BSF_Log instance. */
+    String name=null;
+
+    /** Proxy object for <em>org.apache.commons.logging.Log</em>, if 
available. */
+    private Object oac_logger=null;
+
+
+    public BSF_Log()
+    {
+        this.name="<?>";
+        if (oac_LogFactory!=null)
+        {
+            try     // try to get an org.apache.commons.logging.Log object 
from the LogFactory
+            {
+                oac_logger=oac_LogFactoryGetLog_String.invoke(oac_LogFactory, 
new Object[] {this.name});
+            }
+            catch (Exception e) { e.printStackTrace(); }
+        }
+    };
+
+    public BSF_Log(String name)
+    {
+        this.name=name;
+        if (oac_LogFactory!=null)
+        {
+            try     // try to get an org.apache.commons.logging.Log object 
from the LogFactory
+            {
+                oac_logger=oac_LogFactoryGetLog_String.invoke(oac_LogFactory, 
new Object[] {name});
+            }
+            catch (Exception e) { e.printStackTrace(); }
+        }
+    };
+
+    public BSF_Log(Class clazz)
+    {
+        this.name=clazz.getName();
+        if (oac_LogFactory!=null)
+        {
+            try     // try to get an org.apache.commons.logging.Log object 
from the LogFactory
+            {
+                oac_logger=oac_LogFactoryGetLog_Clazz.invoke(oac_LogFactory, 
new Object[] {clazz});
+            }
+            catch (Exception e) { e.printStackTrace(); }
+        }
+    };
+
+    // --------------------------------------------------------------------
+    public void debug(Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).debug(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void debug(Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).debug(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    // --------------------------------------------------------------------
+    public void error(Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).error(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void error(Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).error(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+
+    // --------------------------------------------------------------------
+    public void fatal(Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).fatal(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void fatal(Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).fatal(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+
+    // --------------------------------------------------------------------
+    public void info (Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).info(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void info (Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).info(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+
+    // --------------------------------------------------------------------
+    public void trace(Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).trace(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void trace(Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).trace(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+
+    // --------------------------------------------------------------------
+    public void warn (Object msg)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).warn(msg);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+    public void warn (Object msg, Throwable t)
+    {
+        if (oac_logger==null) return;   // no org.apache.commons.logging.Log 
object ?
+
+        try
+        {
+            ((org.apache.commons.logging.Log) oac_logger).warn(msg, t);
+        }
+        catch (Exception e) { e.printStackTrace(); }
+    };
+
+
+    // --------------------------------------------------------------------
+    // --------------------------------------------------------------------
+    public boolean isDebugEnabled()
+    {
+        if (oac_logger==null) {return false;}   // no 
org.apache.commons.logging.Log object ?
+
+        try
+            {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isDebugEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+    public boolean isErrorEnabled()
+    {
+        if (oac_logger==null) return false;     // no 
org.apache.commons.logging.Log object ?
+
+        try
+        {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isErrorEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+    public boolean isFatalEnabled()
+    {
+        if (oac_logger==null) return false;     // no 
org.apache.commons.logging.Log object ?
+
+        try
+        {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isFatalEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+    public boolean isInfoEnabled ()
+    {
+        if (oac_logger==null) return false;     // no 
org.apache.commons.logging.Log object ?
+
+        try
+        {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isInfoEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+    public boolean isTraceEnabled()
+    {
+        if (oac_logger==null) return false;     // no 
org.apache.commons.logging.Log object ?
+
+        try
+        {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isTraceEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+    public boolean isWarnEnabled ()
+    {
+        if (oac_logger==null) return false;     // no 
org.apache.commons.logging.Log object ?
+
+        try
+        {
+            return ((org.apache.commons.logging.Log) 
oac_logger).isWarnEnabled();
+        }
+        catch (Exception e) { ; }
+        finally             { return false; }
+    }
+
+
+        // for development purposes only (to debug this class on its own)
+    public static void main (String args[]) {
+        System.out.println("in BSF_Log ...");
+        
System.out.println("--------------------------------------------------------");
+        
System.out.println("--------------------------------------------------------");
+        BSF_Log bl=new BSF_Log();
+        dump(bl);
+        bl=new BSF_Log(Class.class);
+        dump(bl);
+        bl=new BSF_Log("Rony was here...");
+        dump(bl);
+
+    }
+
+    static void dump(BSF_Log bl)
+    {
+        System.out.println("\n\tbl=["+bl+"] <<<---   <<<---   <<<---");
+        bl.debug("debug message. ");
+        bl.error("error message. ");
+        bl.fatal("fatal message. ");
+        bl.info ("info  message. ");
+        bl.trace("trace message. ");
+        bl.warn ("warn  message. ");
+
+        System.out.println("\tisDebugEnabled: "+bl.isDebugEnabled());
+        System.out.println("\tisErrorEnabled: "+bl.isErrorEnabled());
+        System.out.println("\tisFatalEnabled: "+bl.isFatalEnabled());
+        System.out.println("\tisInfo Enabled: "+bl.isInfoEnabled());
+        System.out.println("\tisTraceEnabled: "+bl.isTraceEnabled());
+        System.out.println("\tisWarn Enabled: "+bl.isWarnEnabled());
+
+        System.out.println("\tbl=["+bl+"] --->>>   --->>>   --->>>");
+        
System.out.println("--------------------------------------------------------");
+    }
+}
+

Property changes on: src/org/apache/bsf/BSF_Log.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Rev Id URL

Index: src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java
===================================================================
--- src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java  
(revision 483957)
+++ src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java  
(working copy)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,16 +16,18 @@
 
 package org.apache.bsf.util.event.generator;
 
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
+
 import java.io.FileOutputStream;
 import java.io.IOException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /** EventAdapterGenerator
   *
   * Generate an "Event Adapter" dynamically during program execution
   *
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
   **/
 public class EventAdapterGenerator
 {
@@ -44,13 +46,13 @@
   // the initialization method, noargs constructor
   static byte   INITMETHOD[];
 
-  private static Log logger;
+  private static BSF_Log logger=null;
 
   /* The static initializer */
   static
   {
-       logger = LogFactory.getLog(
-                               
(org.apache.bsf.util.event.generator.EventAdapterGenerator.class).getName());
+       // logger = 
LogFactory.getLog((org.apache.bsf.util.event.generator.EventAdapterGenerator.class).getName());
+        logger = 
BSF_LogFactory.getLog((org.apache.bsf.util.event.generator.EventAdapterGenerator.class).getName());
 
        String USERCLASSPACKAGE = System.getProperty("DynamicEventClassPackage",
                                                                                
                 "");
Index: src/org/apache/bsf/util/event/generator/AdapterClassLoader.java
===================================================================
--- src/org/apache/bsf/util/event/generator/AdapterClassLoader.java     
(revision 483957)
+++ src/org/apache/bsf/util/event/generator/AdapterClassLoader.java     
(working copy)
@@ -1,36 +1,41 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
+ *
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 
 package org.apache.bsf.util.event.generator;
 
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
+
 import java.util.Hashtable;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 public class AdapterClassLoader extends ClassLoader
 {
   private static Hashtable classCache = new Hashtable();
   private Class c;
 
-  private Log logger = LogFactory.getLog(this.getClass().getName());
+  // private Log logger = LogFactory.getLog(this.getClass().getName());
+  private BSF_Log logger = null;
 
   public AdapterClassLoader()
   {
        super();
+        logger = BSF_LogFactory.getLog(this.getClass().getName());
   }
   public synchronized Class defineClass(String name, byte[] b)
   {
Index: src/org/apache/bsf/util/JavaUtils.java
===================================================================
--- src/org/apache/bsf/util/JavaUtils.java      (revision 483957)
+++ src/org/apache/bsf/util/JavaUtils.java      (working copy)
@@ -1,34 +1,36 @@
 /*
  * Copyright 2004,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
+ *
+ * @author   Rony G. Flatscher (added BSF_Log[Factory] to allow BSF to run 
without org.apache.commons.logging present)
  */
 
 package org.apache.bsf.util;
 
+import org.apache.bsf.BSF_Log;
+import org.apache.bsf.BSF_LogFactory;
+
 import java.io.IOException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 public class JavaUtils {
        // Temporarily copied from JavaEngine...
 
-       private static Log logger;
+       private static BSF_Log logger=null;
 
        static {
-               logger = LogFactory.getLog((org.apache.bsf.util.JavaUtils.class)
-                               .getName());
+                    // handle logger
+                logger = 
BSF_LogFactory.getLog((org.apache.bsf.util.JavaUtils.class).getName());
        }
 
        public static boolean JDKcompile(String fileName, String classPath) {
Index: build-properties.xml
===================================================================
--- build-properties.xml        (revision 483957)
+++ build-properties.xml        (working copy)
@@ -2,7 +2,7 @@
 <project name="props">
     <property name="project.name" value="bsf"/>
     <property name="project.fullName" value="Bean Scripting Framework"/>
-    <property name="project.version" value="2.4.0-20061006"/>
+    <property name="project.version" value="2.4.1-20061208"/>
     <property name="project.debug" value="on"/>
     <property name="project.deprecation" value="on"/>
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to