Hi Kevin,
On Thu, Jan 14, 2010 at 8:09 PM, Kevin S. Lim [email protected] wrote:
Would it be possible to get to the rails environment then?
This brings me another question actually.
While back, when I tried this, the second jruby runtime was created by
runtime = Ruby.newInstance(); // because getCurrentInstance() is deprecated?
And I had thought that this new runtime instance is different than the original jruby runtime which started rails.
From the java code(third one on above sequences), can I get the original jruby runtime or rails environments?
Ah, I honestly understood what you wanted to do, now.
Yes. Currently, Ruby runtime isn’t a static, so you’ll get another
runtime instance. This happens even though you use
org.jruby.Ruby.newInstacne() directly.
We had a discussion recently about a static Ruby runtime,
http://old.nabble.com/Moving-to-a-classloader-global-runtime!-td27045093.html.
When we have this new runtime, JRuby Embed as well as JSR223 impl will
be able to return the same instance as the original runtime.
But, we don’t have such kind of runtime right now, so you probably
need a trick. For example, using Java’s system property:
in a code on rails:
java.lang.System.set_property(“RAILS_ENV”, value)
in another code:
java.lang.System.get_property(“RAILS_ENV”)
This is just an example, so you have other couple of options, I think.
-Yoko
Here is how my objects are instantiated. (jruby → rails → java →
but org.jruby.Ruby.getCurrentInstance() returns null.
Sort of. ScriptEngine doesn’t expose Ruby runtime rather than it
http://xircles.codehaus.org/manage_email
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email