Return-Path: Delivered-To: apmail-jakarta-bsf-dev-archive@www.apache.org Received: (qmail 11335 invoked from network); 16 Dec 2006 14:03:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Dec 2006 14:03:33 -0000 Received: (qmail 27608 invoked by uid 500); 16 Dec 2006 12:16:45 -0000 Delivered-To: apmail-jakarta-bsf-dev-archive@jakarta.apache.org Received: (qmail 27514 invoked by uid 500); 16 Dec 2006 12:16:44 -0000 Mailing-List: contact bsf-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Bean Scripting Framework developers" Reply-To: "Bean Scripting Framework developers" Delivered-To: mailing list bsf-dev@jakarta.apache.org Received: (qmail 27503 invoked by uid 500); 16 Dec 2006 12:16:44 -0000 Received: (qmail 27500 invoked by uid 99); 16 Dec 2006 12:16:44 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Dec 2006 04:16:44 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Dec 2006 04:16:35 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 49F0C1A981A; Sat, 16 Dec 2006 04:15:48 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r487795 - in /jakarta/bsf/trunk/src/org/apache/bsf: ./ engines/java/ engines/netrexx/ engines/xslt/ util/ util/event/generator/ Date: Sat, 16 Dec 2006 12:15:47 -0000 To: bsf-cvs@jakarta.apache.org From: rony@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061216121548.49F0C1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rony Date: Sat Dec 16 04:15:45 2006 New Revision: 487795 URL: http://svn.apache.org/viewvc?view=rev&rev=487795 Log: 20061216 1214 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 (possibly easying installation issues considerably). A build of BSF incorporating all these changes can be downloaded from Added: jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java (with props) jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java (with props) Modified: jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java jakarta/bsf/trunk/src/org/apache/bsf/engines/java/JavaEngine.java jakarta/bsf/trunk/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java jakarta/bsf/trunk/src/org/apache/bsf/engines/xslt/XSLTEngine.java jakarta/bsf/trunk/src/org/apache/bsf/util/JavaUtils.java jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java Modified: jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java Sat Dec 16 04:15:45 2006 @@ -34,8 +34,10 @@ 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 @@ -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 @@ "yyyy" a four digit year, "mm" a two digit month, "dd" a two digit day. * -
Example: "240.20061006" - stands for: BSF version 2.4.0 as of 2006-10-06. +
Example: "241.20061208" + stands for: BSF version 2.4.1 as of 2006-12-08. * * * @since 2006-01-17 Added: jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java?view=auto&rev=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java (added) +++ jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java Sat Dec 16 04:15:45 2006 @@ -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 org.apache.commons.logging, + * which is needed for compilation) using the org.apache.commons.logging.Log + * methods. + + Therefore this class implements all the org.apache.commons.logging.Log + methods. If org.apache.commons.logging.LogFactory is available, then this + * class is used to get an org.apache.commons.logging.Log 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 not available then a no-op behaviour + is employed, modelled after org.apache.commons.logging.impl.NoOpLog. + + @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 org.apache.commons.logging.Log, 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("--------------------------------------------------------"); + } +} + Propchange: jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java ------------------------------------------------------------------------------ svn:executable = * Propchange: jakarta/bsf/trunk/src/org/apache/bsf/BSF_Log.java ------------------------------------------------------------------------------ svn:keywords = Author Date Rev Id URL Added: jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java?view=auto&rev=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java (added) +++ jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java Sat Dec 16 04:15:45 2006 @@ -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 org.apache.commons.logging.Log object. + * + It implements the static org.apache.commons.logging.LogFactory.getLog({String|Class} object) + * methods which return an instance of the class org.apache.bsf.BSF_Log, which in + * turn implements all the methods of the org.apache.commons.logging.Log 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); + } +} + Propchange: jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java ------------------------------------------------------------------------------ svn:executable = * Propchange: jakarta/bsf/trunk/src/org/apache/bsf/BSF_LogFactory.java ------------------------------------------------------------------------------ svn:keywords = Author Date Rev Id URL Modified: jakarta/bsf/trunk/src/org/apache/bsf/engines/java/JavaEngine.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/engines/java/JavaEngine.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/engines/java/JavaEngine.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/engines/java/JavaEngine.java Sat Dec 16 04:15:45 2006 @@ -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. *

* @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; Modified: jakarta/bsf/trunk/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/engines/netrexx/NetRexxEngine.java Sat Dec 16 04:15:45 2006 @@ -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;i0; - --i,++uniqueFileOffset) + --i,++uniqueFileOffset) { // Probably a timing hazard here... *************** try Modified: jakarta/bsf/trunk/src/org/apache/bsf/engines/xslt/XSLTEngine.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/engines/xslt/XSLTEngine.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/engines/xslt/XSLTEngine.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/engines/xslt/XSLTEngine.java Sat Dec 16 04:15:45 2006 @@ -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 Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/JavaUtils.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/util/JavaUtils.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/JavaUtils.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/JavaUtils.java Sat Dec 16 04:15:45 2006 @@ -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 java.io.IOException; +import org.apache.bsf.BSF_Log; +import org.apache.bsf.BSF_LogFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.io.IOException; 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) { Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java Sat Dec 16 04:15:45 2006 @@ -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) { Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java?view=diff&rev=487795&r1=487794&r2=487795 ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java Sat Dec 16 04:15:45 2006 @@ -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", ""); --------------------------------------------------------------------- To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: bsf-dev-help@jakarta.apache.org