JRubyScriptEngine.invokeMethod

Hi,

I had couple of queries around invokeMethod of JRubyScriptEngine. Can
someone please help me with these?

  1. invokeMethod of Invocable interface does not take the Class of the
    method
    return type as parameter, hence rubyToJava call passes generic
    Object.class.
    Is this a problem with designing the interface?

  2. when i use invokeMethod, it takes native java objects and converts
    then
    to ruby objects using the wrap method. On the other hand, the object
    returned by invokeMethod is not a native java object, but a RubyObject
    with
    instance variables set to the fields of the corresponding native java
    object. How do I unwrap the Ruby object to get the native java object?

e.g. if the return type is LoanResponse with two fields ssn:string and
approved:boolean, the return object i get is a Ruby Object with @ssn and
@approved instance variables in the container map.

(i tried adding another invokeMethod, which takes the Class of the
method
return type as parameter, and rubyToJava gets to use this, but that did
not
help)

thanks,
pankaj

I am using Apache BSF 3.0 beta and JRuby 1.0.3 on JDK 1.5.

Hi pankaj,

Do you know what version of JRuby engine is included in the archive
distributed in BSF project? Since JRuby engine is sensitive to JRuby’s
version, you might have a compatibility problem. As far as I remember,
some of internal API changes done on JRuby 1.0.2 - 1.1RC2 affected
JRuby engine, so each version of JRuby engine works on the exactly
compliant version of JRuby.
Moreover, as far as I remember, invokeMethod of Invocable interface
has worked completely since JRuby 1.1b1. You might need to use later
version of JRuby and JRuby engine to run your code.
Please visit
https://scripting.dev.java.net/servlets/ProjectDocumentList?folderID=8848&expandFolder=8848&folderID=0
to see version dependencies.

-Yoko

Thanks Yoko for the response.

Nopes bsf-all-3.0-beta2.jar does not seem to tell the JRubyScriptEngine
version. (attached with this mail)

I am restricted to JDK 1.5

bsf 2.4 stable version has old scripting APIs, hence i chose bsf 3.0
beta
jruby 1.1 did not work with bsf 3.0 beta, hence i chose jruby 1.0.3

I will try the JRubyScriptEngine versions from the location you
suggested. But eventually I will need an all in one Scripting Engines
jar.

Can someone please suggest highest versions of JRubyScriptEngine and
JRuby with which they have successfully used invokeMethod for sending
the native java object parameters and getting the native java object
response?

regards,
pankaj

Yoko H. wrote:

version of JRuby and JRuby engine to run your code.

someone please help me with these?

I am using Apache BSF 3.0 beta and JRuby 1.0.3 on JDK 1.5.


पंकज एम तोलानी


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Folks,

My bad. I was creating a native Ruby object as response, and was
expecting invokeMethod return to automagically convert it to native Java
object. When I looked at the code details, I understood I need to create
native Java objects on Ruby side.

thanks,
pankaj


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Folks,

I tried jruby script engine version 1.1.4 and jruby version 1.1.2. This
did
not work either. invokeMethod still returns RubyObject and not the
required
native Java object.

Help please.

thanks,
pankaj

On Thu, Jul 10, 2008 at 11:05 PM, “पंक्ज एम. तोलानी” <

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs