RE: Re: Passing JRuby to Java

Hi…
Did you read this…??

-----Mensaje original-----
De: “Ray H.” [email protected]
Enviado: ‎03/‎12/‎2013 15:25
Para: “[email protected]” [email protected]
Asunto: [jruby-user] Re: Passing JRuby to Java

Christian, I wanted to get a bit more info about the Marshal class, but
cannot seem to find it. I searched in the JRuby API but only saw the
MarshalStream class.

Like I said, I need to pass the objects to Drools and Drools need to
recognize them as a special named class for the “facts” to work. That
was why I created a Java class to inspect an object and then passed a
JRuby mongoid/moped object. JRuby properly see it as an object of type
“Record” or whatever I have called it, but my Java program saw the class
as “RubyObject”.

Drools is a rules engine that responds to facts that are actually Java
classes with specific values. So if for example, I have customer data
in a class but Drools not see the class as being “Customer”, then it
will not trigger processing. The class types have to match as well as
the method calls.

Ray

–
Posted via http://www.ruby-forum.com/.

Manuel, I have tried many things to resolve this issue. Basically the
issue is when passing JRuby objects to Java. For standard objects/
primities such as Strings, JRuby has some standard builtin translations.
The problem comes in if you want to pass any instance of a class. It
will be translated to a RubyObject. I have tried Java reflection, but I
cannot find any way to execute the methods nor to set/ retrieve the
contents of a JRuby class.

I have done this many times in Groovy, where the Groovy classes are
first class Java classes. I was hoping to do the same with JRuby and
Rails. I would even be willing to create a wrapper class to give the
Java objects access to the methods and data in the Ruby class. I cannot
see anyway to do that… before you mention embedding, keep in mind that
I not trying to instantiate the class within Java but to use an instance
of the class created by Rails.

Thoughts?

Ray