Rony G. Flatscher wrote:
Hi Kay,

Rony,

Thanks for the detailed explanation of why XEventListener should extend java.util.EventListener. Doing so would not be difficult, I just hesitated to add such (at first sight arbitrary) special casing (and then simply forgot about your request). Please file an issue for me, and I can probably add that for OOo 2.0.3.

-Stephan

according to the documentation "com.sun.star.lang.XEventListener" does not report to implement the Java interface "java.util.EventListener". It seems that "java.beans.Introspector" is not able to identify/locate the OOo EventListeners breaking generic reflective code as a result.

what would be the advantage of the Introspector being able to identify event listeners?

Every Java program relying on the abliity of the Introspector to identify event listeners will be able to rely on the OOo Java interfaces as well. Or put differently: every Java code breaks with OOo Java event listeners, because OOo does not classify its event listeners of type <>.

What would the usage scenario look like? Do you have an example at hand?

Yes, I think so. An (rather important) example might be:

    <http://jakarta.apache.org/bsf>

The "Bean Scripting Framework" (BSF) is a Java opensource framework allowing Java programs to easily invoke scripts in non-Java languages and also supplies functionality to non-Java scripting engines to interface with Java. This way non-Java programs are able to interface and take advantage of Java.

I have been using BSF to allow the free, opensource, multiplatform scripting language ooRexx (cf. <http://www.ooRexx.org>) to drive OOo via Java. (The generic support for this ooRexx-to-Java bridge is dubbed "BSF4Rexx" and will get contain the generic support for OOo, making it considerably easy for script coders to drive OOo in a platform independent manner.) [You can take a look at the following work: <http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2005/200511_OOo-Ahammer/200511_OOoAutomation.pdf> which contains nutshell examples of driving OOo from ooRexx, showing the code and images of the resulting OOo window. All examples run under Linux *and* Windows, with the exception of the MS Access sample, of course. This work was updated in 2006-11. There is another student who is about to finalize another work, creating nutshell examples of using ooRexx as a macro language for OOo 2.x.]

With the advent of OOo 2.0 a Java based scripting framework is available, which I use to plug in ooRexx into OOo, allowing it to be used as a scripting language beside OOo Basic, Python, JavaScript (Rhino), BeanShell. (It would be now a matter of a few minutes to add all the BSF supported scripting languages using the ooRexx implementation as a template. Will announce that fact, once the ooRexx implementation goes "Golden") Just to give you an idea about the "complexity" of this part of the task (besides getting acquainted with the OOo scripting framework itself), here is the necessary code to make ooRexx available as a macro language to OOo:

--------------- cut here --------------

ScriptSourceModel.invoke(...):

// ... cut ...

BSFManager mgr = new BSFManager(); Vector args= new Vector(aParams.length+1);
try // create arguments for ooRexx
{
    int i;

       // rgf, make XScriptContext available to script
       // 2006-01-06, set entries into BSF registry for retrieval by invoked 
Rexx script (available in every Rexx scope)
    mgr.registerBean(ScriptProviderForooRexx.OOREXX_XSCRIPTCONTEXT_KEY,  
ScriptContext.createContext(m_xModel, m_xContext, m_xMultiComponentFactory));
    mgr.registerBean(ScriptProviderForooRexx.OOREXX_VERSION_KEY,        "1.0");

       // add arguments to Vector
    for (i=0;i<aParams.length;i++)
    {
        args.addElement(aParams[i]);    // add argument
    }
}

// ... cut (plain vanilla stuff from ScriptSourceModel.invoke(...) ...

result=mgr.apply(ScriptProviderForooRexx.OOREXX_BSFLANGUAGE, 
"OOo.ScriptProviderForooRexx", 0, 0, source, null, args);

if (result == null)
{
    return new Any(new Type(), null);
}

return result;

// ... cut ...
--------------- cut here --------------


Changing a few constants and you could use the same code for dispatching JavaScript (Rhino), Jython, JLog (PROLOG) etc. via BSF and the OOo scripting framework. (Just to hint at the importance of Java frameworks like BSF.)

---

Now, because OOo event handlers do not declare to have the Java "java.util.EventListener" implemented (it is actually just a classification information, as it is an interface class not defining any fields or methods), the generic event handler support of BSF breaks. (Due to the opensourceness of BSF I was able to go through the respective code and was able to add the support for OOo event handlers; but this is a "private" fix, which I doubt that the BSF committers will accept for the official distribution. If interested, you could look at it at the URL given in the "P.S." below.)

---

As you may know, with Java 1.6 a scripting interface will become available with Java (I was serving on the respective JSR-223 group for the past years), which will be confined to 1.6. There are plans to create a version of BSF which will be compatible with JSR-223, allowing earlier versions of Java the same scripting interfaces.

No matter which (scripting interface) version one is interested in, supporting event handlers is critical for scripts. So today's introspection/reflection Java classes should work with OOo event handlers generically as well, ie. without the need for any changes.

Rergards,

---rony

P.S.: The present Beta-version of "BSF4Rexx" including the OOo/UNO support can be found together with examples and the source code (OOo scripting framework, tweaked BSF for OOo event listeners, etc.) at: <http://wi.wu-wien.ac.at/rgf/rexx/bsf4rexx/current/>. Feel free to ask questions, should you have any questions.

P.P.S.: Although ooRexx is available for Solaris, I have not yet had the time to dig into Solaris in order to port BSF4Rexx to Solaris (one JNI file needs to be compiled for it); so if anyone is interested/curious and does a port to Solaris of BSF4Rexx, please let me know.

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

Reply via email to