Hi Noel, enclosed please find the message of the bounce message which I could resurrect. It's cc: to [EMAIL PROTECTED] The check-in seemed to have succeeded, so I did not pursue this any further. Regards, ---rony -------- Original Message --------
What was the message on the bounce? Please notify infrastructure@ the next time this happens. --- Noel -------- Original Message --------
Hi! This is the ezmlm program. I'm managing the bsf-dev@jakarta.apache.org mailing list. I'm working for my owner, who can be reached at [EMAIL PROTECTED]. I'm sorry, your message (enclosed) was not accepted by the moderator. If the moderator has made any comments, they are shown below. |
--- Begin Message ---Author: rony Date: Wed Jan 18 23:46:38 2006 New Revision: 370410 URL: http://svn.apache.org/viewcvs?rev=370410&view=rev Log: 2006-01-19 'BSFManager.java': new method String getVersion(); generally: changed Class.forName(...) to Thread.getCurrentThread().getContextClassLoader().loadClass(...): allows using BSF as a Java extension. Modified: jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java jakarta/bsf/trunk/src/org/apache/bsf/util/event/EventAdapterRegistry.java jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/ByteUtility.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/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java Wed Jan 18 23:46:38 2006 @@ -68,16 +68,16 @@ /** * This class is the entry point to the bean scripting framework. An - * application wishing to integrate scripting to a Java app would + * application wishing to integrate scripting to a Java app would * place an instance of a BSFManager in their code and use its services * to register the beans they want to make available for scripting, - * load scripting engines, and run scripts. + * load scripting engines, and run scripts. * <p> * BSFManager serves as the registry of available scripting engines * as well. Loading and unloading of scripting engines is * supported as well. Each BSFManager loads one engine per language. * Several BSFManagers can be created per JVM. - * + * * @author Sanjiva Weerawarana * @author Matthew J. Duftler * @author Sam Ruby @@ -85,13 +85,18 @@ * @author Don Schwarz (added support for registering languages dynamically) */ public class BSFManager { + // version string in the form of: "abb.yyyymmdd", + // where "a" is the major version number, "bb" the minor version number, + // and "yyyymmdd" represents the date in sorted order (four digit year, two digit month, two digit day) + protected static String version="204.20060117"; + // table of registered scripting engines protected static Hashtable registeredEngines = new Hashtable(); // mapping of file extensions to languages protected static Hashtable extn2Lang = new Hashtable(); - // table of scripting engine instances created by this manager. + // table of scripting engine instances created by this manager. // only one instance of a given language engine is created by a single // manager instance. protected Hashtable loadedEngines = new Hashtable(); @@ -105,10 +110,11 @@ // the class loader to use if a class loader is needed. Default is // he who loaded me (which may be null in which case its Class.forName). - protected ClassLoader classLoader = getClass().getClassLoader(); + // protected ClassLoader classLoader = getClass().getClassLoader(); + protected ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // rgf, 2006-01-05 // temporary directory to use to dump temporary files into. Note that - // if class files are dropped here then unless this dir is in the + // if class files are dropped here then unless this dir is in the // classpath or unless the classloader knows to look here, the classes // will not be found. protected String tempDir = "."; @@ -116,7 +122,7 @@ // classpath used by those that need a classpath protected String classPath; - // stores BSFDeclaredBeans representing objects + // stores BSFDeclaredBeans representing objects // introduced by a client of BSFManager protected Vector declaredBeans = new Vector(); @@ -140,10 +146,10 @@ while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = p.getProperty(key); - + StringTokenizer tokens = new StringTokenizer(value, ","); String className = (String) tokens.nextToken(); - + // get the extensions for this language String exts = (String) tokens.nextToken(); StringTokenizer st = new StringTokenizer(exts, "|"); @@ -159,11 +165,11 @@ catch (IOException ex) { ex.printStackTrace(); System.err.println("Error reading Languages file " + ex); - } + } catch (NoSuchElementException nsee) { nsee.printStackTrace(); System.err.println("Syntax error in Languages resource bundle"); - } + } catch (MissingResourceException mre) { mre.printStackTrace(); System.err.println("Initialization error: " + mre.toString()); @@ -174,6 +180,22 @@ pcs = new PropertyChangeSupport(this); } + + /** Returns the version string of BSF. + * + * @return version string in the form ""abb.yyyymmdd"" where + * "a" represents the major version number, + * "bb" the minor version number, + * "yyyy" four digit year, + * "mm" two digit month, and + * "dd" two digit day. + * @since 2006-01-17 + */ + public static String getVersion() + { + return version; + } + /** * Apply the given anonymous function of the given language to the given * parameters and return the resulting value. @@ -206,10 +228,10 @@ Object result = null; try { - final Object resultf = + final Object resultf = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { - return e.apply(sourcef, lineNof, columnNof, + return e.apply(sourcef, lineNof, columnNof, funcBodyf, paramNamesf, argumentsf); } }); @@ -254,12 +276,12 @@ final Vector paramNamesf = paramNames; final Vector argumentsf = arguments; final CodeBuffer cbf = cb; - + try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { - e.compileApply(sourcef, lineNof, columnNof, - funcBodyf, paramNamesf, + e.compileApply(sourcef, lineNof, columnNof, + funcBodyf, paramNamesf, argumentsf, cbf); return null; } @@ -271,7 +293,7 @@ } /** - * Compile the given expression of the given language into the given + * Compile the given expression of the given language into the given * <tt>CodeBuffer</tt>. * * @param lang language identifier @@ -311,7 +333,7 @@ } /** - * Compile the given script of the given language into the given + * Compile the given script of the given language into the given * <tt>CodeBuffer</tt>. * * @param lang language identifier @@ -340,7 +362,7 @@ try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { - e.compileScript(sourcef, lineNof, columnNof, + e.compileScript(sourcef, lineNof, columnNof, scriptf, cbf); return null; } @@ -352,7 +374,7 @@ } /** - * Declare a bean. The difference between declaring and registering + * Declare a bean. The difference between declaring and registering * is that engines are spsed to make declared beans "pre-available" * in the scripts as far as possible. That is, if a script author * needs a registered bean, he needs to look it up in some way. However @@ -366,7 +388,7 @@ * says they don't like this (by throwing an exception) then this * method will simply quit with that exception. That is, any engines * that come after than in the engine enumeration will not even be - * told about this new bean. + * told about this new bean. * <p> * So, in general its best to declare beans before the manager has * been asked to load any engines because then the user can be informed @@ -420,7 +442,7 @@ final int lineNof = lineNo, columnNof = columnNo; final Object exprf = expr; Object result = null; - + try { final Object resultf = AccessController.doPrivileged(new PrivilegedExceptionAction() { @@ -485,7 +507,7 @@ * emulate an interactive session w/ the language. * * @param lang language identifier - * @param source (context info) the source of this expression + * @param source (context info) the source of this expression * (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr @@ -531,7 +553,7 @@ if (classPath == null) { try { classPath = System.getProperty("java.class.path"); - } + } catch (Throwable t) { // prolly a security exception .. so no can do } @@ -541,17 +563,17 @@ /** * Determine the language of a script file by looking at the file - * extension. + * extension. * * @param fileName the name of the file * * @return the scripting language the file is in if the file extension - * is known to me (must have been registered via + * is known to me (must have been registered via * registerScriptingEngine). * * @exception BSFException if file's extension is unknown. */ - public static String getLangFromFilename(String fileName) + public static String getLangFromFilename(String fileName) throws BSFException { int dotIndex = fileName.lastIndexOf("."); @@ -571,7 +593,7 @@ // Test to see if in classpath try { - String engineName = + String engineName = (String) registeredEngines.get(lang); Class.forName(engineName); } @@ -586,7 +608,7 @@ } if (loops == 0) lang = langval; } - + if (lang != null && lang != "") { return lang; } @@ -636,7 +658,7 @@ * * @param lang string identifying language * @exception BSFException if the language is unknown (i.e., if it - * has not been registered) with a reason of + * has not been registered) with a reason of * REASON_UNKNOWN_LANGUAGE. If the language is known but * if the interface can't be created for some reason, then * the reason is set to REASON_OTHER_ERROR and the actual @@ -677,7 +699,7 @@ loadedEngines.put(lang, eng); pcs.addPropertyChangeListener(eng); return eng; - } + } catch (PrivilegedActionException prive) { throw (BSFException) prive.getException(); } @@ -690,7 +712,7 @@ /** * return a handle to a bean registered in the bean registry by the - * application or a scripting engine. Returns null if bean is not found. + * application or a scripting engine. Returns null if bean is not found. * * @param beanName name of bean to look up * @@ -699,14 +721,14 @@ public Object lookupBean(String beanName) { try { return ((BSFDeclaredBean)objectRegistry.lookup(beanName)).bean; - } + } catch (IllegalArgumentException e) { return null; } } - /** - * Registering a bean allows a scripting engine or the application to + /** + * Registering a bean allows a scripting engine or the application to * access that bean by name and to manipulate it. * * @param beanName name to register under @@ -725,7 +747,7 @@ } /** - * Register a scripting engine in the static registry of the + * Register a scripting engine in the static registry of the * BSFManager. * * @param lang string identifying language @@ -771,7 +793,7 @@ /** * Set the object registry used by this manager. By default a new - * one is created when the manager is new'ed and this overwrites + * one is created when the manager is new'ed and this overwrites * that one. * * @param objectRegistry the registry to use @@ -782,13 +804,13 @@ /** * Temporary directory to put stuff into (for those who need to). Note - * that unless this directory is in the classpath or unless the - * classloader knows to look in here, any classes here will not - * be found! BSFManager provides a service method to load a class - * which uses either the classLoader provided by the class loader - * property or, if that fails, a class loader which knows to load from - * the tempdir to try to load the class. Default value of tempDir - * is "." (current working dir). + * that unless this directory is in the classpath or unless the + * classloader knows to look in here, any classes here will not + * be found! BSFManager provides a service method to load a class + * which uses either the classLoader provided by the class loader + * property or, if that fails, a class loader which knows to load from + * the tempdir to try to load the class. Default value of tempDir + * is "." (current working dir). * * @param tempDir the temporary directory */ @@ -848,7 +870,7 @@ } } - /** + /** * Unregister a previously registered bean. Silent if name is not found. * * @param beanName name of bean to unregister Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java URL: http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java Wed Jan 18 23:46:38 2006 @@ -339,7 +339,9 @@ ClassLoader classLoader = mgr.getClassLoader (); try { - return (classLoader == null) ? Class.forName (name) + return (classLoader == null) ? + // Class.forName (name) + Thread.currentThread().getContextClassLoader().loadClass (name) : classLoader.loadClass (name); } catch (ClassNotFoundException e) { // try to load it from the temp dir using my own class loader Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java URL: http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java Wed Jan 18 23:46:38 2006 @@ -67,7 +67,7 @@ * This file is a collection of reflection utilities. There are utilities * for creating beans, getting bean infos, setting/getting properties, * and binding events. - * + * * @author Sanjiva Weerawarana * @author Joseph Kesselman */ @@ -76,19 +76,19 @@ ////////////////////////////////////////////////////////////////////////// /** - * Add an event processor as a listener to some event coming out of an + * Add an event processor as a listener to some event coming out of an * object. - * + * * @param source event source * @param eventSetName name of event set from event src to bind to * @param processor event processor the event should be delegated to * when it occurs; either via processEvent or - * processExceptionableEvent. + * processExceptionableEvent. * * @exception IntrospectionException if unable to introspect * @exception IllegalArgumentException if event set is unknown - * @exception IllegalAccessException if the event adapter class or - * initializer is not accessible. + * @exception IllegalAccessException if the event adapter class or + * initializer is not accessible. * @exception InstantiationException if event adapter instantiation fails * @exception InvocationTargetException if something goes wrong while * running add event listener method @@ -103,7 +103,7 @@ EventSetDescriptor esd = (EventSetDescriptor) findFeatureByName ("event", eventSetName, bi.getEventSetDescriptors ()); if (esd == null) { - throw new IllegalArgumentException ("event set '" + eventSetName + + throw new IllegalArgumentException ("event set '" + eventSetName + "' unknown for source type '" + source.getClass () + "'"); } @@ -128,10 +128,10 @@ Object[] args; if (eventSetName.equals ("propertyChange") || eventSetName.equals ("vetoableChange")) { - // In Java 1.2, beans may have direct listener adding methods + // In Java 1.2, beans may have direct listener adding methods // for property and vetoable change events which take the // property name as a filter to be applied at the event source. - // The filter property of the event processor should be used + // The filter property of the event processor should be used // in this case to support the source-side filtering. // // ** TBD **: the following two lines need to change appropriately @@ -164,16 +164,18 @@ * @exception InvocationTargetException if constructor excepted * @exception IOException if I/O error in beans.instantiate */ - public static Bean createBean (ClassLoader cld, String className, - Class[] argTypes, Object[] args) + public static Bean createBean (ClassLoader cld, String className, + Class[] argTypes, Object[] args) throws ClassNotFoundException, NoSuchMethodException, - InstantiationException, IllegalAccessException, + InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { if (argTypes != null) { // find the right constructor and use that to create bean Class cl = (cld != null) ? cld.loadClass (className) - : Class.forName (className); + : Thread.currentThread().getContextClassLoader().loadClass (className); // rgf, 2006-01-05 + // : Class.forName (className); + Constructor c = MethodUtils.getConstructor (cl, argTypes); return new Bean (cl, c.newInstance (args)); } else { @@ -203,10 +205,10 @@ * @exception InvocationTargetException if constructor excepted * @exception IOException if I/O error in beans.instantiate */ - public static Bean createBean (ClassLoader cld, String className, - Object[] args) + public static Bean createBean (ClassLoader cld, String className, + Object[] args) throws ClassNotFoundException, NoSuchMethodException, - InstantiationException, IllegalAccessException, + InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { Class[] argTypes = null; @@ -221,10 +223,10 @@ ////////////////////////////////////////////////////////////////////////// /** - * locate the item in the fds array whose name is as given. returns + * locate the item in the fds array whose name is as given. returns * null if not found. */ - private static + private static FeatureDescriptor findFeatureByName (String featureType, String name, FeatureDescriptor[] fds) { for (int i = 0; i < fds.length; i++) { @@ -244,7 +246,7 @@ try { Field f = targetClass.getField (fieldName); Class fieldType = f.getType (); - + // Get the value and return it. Object value = f.get (target); return new Bean (fieldType, value); @@ -276,7 +278,7 @@ IllegalAccessException, InvocationTargetException { // find the property descriptor BeanInfo bi = Introspector.getBeanInfo (target.getClass ()); - PropertyDescriptor pd = (PropertyDescriptor) + PropertyDescriptor pd = (PropertyDescriptor) findFeatureByName ("property", propName, bi.getPropertyDescriptors ()); if (pd == null) { throw new IllegalArgumentException ("property '" + propName + "' is " + @@ -290,7 +292,7 @@ // if index != null, then property is indexed - pd better be so too if (!(pd instanceof IndexedPropertyDescriptor)) { throw new IllegalArgumentException ("attempt to get non-indexed " + - "property '" + propName + + "property '" + propName + "' as being indexed"); } IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; @@ -302,7 +304,7 @@ } if (rm == null) { - throw new IllegalArgumentException ("property '" + propName + + throw new IllegalArgumentException ("property '" + propName + "' is not readable"); } @@ -377,12 +379,12 @@ */ public static void setProperty (Object target, String propName, Integer index, Object value, - Class valueType, TypeConvertorRegistry tcr) + Class valueType, TypeConvertorRegistry tcr) throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { // find the property descriptor BeanInfo bi = Introspector.getBeanInfo (target.getClass ()); - PropertyDescriptor pd = (PropertyDescriptor) + PropertyDescriptor pd = (PropertyDescriptor) findFeatureByName ("property", propName, bi.getPropertyDescriptors ()); if (pd == null) { throw new IllegalArgumentException ("property '" + propName + "' is " + @@ -397,7 +399,7 @@ // if index != null, then property is indexed - pd better be so too if (!(pd instanceof IndexedPropertyDescriptor)) { throw new IllegalArgumentException ("attempt to set non-indexed " + - "property '" + propName + + "property '" + propName + "' as being indexed"); } IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; @@ -409,7 +411,7 @@ } if (wm == null) { - throw new IllegalArgumentException ("property '" + propName + + throw new IllegalArgumentException ("property '" + propName + "' is not writeable"); } Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/event/EventAdapterRegistry.java URL: http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/event/EventAdapterRegistry.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/event/EventAdapterRegistry.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/event/EventAdapterRegistry.java Wed Jan 18 23:46:38 2006 @@ -68,13 +68,13 @@ * and if it doesn't find one looks for a standard implementation of * that adapter in the org.apache.bsf.util.event.adapters package with a * standard naming convention. The naming convention it assumes is the - * following: for event listener type <tt>a.b.c.FooListener</tt>, - * it loads an adapter of type + * following: for event listener type <tt>a.b.c.FooListener</tt>, + * it loads an adapter of type * <tt>org.apache.bsf.util.event.adapters.a_b_c_FooAdapter</tt>. * If both the loading and the dynamic generation fail, then a * <code>null</code> is returned. * <p> - * + * * @author Sanjiva Weerawarana * @author Matthew J. Duftler * @see EventAdapter @@ -89,14 +89,17 @@ public static Class lookup (Class listenerType) { String key = listenerType.getName().replace ('.', '_'); Class adapterClass = (Class) reg.get (key); - + if (adapterClass == null) { String en = key.substring (0, key.lastIndexOf ("Listener")); String cn = adapterPackage + "." + en + adapterSuffix; try { // Try to resolve one. - adapterClass = (cl != null) ? cl.loadClass (cn) : Class.forName (cn); + // adapterClass = (cl != null) ? cl.loadClass (cn) : Class.forName (cn); + adapterClass = (cl != null) ? cl.loadClass (cn) + : Thread.currentThread().getContextClassLoader().loadClass (cn); // rgf, 2006-01-05 + } catch (ClassNotFoundException e) { if (dynamic) { // Unable to resolve one, try to generate one. @@ -129,7 +132,7 @@ * If the <code>dynamic</code> property is set to true, and the * <code>ClassLoader</code> is unable to resolve an adapter, one will be * dynamically generated. - * + * * @param dynamic whether or not to dynamically generate adapters. */ public static void setDynamic (boolean dynamic) { Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/ByteUtility.java URL: http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/ByteUtility.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/ByteUtility.java (original) +++ jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/ByteUtility.java Wed Jan 18 23:46:38 2006 @@ -190,7 +190,7 @@ temp += (((long)low[3]) & 0xFF); return temp; } - public static double byteArrayToDounle(byte value[]) + public static double byteArrayToDouble(byte value[]) { byte high[] = new byte[4]; byte low[] = new byte[4]; Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java URL: http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java?rev=370410&r1=370409&r2=370410&view=diff ============================================================================== --- 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 Wed Jan 18 23:46:38 2006 @@ -105,11 +105,12 @@ { WRITEDIRECTORY = WRITEDIRECTORY+"/"; } } try - { EVENTLISTENER = Class.forName("java.util.EventListener"); } + // { EVENTLISTENER = Class.forName("java.util.EventListener"); } + { EVENTLISTENER = Thread.currentThread().getContextClassLoader().loadClass ("java.util.EventListener"); } // rgf, 2006-01-05 catch(ClassNotFoundException ex) - { + { System.err.println(ex.getMessage()); - ex.printStackTrace(); + ex.printStackTrace(); } // start of the Java Class File @@ -243,7 +244,7 @@ return cached; } catch(VerifyError ex) - { + { System.err.println(ex.getMessage()); ex.printStackTrace(); return cached; @@ -559,9 +560,9 @@ fos.close(); } catch(IOException ex) - { + { System.err.println(ex.getMessage()); - ex.printStackTrace(); + ex.printStackTrace(); } try @@ -573,9 +574,9 @@ return ret; } catch (ClassNotFoundException ex) - { - System.err.println(ex.getMessage()); - ex.printStackTrace(); + { + System.err.println(ex.getMessage()); + ex.printStackTrace(); } } @@ -589,9 +590,9 @@ return ret; } catch(Exception ex) - { - System.err.println(ex.getMessage()); - ex.printStackTrace(); + { + System.err.println(ex.getMessage()); + ex.printStackTrace(); } } else
--- End Message ---
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]