> > Is there any way for a program to find out what are the beans created
> > by the scripts and then retrieve them one by one (without hardcode the
> > names)?
> Not at the moment. However, it would be questionable whether that was a
> desirable feature at all, which may be surprising at first. Reasoning:
> invoked scripts should only be able to address Java objects that were
> made explicitly known to them by the controlling/invoking Java program.

I think he's asking for the opposite actually, for the controlling/invoking 
Java program to have access to objects created by the script.  I'm nearly 
certain that BSF hands off to the script engine, and doesn't automatically 
register everything the script engine does.  

That being said, BSF does add itself to the script's context, so I think you 
can do something like $bsf.declareBean("myrubyvariable", $rubyvariable) from 
within the ruby script, then fetch it using 
BSFManager.lookupBean("myrubyvariable") from the Java code.

It would be nice if there was a BSFEvent or something when a script created a 
new object/variable in it's context, I know I want something like that for my 
application, but I don't think BSF is that aware enough of what the script 
engine itself is doing to accomplish that.

Note: The syntax above is almost certainly wrong, but you get the idea.

-----Original message-----
From: "Rony G. Flatscher" [EMAIL PROTECTED]
Date: Fri, 20 Oct 2006 15:45:09 -0400
To: Bean Scripting Framework users bsf-user@jakarta.apache.org
Subject: Re: How to access JRuby object from Java program?

> Hi Wolverline,
> > OK, the above code hardcodes one bean called "map2" which the script
> > author has to manipulate in the script file. 
> Congratulations!
> :)
> 
> > Is there any way for a program to find out what are the beans created
> > by the scripts and then retrieve them one by one (without hardcode the
> > names)?
> Not at the moment. However, it would be questionable whether that was a
> desirable feature at all, which may be surprising at first. Reasoning:
> invoked scripts should only be able to address Java objects that were
> made explicitly known to them by the controlling/invoking Java program.
> 
> Regards,
> 
> ---rony
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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

Reply via email to