JRubyat,
i’ve really been stymied by various approaches to use JRuby objects from
any
other JVM language. At the time of this writing, my currently best
performing, non-buggy approach is to covert to YAML and convert back via
jvyaml (see below). This really feels like it defeats the purpose of JVM
level interop. There must be a better way. What am i missing?
Best wishes,
–greg
bash-3.2$ script/console
script/console
Loading development environment (Rails 2.1.1)
JRuby limited openssl loaded. gem install jruby-openssl for full
support.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
cas = MyProjActivities.new
cas = MyProjActivities.new
=> #<MyProjActivities id: nil, name: nil, creator_id: nil, owner_id:
nil,
uuid: nil, created_at: nil, updated_at: nil, visibility: “public”,
status:
“open”, sharing: “anyone”>
cas.to_yaml
cas.to_yaml
=> “— !ruby/object:MyProjActivities\nnew_record: true\nattributes: \n
owner_id: \n name: \n updated_at: \n creator_id: \n uuid: \n
visibility: public\n created_at: \n status: open\n sharing:
anyone\nattributes_cache: {}\n”
bash-3.2$ mvn scala:console
[INFO] Scanning for projects…
[INFO] Searching repository for plugin with prefix: ‘scala’.
[INFO]
[INFO] Building dspace
[INFO] task-segment: [scala:console]
[INFO]
[INFO] Preparing scala:console
Welcome to Scala version 2.7.3.final (Java HotSpot™ Client VM, Java
1.5.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> org.jvyaml.YAML.load(“—
!ruby/object:MyProjActivities\nnew_record:
true\nattributes: \n owner_id: \n name: \n updated_at: \n
creator_id:
\n uuid: \n visibility: public\n created_at: \n status: open\n
sharing:
anyone\nattributes_cache: {}\n”)
org.jvyaml.YAML.load(“— !ruby/object:MyProjActivities\nnew_record:
true\nattributes: \n owner_id: \n name: \n updated_at: \n
creator_id:
\n uuid: \n visibility: public\n created_at: \n status: open\n
sharing:
anyone\nattributes_cache: {}\n”)
org.jvyaml.YAML.load(“— !ruby/object:MyProjActivities\nnew_record:
true\nattributes: \n owner_id: \n name: \n updated_at: \n
creator_id:
\n uuid: \n visibility: public\n created_at: \n status: open\n
sharing:
anyone\nattributes_cache: {}\n”)
res0: java.lang.Object = #<PrivateType tag:
!ruby/object:MyProjActivities
value: {attributes={visibility=public, updated_at=null, owner_id=null,
creator_id=null, uuid=null, created_at=null, sharing=anyone,
status=open,
name=null}, new_record=true, attributes_cache={}}>
scala>
–
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105
+1 206.650.3740