On Thu, 16 Feb 2006 15:41:41 +0100, Rony G. Flatscher wrote
> Benjamin Reitzammer wrote:
> > Hi,
> > On 2/14/06, neil.benn <[EMAIL PROTECTED]> wrote:>     This returns
'NeilNeilNeilNeilNeil' - all good so far.  However I want to> be able to pass
Java variables to Jython (I'll include JRuby and Groovy again> at some point).
 For this, I reckon I need to use the apply function.> However, I'm confused -
the docs state that I need :
> > I don't have the javadoc at hand (it would be great if the javadoccould be
found on the jakarta BSF website, BTW), but looking at mycode, I can tell that
you need thedeclareBean()-method from the BSFManager class. Something like this:
> > BSFManager manager = new BSFManager();manager.declareBean("objList", new
ArrayList(), List.class);
> > This code makes a variable called "objList" available to your script.
> >   
> A non-official but fairly recent online version of the BSF Javadocs 
> can be found at: <http://wi.wu-
> wien.ac.at/rgf/rexx/bsf4rexx/current/docs/docs.apache.bsf/>. Infos 
> on apply() can be found in: <http://wi.wu-
<snip>
Helo,
  
     Thanks for your replies, sorry about the delay in replying - I've been
travelling.  I'm still confused as to how do to what I wish (BTW the code is
from Java -> Scripting language).  Here's a concrete example : 

---

 * An authorised user submits a script that will be run in the future the
script looks like (example in Jython):

<a load of import statements and so on>

def getOrderData(order_number, order_submit_auth_code):

  <blah, blah, blahh>
  __check_order_auth(order_submit_auth)
  #dctOrderDetails is a dictionary which contains key value pairs contiang
order information.
  return dctOrderDetails

def __check_order_auth(auth_code):

  <blah, blahh, blaaahh>
  return tOrderAuthorised

 * In the future the system receives a request to run that script by callign
the function getOrderData with the parameters order_number=123456 and
order_submit_auth_code=98765
 * The framework then calls the getOrderData function, receives teh dict -
converts it into a Java friendly instance (somewhere previously it was told
that this is what it would be getting) and returns it to the caller.

---

  So that would be about it, I can get something to work by specifying a
format which the scripts must be in and passing the variable in.  Therefore I
could modify the script to register the parameters as variables and simply
insert a call to the function right before the function deceleration.  Such as :

---

registerBean(passOrderNubmer, new Integer(123456));
registerBean(passOrderAuthCode, new Integer(98765));

I can then modify the execution script so that it now has:

<a load of import statements and so on>

getOrderData(passOrderNumber, passOrderAuthCode)
def getOrderData(order_number, order_submit_auth_code):

  <blah, blah, blahh>
  __check_order_auth(order_submit_auth)
  #dctOrderDetails is a dictionary which contains key value pairs contiang
order information.
  return dctOrderDetails

def __check_order_auth(auth_code):

  <blah, blahh, blaaahh>
  return tOrderAuthorised

---

    That way I can execute the scripts by calling a simple eval.  Does anyone
know if that would work (I've given up with the apply call)?

    Thanks for your help.

Cheers,

Neil
--
Open WebMail Project (http://openwebmail.org)


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

Reply via email to