/** * Returns a Ruby runtime in one of {@link LocalContextScope}. * * @deprecated As of JRuby 1.5.0. Use getProvider().getRuntime() method instead. * * @return Ruby runtime of a specified local context */ @Deprecated public Ruby getRuntime() { return provider.getRuntime(); }
/** * Returns a Ruby runtime in one of {@link LocalContextScope}. * * @deprecated As of JRuby 1.5.0. Use getProvider().getRuntime() method instead. * * @return Ruby runtime of a specified local context */ @Deprecated public Ruby getRuntime() { return provider.getRuntime(); }
/** * Returns a Ruby runtime in one of {@link LocalContextScope}. * * @deprecated As of JRuby 1.5.0. Use getProvider().getRuntime() method instead. * * @return Ruby runtime of a specified local context */ @Deprecated public Ruby getRuntime() { return provider.getRuntime(); }
@Deprecated public void setVariable(BiVariable var) { setVariable((RubyObject)provider.getRuntime().getTopSelf(), var); }
public JRubyFacet() { // TODO: is this too early? Shall we allow registrations later? languages.addAll(Facet.discoverExtensions(RubyTemplateLanguage.class, Thread.currentThread().getContextClassLoader(), getClass().getClassLoader())); container = new ScriptingContainer(LocalContextScope.SINGLETHREAD); // we don't want any funny multiplexing from ScriptingContainer. container.runScriptlet("require 'org/kohsuke/stapler/jelly/jruby/JRubyJellyScriptImpl'"); navigator = new RubyKlassNavigator(container.getProvider().getRuntime(), getClass().getClassLoader()); for (RubyTemplateLanguage l : languages) { templateContainers.put(l.getScriptExtension(),l.createContainer(container)); tearOffTypes.add(l.getTearOffClass()); } }
private void setVariable(BSFDeclaredBean bean) { String name = bean.name; if ("$bsf".equals(name)) { return; } if (!name.startsWith("$")) { name = "$".concat(name); } RubyObject receiver = (RubyObject)container.getProvider().getRuntime().getTopSelf(); BiVariable v = VariableInterceptor.getVariableInstance(LocalVariableBehavior.BSF,receiver, name, bean.bean, bean.type); container.getVarMap().setVariable(receiver, v); }
private RubyObject getReceiverObject(Object receiver) { if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf(); else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { if (receiver == null || !(receiver instanceof IRubyObject)) return (RubyObject)provider.getRuntime().getTopSelf(); else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
private RubyObject getReceiverObject(Object receiver) { Ruby runtime = container.getProvider().getRuntime(); if (receiver == null || !(receiver instanceof IRubyObject)) { return (RubyObject)runtime.getTopSelf(); } else if (receiver instanceof RubyObject) return (RubyObject)receiver; else return (RubyObject)((IRubyObject)receiver).getRuntime().getTopSelf(); }
/** * Cleanly shut down this ScriptingContainer and any JRuby resources it holds. * All ScriptingContainer instances should be terminated when you are done with * them, rather then leaving them for GC to finalize. * * @since JRuby 1.5.0 */ public void terminate() { if (getProvider().isRuntimeInitialized()) getProvider().getRuntime().tearDown(false); getProvider().terminate(); }
public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName); return bv.getRubyObject(); } } return null; }
/** * Cleanly shut down this ScriptingContainer and any JRuby resources it holds. * All ScriptingContainer instances should be terminated when you are done with * them, rather then leaving them for GC to finalize. * * @since JRuby 1.5.0 */ public void terminate() { if (getProvider().isRuntimeInitialized()) getProvider().getRuntime().tearDown(false); getProvider().terminate(); }
public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable((RubyObject)container.getProvider().getRuntime().getTopSelf(), variableName); return bv.getRubyObject(); } } return null; }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setErrorStream(PrintStream error) { if (error == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, error); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDERR", io); runtime.getGlobalVariables().alias("$deferr", "$stderr"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }
private void setOutputStream(PrintStream pstream) { if (pstream == null) { return; } Ruby runtime = provider.getRuntime(); RubyIO io = new RubyIO(runtime, pstream); io.getOpenFile().getMainStream().setSync(true); runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL); runtime.getObject().storeConstant("STDOUT", io); runtime.getGlobalVariables().alias("$>", "$stdout"); runtime.getGlobalVariables().alias("$defout", "$stdout"); }