I want to have my Java swing application be applescriptable.
I am not trying to just respond to pre-defined events like open, print, etc.
It would be best if the AppleEvents appeared through a Listener interface.
Edit: A little bit of explanation of my understanding of Apple Events may help demonstrate that I'm not a slacker. :-) I've written code here that demonstrates how to respond to a lot of the pre-defined events:
Apple Events are delivered to regular applications using a non-Java interface. There are no supplied Java methods for obtaining these events, so far as I've been able to discover. The Apple Event technology includes writing "terminology" files which describe in human readable form what events an application responds to and the four-letter codes for building up Apple Events programatically. Creating an instance of javax.script.ScriptEngine doesn't do what I want. It allows a Java program to initiate calling AppleScript, but no means for having AppleScript call a Java program.
To clarify, are there are already written libraries or examples that show how to:
Mark or register certain Java methods as being "visible" as AppleScript methods and/or classes as AppleScript classes.
Failing a declarative approach, is there a Java method for capturing Apple Events sent to the Java application? If the event just gets returned as an array of bytes, then the event can be parsed and turned into a Swing event and the reverse process can be used to return results to the application that sent the Apple Event.
Or does lots of JNI code need to written?