|
|
| 566 |
568 |
|
| 7 | 7 | import org.jruby.javasupport.JavaEmbedUtils;
|
| 8 | 8 | import org.jruby.runtime.builtin.IRubyObject;
|
| 9 | 9 |
|
| 10 | | import java.io.PipedInputStream;
|
| 11 | | import java.io.PrintStream;
|
| 12 | | import java.io.OutputStream;
|
| 13 | | import java.io.IOException;
|
| 14 | 10 | import java.util.ArrayList;
|
| 15 | 11 |
|
| 16 | 12 | /**
|
| --- | --- | |
| 29 | 25 | public static Ruby getRuntime() { return (Ruby)sRuby; }
|
| 30 | 26 |
|
| 31 | 27 | public static void initialize() throws ClassNotFoundException {
|
| 28 | // System.err.println("Before: " + System.currentTimeMillis());
|
| 32 | 29 | // Test for JRuby's presence
|
| 33 | 30 | Class.forName("org.jruby.RubyInstanceConfig", true, Thread.currentThread().getContextClassLoader());
|
| 34 | 31 |
|
| 35 | | final RubyInstanceConfig config = new RubyInstanceConfig()
|
| 36 | | {
|
| 37 | | {
|
| 38 | | setObjectSpaceEnabled(false);
|
| 39 | | }
|
| 40 | | };
|
| 32 | final RubyInstanceConfig config = new RubyInstanceConfig();
|
| 41 | 33 | final Ruby runtime = Ruby.newInstance(config);
|
| 42 | 34 |
|
| 43 | 35 | String[] args = new String[0];
|
| --- | --- | |
| 47 | 39 | runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(System.identityHashCode(runtime))));
|
| 48 | 40 | runtime.getLoadService().init(new ArrayList());
|
| 49 | 41 |
|
| 42 | // System.err.println("Middle: " + System.currentTimeMillis());
|
| 50 | 43 | runtime.evalScriptlet("require 'builtin/javasupport.rb'; require 'jbidwatcher/utilities';");
|
| 44 | // System.err.println("After : " + System.currentTimeMillis());
|
| 51 | 45 |
|
| 52 | 46 | sRuby = runtime;
|
| 53 | 47 | }
|
| 54 | 48 |
|
| 55 | 49 | public static Object ruby(String command) {
|
| 56 | 50 | if(sRuby != null) {
|
| 57 | | Object rval = ((Ruby)sRuby).evalScriptlet(command);
|
| 58 | | return rval;
|
| 51 | return ((Ruby)sRuby).evalScriptlet(command);
|
| 59 | 52 | } else {
|
| 60 | 53 | return null;
|
| 61 | 54 | }
|
| --- | --- | |
| 70 | 63 | sJBidwatcher = ruby("JBidwatcher");
|
| 71 | 64 | }
|
| 72 | 65 |
|
| 73 | | Object rval = JavaEmbedUtils.invokeMethod((Ruby)sRuby, sJBidwatcher, method, method_params, Object.class);
|
| 74 | | return rval;
|
| 66 | return JavaEmbedUtils.invokeMethod((Ruby)sRuby, sJBidwatcher, method, method_params, Object.class);
|
| 75 | 67 | }
|
| 76 | 68 | }
|