Author: rony
Date: Mon Mar 27 10:27:31 2006
New Revision: 389218
URL: http://svn.apache.org/viewcvs?rev=389218&view=rev
Log:
2006-03-27 Fix for dynamic event adapter creation bug, added
EngineUtils.addEventListenerReturningEventInfos() allowing access to supplied
event-object, contains special transient OpenOffice.org (OOo) support code for
event adapter creations (applicable for OOo version <= 2.0.3).
Added:
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
(with props)
Modified:
jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessor.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/AdapterClassLoader.java
jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/EventAdapterGenerator.java
jakarta/bsf/trunk/xdocs/projects.xml
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=389218&r1=389217&r2=389218&view=diff
==============================================================================
--- jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java (original)
+++ jakarta/bsf/trunk/src/org/apache/bsf/BSFManager.java Mon Mar 27 10:27:31
2006
@@ -90,7 +90,7 @@
// 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";
+ protected static String version="205.20060327";
// table of registered scripting engines
protected static Hashtable registeredEngines = new Hashtable();
@@ -127,7 +127,7 @@
// stores BSFDeclaredBeans representing objects
// introduced by a client of BSFManager
protected Vector declaredBeans = new Vector();
-
+
private Log logger = LogFactory.getLog(this.getClass().getName());
//////////////////////////////////////////////////////////////////////
@@ -224,7 +224,7 @@
Vector arguments)
throws BSFException {
logger.debug("BSFManager:apply");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -277,7 +277,7 @@
CodeBuffer cb)
throws BSFException {
logger.debug("BSFManager:compileApply");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -324,7 +324,7 @@
CodeBuffer cb)
throws BSFException {
logger.debug("BSFManager:compileExpr");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -367,7 +367,7 @@
CodeBuffer cb)
throws BSFException {
logger.debug("BSFManager:compileScript");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -422,7 +422,7 @@
public void declareBean(String beanName, Object bean, Class type)
throws BSFException {
logger.debug("BSFManager:declareBean");
-
+
registerBean(beanName, bean);
BSFDeclaredBean tempBean = new BSFDeclaredBean(beanName, bean, type);
@@ -456,7 +456,7 @@
Object expr)
throws BSFException {
logger.debug("BSFManager:eval");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -506,7 +506,7 @@
Object script)
throws BSFException {
logger.debug("BSFManager:exec");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -546,7 +546,7 @@
Object script)
throws BSFException {
logger.debug("BSFManager:iexec");
-
+
final BSFEngine e = loadScriptingEngine(lang);
final String sourcef = source;
final int lineNof = lineNo, columnNof = columnNo;
@@ -696,7 +696,7 @@
*/
public BSFEngine loadScriptingEngine(String lang) throws BSFException {
logger.debug("BSFManager:loadScriptingEngine");
-
+
// if its already loaded return that
BSFEngine eng = (BSFEngine) loadedEngines.get(lang);
if (eng != null) {
@@ -755,7 +755,7 @@
*/
public Object lookupBean(String beanName) {
logger.debug("BSFManager:lookupBean");
-
+
try {
return ((BSFDeclaredBean)objectRegistry.lookup(beanName)).bean;
}
@@ -774,7 +774,7 @@
*/
public void registerBean(String beanName, Object bean) {
logger.debug("BSFManager:registerBean");
-
+
BSFDeclaredBean tempBean;
if(bean == null) {
@@ -817,7 +817,7 @@
*/
public void setClassLoader(ClassLoader classLoader) {
logger.debug("BSFManager:setClassLoader");
-
+
pcs.firePropertyChange("classLoader", this.classLoader, classLoader);
this.classLoader = classLoader;
}
@@ -830,7 +830,7 @@
*/
public void setClassPath(String classPath) {
logger.debug("BSFManager:setClassPath");
-
+
pcs.firePropertyChange("classPath", this.classPath, classPath);
this.classPath = classPath;
}
@@ -844,7 +844,7 @@
*/
public void setObjectRegistry(ObjectRegistry objectRegistry) {
logger.debug("BSFManager:setObjectRegistry");
-
+
this.objectRegistry = objectRegistry;
}
@@ -862,7 +862,7 @@
*/
public void setTempDir(String tempDir) {
logger.debug("BSFManager:setTempDir");
-
+
pcs.firePropertyChange("tempDir", this.tempDir, tempDir);
this.tempDir = tempDir;
}
@@ -872,7 +872,7 @@
*/
public void terminate() {
logger.debug("BSFManager:terminate");
-
+
Enumeration enginesEnum = loadedEngines.elements();
BSFEngine engine;
while (enginesEnum.hasMoreElements()) {
@@ -898,7 +898,7 @@
*/
public void undeclareBean(String beanName) throws BSFException {
logger.debug("BSFManager:undeclareBean");
-
+
unregisterBean(beanName);
BSFDeclaredBean tempBean = null;
@@ -929,7 +929,7 @@
*/
public void unregisterBean(String beanName) {
logger.debug("BSFManager:unregisterBean");
-
+
objectRegistry.unregister(beanName);
}
}
Modified: jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessor.java
URL:
http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessor.java?rev=389218&r1=389217&r2=389218&view=diff
==============================================================================
--- jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessor.java (original)
+++ jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessor.java Mon Mar 27
10:27:31 2006
@@ -61,7 +61,7 @@
/**
* This is used to support binding scripts to be run when an event
- * occurs.
+ * occurs.
*
* @author Sanjiva Weerawarana
*/
@@ -101,7 +101,7 @@
try {
processExceptionableEvent (inFilter, evtInfo);
} catch (RuntimeException re) {
- // rethrow this .. I don't want to intercept run-time stuff
+ // rethrow this .. I don't want to intercept run-time stuff
// that can in fact occur legit
throw re;
} catch (Exception e) {
@@ -117,8 +117,8 @@
// an exception which must go all the way back to the source (as in
// the vetoableChange case)
- public void processExceptionableEvent (String inFilter, Object[] evtInfo)
-
throws Exception {
+ public void processExceptionableEvent (String inFilter, Object[] evtInfo)
throws Exception
+ {
if ((filter != null) && !filter.equals (inFilter)) {
// ignore this event
return;
Added:
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
URL:
http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java?rev=389218&view=auto
==============================================================================
---
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
(added)
+++
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
Mon Mar 27 10:27:31 2006
@@ -0,0 +1,146 @@
+/*
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation and was originally created by
+ * Sanjiva Weerawarana and others at International Business Machines
+ * Corporation. For more information on the Apache Software Foundation,
+ * please see <http://www.apache.org/>.
+ */
+
+package org.apache.bsf.util;
+
+import org.apache.bsf.util.event.*;
+import org.apache.bsf.*;
+import java.io.PrintStream;
+import java.util.Vector;
+
+/**
+ * This is used to support binding scripts to be run when an event
+ * occurs, forwarding the arguments supplied to the event listener. It is an
adapted version of
+ * [EMAIL PROTECTED] org.apache.bsf.util.BSFEventProcessor}.
+ *
+ * <pre>------------------------ Apache Version 2.0 license
-------------------------
+ * Copyright (C) 2001-2006 Rony G. Flatscher
+ *
+ * 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
+ *
+ * <a
href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
+ *
+ * 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.
+ *
-----------------------------------------------------------------------------
</pre>
+ *
+ * @author Rony G. Flatscher, but most of the code copied from
org.apache.bsf.util.BSFEventProcessor by Sanjiva Weerawarana
+ *
+ *
+ * @see [EMAIL PROTECTED] org.apache.bsf.util.BSFEventProcessor}
+ *
+ */
+public class BSFEventProcessorReturningEventInfos implements EventProcessor {
+ BSFEngine engine;
+ BSFManager manager;
+ String filter;
+ String source;
+ int lineNo;
+ int columnNo;
+ Object script;
+ Object dataFromScriptingEngine; // ---rgf, 2006-02-24: data coming from the
script engine, could be
+ // e.g. an object reference to forward event
with received arguments to
+
+ /**
+ * Package-protected constructor makes this class unavailable for
+ * public use.
+ *
+ * @param dataFromScriptingEngine this contains any object supplied by the
scripting engine and gets
+ * sent back with the supplied script. This could be used e.g. for
indicating which scripting
+ * engine object should be ultimately informed of the event
occurrence.
+ */
+ BSFEventProcessorReturningEventInfos (BSFEngine engine, BSFManager manager,
String filter,
+ String source, int lineNo, int columnNo, Object script,
Object dataFromScriptingEngine)
+ throws BSFException {
+ this.engine = engine;
+ this.manager = manager;
+ this.filter = filter;
+ this.source = source;
+ this.lineNo = lineNo;
+ this.columnNo = columnNo;
+ this.script = script;
+ this.dataFromScriptingEngine = dataFromScriptingEngine;
+ }
+ //////////////////////////////////////////////////////////////////////////
+ //
+ // event is delegated to me by the adapters using this. inFilter is
+ // in general the name of the method via which the event was received
+ // at the adapter. For prop/veto change events, inFilter is the name
+ // of the property. In any case, in the event processor, I only forward
+ // those events if for which the filters match (if one is specified).
+
+
+ public void processEvent (String inFilter, Object[] evtInfo) {
+ try {
+ processExceptionableEvent (inFilter, evtInfo);
+ } catch (RuntimeException re) {
+ // rethrow this .. I don't want to intercept run-time stuff
+ // that can in fact occur legit
+ throw re;
+ } catch (Exception e) {
+ // should not occur
+ System.err.println ("BSFError: non-exceptionable event delivery " +
+ "threw exception (that's not nice): " +
e);
+ e.printStackTrace ();
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ //
+ // same as above, but used when the method event method may generate
+ // an exception which must go all the way back to the source (as in
+ // the vetoableChange case)
+
+ public void processExceptionableEvent (String inFilter, Object[] evtInfo)
throws Exception {
+
+// System.err.println(this+": inFilter=["+inFilter+"], filter=["+filter+"]");
+ if ((filter != null) && !filter.equals (inFilter)) {
+ // ignore this event
+ return;
+ }
+
+ // run the script
+ // engine.exec (source, lineNo, columnNo, script);
+
+ // create the parameter vectors for engine.apply()
+ Vector paramNames = new Vector(), paramValues = new Vector();
+
+ // parameter # 1
+ // supply the parameters as an array object as sent to the event
object listener
+ // (usually the first entry is the sent event object)
+ paramNames. add( "eventParameters" );
+ paramValues.add( evtInfo );
+
+ // parameter # 2
+ // supply the data object received from the scripting engine to be
sent with the event
+ paramNames. add( "dataFromScriptingEngine" );
+ paramValues.add( this.dataFromScriptingEngine ); // can be null
as well
+
+ // parameter # 3
+ // event filter in place
+ paramNames. add( "inFilter" );
+ paramValues.add( inFilter ); // event name that has occurred
+
+ // parameter # 4
+ // event filter in place
+ paramNames. add( "eventFilter" );
+ paramValues.add( this.filter ); // can be null as well
+
+ // parameter # 5
+ // BSF manager instance (e.g. allows access to its registry)
+ paramNames. add( "BSFManager" );
+ paramValues.add( this.manager );
+
+ engine.apply(source, lineNo, columnNo, this.script, paramNames,
paramValues);
+ }
+}
Propchange:
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
jakarta/bsf/trunk/src/org/apache/bsf/util/BSFEventProcessorReturningEventInfos.java
------------------------------------------------------------------------------
svn:keywords = Author Date Rev Id URL
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=389218&r1=389217&r2=389218&view=diff
==============================================================================
--- jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java (original)
+++ jakarta/bsf/trunk/src/org/apache/bsf/util/EngineUtils.java Mon Mar 27
10:27:31 2006
@@ -69,6 +69,7 @@
*
* @author Sanjiva Weerawarana
* @author Sam Ruby
+ * @author Rony G. Flatscher (added addEventListenerReturningEventInfos)
*/
public class EngineUtils {
// the BSF class loader that knows how to load from the a specific
@@ -118,6 +119,64 @@
BSFEventProcessor ep = new BSFEventProcessor (engine, manager, filter,
source, lineNo, columnNo,
script);
+
+ try {
+ ReflectionUtils.addEventListener (bean, eventSetName, ep);
+ } catch (Exception e) {
+ e.printStackTrace ();
+ throw new BSFException (BSFException.REASON_OTHER_ERROR,
+ "ouch while adding event listener: "
+ + e, e);
+ }
+ }
+
+
+ /**
+ * Add a script as a listener to some event coming out of an object. The
+ * first two args identify the src of the event and the event set
+ * and the rest identify the script which should be run when the event
+ * fires. The processing will use the engine's apply() method.
+ *
+ * @param bean event source
+ * @param eventSetName name of event set from event src to bind to
+ * @param filter filter for events
+ * @param engine BSFEngine which can run this script
+ * @param manager BSFManager of the above engine
+ * @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
+ * @param script the script to execute when the event occurs
+ * @param dataFromScriptingEngine
+ * this contains any object supplied by the scripting
engine and gets sent
+ * back with the supplied script, if the event occurs.
+ * This could be used e.g. for indicating to the
scripting engine which
+ * scripting engine object/routine/function/procedure
+ * should be ultimately informed of the event
occurrence.
+ *
+ * @exception BSFException if anything goes wrong while running the script
+ */
+ public static void addEventListenerReturningEventInfos ( Object bean,
+ String eventSetName,
+ String filter,
+ BSFEngine engine,
+ BSFManager manager,
+ String source,
+ int lineNo,
+ int columnNo,
+ Object script,
+ Object dataFromScriptingEngine
+ ) throws BSFException
+ {
+ BSFEventProcessorReturningEventInfos ep =
+ new BSFEventProcessorReturningEventInfos (engine,
+ manager,
+ filter,
+ source,
+ lineNo,
+ columnNo,
+ script,
+ dataFromScriptingEngine
+ );
try {
ReflectionUtils.addEventListener (bean, eventSetName, ep);
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=389218&r1=389217&r2=389218&view=diff
==============================================================================
--- jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java (original)
+++ jakarta/bsf/trunk/src/org/apache/bsf/util/ReflectionUtils.java Mon Mar 27
10:27:31 2006
@@ -70,6 +70,7 @@
*
* @author Sanjiva Weerawarana
* @author Joseph Kesselman
+ * @author Rony G. Flatscher (added Proxy-handling needed for OpenOffice.org
1.1.x and 2.0.x as of 2006-02-03)
*/
public class ReflectionUtils {
@@ -102,21 +103,63 @@
BeanInfo bi = Introspector.getBeanInfo (source.getClass ());
EventSetDescriptor esd = (EventSetDescriptor)
findFeatureByName ("event", eventSetName, bi.getEventSetDescriptors
());
- if (esd == null) {
- throw new IllegalArgumentException ("event set '" + eventSetName +
-
"' unknown for source type '" +
-
source.getClass () + "'");
- }
+
// get the class object for the event
- Class listenerType = esd.getListenerType ();
+ Class listenerType = null;
+ int idx2mmm=0;
+ java.lang.reflect.Method mmm[]=null; // array object to store
methods from Proxy-class reflected methods
+
+ if (esd == null) // no events found, maybe a proxy from
OpenOffice.org?
+ {
+ if (java.lang.reflect.Proxy.class.isInstance(source)==true) // a
Proxy class, hence reflect "manually"
+ {
+ mmm=source.getClass().getMethods(); // get all methods
+ for (idx2mmm=0; idx2mmm<mmm.length; idx2mmm++)
+ {
+ String methName=mmm[idx2mmm].getName();
+ // looking for a method
"add_XYZ_Listener(someEventClass)
+ if (methName.endsWith("Listener")==true)
+ {
+ String un=getUnqualifiedName(methName);
+
+ if (un.startsWith("add")) // get first argument,
which must be an Event class
+ {
+ String tmpName=un.substring(3, un.length()-8);
// -lengthOf(("add"=3)+("Listener"=8))
+ if (eventSetName.equalsIgnoreCase(tmpName))
+ {
+ java.lang.Class
params[]=mmm[idx2mmm].getParameterTypes();
+ if (params.length>0)
+ {
+ listenerType=params[0]; // o.k. found
ListenerClass
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (listenerType==null) // o.k. no listenerType found, throw
up ...
+ {
+ throw new IllegalArgumentException ("event set '" +
eventSetName +
+ "' unknown for source type
'" + source.getClass () + "'");
+ }
+
+ }
+ else // ListenerType from EventSetDescriptor
+ {
+ listenerType=esd.getListenerType(); // get ListenerType class
object from EventSetDescriptor
+ }
+
+
// find an event adapter class of the right type
Class adapterClass = EventAdapterRegistry.lookup (listenerType);
if (adapterClass == null) {
- throw new IllegalArgumentException ("event adapter for listner type "
+
-
"'" + listenerType + "' (eventset " +
-
"'" + eventSetName + "') unknown");
+ throw new IllegalArgumentException ("event adapter for listener type
" +
+ "'" + listenerType + "' (eventset
" +
+ "'" + eventSetName + "')
unknown");
}
// create the event adapter and give it the event processor
@@ -135,15 +178,76 @@
// in this case to support the source-side filtering.
//
// ** TBD **: the following two lines need to change appropriately
- addListenerMethod = esd.getAddListenerMethod ();
+ if (mmm==null)
+ {
+ addListenerMethod = esd.getAddListenerMethod ();
+ }
+ else
+ {
+ addListenerMethod = mmm[idx2mmm];
+ }
args = new Object[] {adapter};
- } else {
- addListenerMethod = esd.getAddListenerMethod ();
+ }
+ else
+ {
+ if (mmm==null) {
+ addListenerMethod = esd.getAddListenerMethod ();
+ }
+ else
+ {
+ addListenerMethod = mmm[idx2mmm];
+ }
args = new Object[] {adapter};
}
addListenerMethod.invoke (source, args);
}
//////////////////////////////////////////////////////////////////////////
+
+
+ /** Compares two strings in a "relaxed" manner, i.e.
+ * tests case-insensitively, whether the second argument
+ * <code>haystack</code> ends with the first argument <code>endName</code>
+ * string.
+ *
+ * @param endName the string which should end <code>haystack</code>
+ * @param haystack the string to test <code>endName</code> against
+ *
+ * @return <code>true</code>, if <code>haystack</code> ends with the
+ * string <code>endName</code> (comparison carried out
case-insensitively),
+ * <code>false</code> else
+ */
+ static boolean compareRelaxed(String endName, String haystack)
+ {
+ int endNameLength=endName.length(),
+ tmpLength =haystack.length();
+
+ if (endNameLength>tmpLength) // interface endName is shorter than
the sought of one
+ {
+ return false;
+ }
+ else if (endNameLength!=tmpLength) // cut off haystack from the right
to match length of received endName
+ {
+ // 012345678
+ // abc=3 x.y.z.abc=9 9-3=6
+ haystack=haystack.substring(tmpLength-endNameLength); // cut off
from the right
+ }
+
+ return endName.equalsIgnoreCase(haystack);
+ }
+ //////////////////////////////////////////////////////////////////////////
+
+ /** Returns unqualified name (string after the last dot) from dotted string
or string itself, if no dot in string.
+ *
+ * @param s String to extract unqualified name
+ * @return returns unqualified name or s, if no dot in string
+ */
+ static String getUnqualifiedName(String s)
+ {
+ int lastPos=s.lastIndexOf('.'); // get position of last dot
+ return lastPos==-1 ? s : s.substring(lastPos+1) ;
+ }
+ //////////////////////////////////////////////////////////////////////////
+
/**
* Create a bean using given class loader and using the appropriate
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=389218&r1=389217&r2=389218&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
Mon Mar 27 10:27:31 2006
@@ -103,7 +103,7 @@
} catch (ClassNotFoundException e) {
if (dynamic) {
// Unable to resolve one, try to generate one.
- adapterClass =
+ adapterClass = // if second argument is set to 'true', then
the class file will be stored in the filesystem
EventAdapterGenerator.makeEventAdapterClass
(listenerType, false);
}
}
Modified:
jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java
URL:
http://svn.apache.org/viewcvs/jakarta/bsf/trunk/src/org/apache/bsf/util/event/generator/AdapterClassLoader.java?rev=389218&r1=389217&r2=389218&view=diff
==============================================================================
---
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
Mon Mar 27 10:27:31 2006
@@ -63,8 +63,8 @@
{
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());
public AdapterClassLoader()
{
@@ -74,7 +74,7 @@
{
if ((c = getLoadedClass(name)) == null)
{
- c = defineClass(name, b, 0, b.length);
+ c = defineClass(name.replace('/','.'), b, 0, b.length); // rgf,
2006-02-03
put(name, c);
}
else
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=389218&r1=389217&r2=389218&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
Mon Mar 27 10:27:31 2006
@@ -53,6 +53,14 @@
* please see <http://www.apache.org/>.
*/
+ /* changes:
+ 2006-02-03, Rony G. Flatscher: added OpenOffice.org support
(versions 1.1.x and 2.0.1)
+ which need special handling due to their omission
to tagt heir event
+ listeners as implementing
"java.util.EventListener" inhibiting standard
+ introspection to identify events; therefore a
"manual" branch got introduced
+ to identify OpenOffice.org event listeners
+ */
+
package org.apache.bsf.util.event.generator;
import java.io.*;
@@ -69,6 +77,7 @@
{
public static AdapterClassLoader ldr = new AdapterClassLoader();
static Class EVENTLISTENER = null;
+ static Class OPENOFFICE_XEVENTLISTENER = null;
static String CLASSPACKAGE = "org/apache/bsf/util/event/adapters/";
static String WRITEDIRECTORY = null;
@@ -83,13 +92,13 @@
static byte INITMETHOD[];
private static Log logger;
-
+
/* The static initializer */
static
{
logger = LogFactory.getLog(
(org.apache.bsf.util.event.generator.EventAdapterGenerator.class).getName());
-
+
String USERCLASSPACKAGE = System.getProperty("DynamicEventClassPackage",
"");
@@ -120,6 +129,18 @@
ex.printStackTrace();
}
+
+ // try to load the OpenOffice.org (OOo) counterpart of
EventListener; unfortunately as of 2006
+ // OOo's XEventListener does not report to have
'java.util.EventListener' implemented, hence
+ // Introspector cannot identify events !
+ try
+ {
+ OPENOFFICE_XEVENTLISTENER =
Thread.currentThread().getContextClassLoader().loadClass
("com.sun.star.lang.XEventListener");
+ }
+ catch (Exception e)
+ {
+ }
+
// start of the Java Class File
CLASSHEADER = ByteUtility.addBytes(CLASSHEADER,(byte)0xCA); // magic
CLASSHEADER = ByteUtility.addBytes(CLASSHEADER,(byte)0xFE); // magic
@@ -213,7 +234,11 @@
{
logger.info("EventAdapterGenerator");
- if( EVENTLISTENER.isAssignableFrom(listenerType) )
+ if( EVENTLISTENER.isAssignableFrom(listenerType) ||
+ // test explicitly OpenOffice.org listener types; as of
2006-02-03 neither 1.1.5 nor
+ // OOo 2.0.1 do indicate that they implement
'java.lang.EventListener'
+ ( OPENOFFICE_XEVENTLISTENER!=null &&
OPENOFFICE_XEVENTLISTENER.isAssignableFrom(listenerType) )
+ )
{
boolean exceptionable = false;
boolean nonExceptionable = false;
@@ -560,7 +585,8 @@
{
try
{
- FileOutputStream fos = new
FileOutputStream(WRITEDIRECTORY+finalAdapterClassName+".class");
+ // removed "WRITEDIRECTORY+", as this path is already part
of 'finalAdapterClassName'
+ FileOutputStream fos = new
FileOutputStream(finalAdapterClassName+".class");
fos.write(newClass);
fos.close();
}
@@ -598,10 +624,6 @@
System.err.println(ex.getMessage());
ex.printStackTrace();
}
- }
- else
- {
- System.err.println("EventAdapterGenerator ListenerType invalid:
listenerType = " + listenerType);
}
return null;
}
Modified: jakarta/bsf/trunk/xdocs/projects.xml
URL:
http://svn.apache.org/viewcvs/jakarta/bsf/trunk/xdocs/projects.xml?rev=389218&r1=389217&r2=389218&view=diff
==============================================================================
--- jakarta/bsf/trunk/xdocs/projects.xml (original)
+++ jakarta/bsf/trunk/xdocs/projects.xml Mon Mar 27 10:27:31 2006
@@ -8,7 +8,7 @@
</properties>
<body>
-
+
<section name="Related Projects">
<p>Nothing listed here is directly supported by the BSF
@@ -165,7 +165,7 @@
</tr>
</table>
</subsection>
-
+
<subsection name="NetRexx">
<p>
@@ -310,10 +310,10 @@
<subsection name="ObjectScript">
<p>
- "ObjectScript is a general purpose object-oriented programming
language. It is designed to
- be simple to learn, easy to use, yet still powerful, combining the
convenience of an
+ "ObjectScript is a general purpose object-oriented programming
language. It is designed to
+ be simple to learn, easy to use, yet still powerful, combining the
convenience of an
interactive interpreter with many of the features of Java, plus
operator overloading,
- regular expressions, closures, XML-RPC support, etc. And a behind
the scenes compiler
+ regular expressions, closures, XML-RPC support, etc. And a behind
the scenes compiler
compiles script code to JVM bytecode for faster execution."
</p>
<table>
@@ -361,6 +361,57 @@
<tr>
<th>License:</th>
<td>GPL (same as JLog itself)</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="ooRexx">
+ <p>
+ "Open Object Rexx (ooRexx, http://www.ooRexx.org) is a free
+ and opensource language, which was originally developed by IBM.
+ The non-profit SIG Rexx Language Association (http://www.RexxLA.org)
+ received the source code from IBM and released an opensource version
+ to the community in 2005.
+
+ <br></br>The BSF engine for Rexx (BSF4Rexx) comes with an ooRexx
wrapper
+ program (BSF.CLS) which camouflages Java as ooRexx, easying programming
+ considerably (e.g. no need for type information/casting).
+ </p>
+
+ <table>
+ <tr>
+ <th>Compatibility:</th>
+ <td>BSF 2.3 and above</td>
+ </tr>
+ <tr>
+ <th>URL (ooRexx):</th>
+ <td><a
href="http://www.ooRexx.org/">http://www.ooRexx.org/</a></td>
+ </tr>
+ <tr>
+ <th>URL (BSF4Rexx, temporary):</th>
+ <td><a
href="http://wi.wu-wien.ac.at/rgf/rexx/bsf4rexx/current/">http://wi.wu-wien.ac.at/rgf/rexx/bsf4rexx/current/
(temporary)</a></td>
+ </tr>
+ <tr>
+ <th>URL (BSF4Rexx, planned home):</th>
+ <td><a
href="http://bsf4rexx.sourceforge.net/">http://bsf4rexx.sourceforge.net
(starting at the end of April 2006)</a></td>
+ </tr>
+ <tr>
+ <th>Contact (ooRexx):</th>
+ <td><a href="mailto:[EMAIL PROTECTED]">Ulf Dittmer</a></td>
+ </tr>
+ <tr>
+ <th>Contact (BSF4Rexx):</th>
+ <td><a href="mailto:[EMAIL PROTECTED]">Ulf Dittmer</a></td>
+ </tr>
+ <tr>
+ <th>License:</th>
+ <td>ooRexx: IBM's opensource license CPL v 1.0
+ </td>
+ </tr>
+ <tr>
+ <th>License:</th>
+ <td>BSF4Rexx: Apache v2.0
+ </td>
</tr>
</table>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]