Scripted interfaces for something other than an Interpreter

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Scripted interfaces for something other than an Interpreter

David Walend
http://beanshell.org/manual/ 
embeddedmode.html#Embedding_BeanShell_in_Your_Application talks about  
how to get the beanshell interpreter to implement an interface in  
compiled Java code:

// script the method globally
i.eval( "actionPerformed( e ) { print( e ); }");

// Get a reference to the script object (implementing the interface)
ActionListener scriptedHandler =
     (ActionListener)i.eval("return (ActionListener)this");

// Use the scripted event handler normally...
new JButton.addActionListener( scriptedHandler );

Can other beanshell objects that implement an interface be used in  
compiled Java code?

// Get a reference to the script object (implementing the interface)
ActionListener scriptedHandler =
     (ActionListener)i.eval("return (ActionListener)
myScriptedActionListenerThatIsNotThis");

I've tried it this way and it doesn't seem to quite work. I get a  
ClassCastException: global$2 or the like.

Thanks,

Dave


David Walend
[hidden email]




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users