Refine search
Script jsscript; jscx = ContextFactory.getGlobal().enterContext(); jsscope = jscx.initStandardObjects( null, false ); try { jscx.setOptimizationLevel( Integer.valueOf( transMeta.environmentSubstitute( optimizationLevel ) ) ); } catch ( NumberFormatException nfe ) { error_message = Scriptable jsR = Context.toObject( jsScripts[i].getScript(), jsscope ); jsscope.put( jsScripts[i].getScriptName(), jsscope, jsR );
@Override protected Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { RhinoContext mcx = (RhinoContext) cx; mcx.startTime = System.currentTimeMillis(); return super.doTopCall(callable, cx, scope, thisObj, args); }
public static String getVersion() { return ContextFactory.getGlobal().enterContext().getImplementationVersion(); }
private static Function compile(String function) { final ContextFactory contextFactory = ContextFactory.getGlobal(); final Context context = contextFactory.enterContext(); context.setOptimizationLevel(JavaScriptConfig.DEFAULT_OPTIMIZATION_LEVEL); final ScriptableObject scope = context.initStandardObjects(); final org.mozilla.javascript.Function fn = context.compileFunction(scope, function, "fn", 1, null); Context.exit(); return new Function() { @Override public double apply(Object[] args) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } return Context.toNumber(fn.call(cx, scope, scope, args)); } }; }
@Before public void setUp() { request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); jsContext = ContextFactory.getGlobal().enterContext(); jsScope = jsContext.initStandardObjects(); view = new MappingJackson2JsonView(); }
Scriptable scope; cx = ContextFactory.getGlobal().enterContext(); scope = cx.initStandardObjects( null ); Object res = cx.evaluateString( scope, this.script, "<cmd>", 1, null ); boolean retval = Context.toBoolean( res );
@Override public Object apply(Object input) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } final Object res = fn.call(cx, scope, scope, new Object[]{input}); return res != null ? Context.toObject(res, scope) : null; } };
/** * Creates a Context object for use with the interpreter. */ protected Context makeContext() { Context cx = super.makeContext(); cx.setWrapFactory(wrapFactory); cx.setSecurityController(securityController); cx.setClassShutter(classShutter); if (rhinoClassLoader == null) { cx.setOptimizationLevel(-1); } return cx; } }
@Override public String apply(Object input) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } final Object res = fn.call(cx, scope, scope, new Object[]{input}); return res != null ? Context.toString(res) : null; } };
/** * @deprecated * @see ContextFactory#removeListener(ContextFactory.Listener) * @see ContextFactory#getGlobal() */ public static void removeContextListener(ContextListener listener) { ContextFactory.getGlobal().addListener(listener); }
@Close public void close() { final Context context = _contextFactory.enterContext(); try { _closeFunction.call(context, _sharedScope, _sharedScope, new Object[0]); } finally { Context.exit(); } }
protected Context makeContext() { Context cx = super.makeContext(); cx.setOptimizationLevel(-1); return cx; } });
@Override public double apply(Object[] args) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } return Context.toNumber(fn.call(cx, scope, scope, args)); } };
/** * Create new Context instance to be associated with the current thread. */ @Override protected Context makeContext() { Context cx = super.makeContext(); cx.setLanguageVersion(languageVersion); cx.setOptimizationLevel(optimizationLevel); cx.setClassShutter(RhinoClassShutter.getInstance()); cx.setWrapFactory(RhinoWrapFactory.getInstance()); return cx; }
public void initialize() { if (!initialized) { if ("true".equals(getProperty(USE_INTERPRETER_SYSTEM_PROPERTY))) { if (!ContextFactory.hasExplicitGlobal()) { ContextFactory.initGlobal(new ContextFactory() { protected Context makeContext() { Context cx = super.makeContext(); cx.setOptimizationLevel(-1); return cx; } }); } } if (listener != null) { ContextFactory.getGlobal().addListener(listener); } initialized = true; } }
@Override protected Context makeContext() { Context cx = super.makeContext(); cx.setOptimizationLevel(-1); cx.setWrapFactory(new CustomWrapFactory()); return cx; }
private static Context prepareNewContext(ContextFactory factory, Object contextHelper) { Context cx = factory.makeContext(); if (cx.factory != null || cx.enterCount != 0) { throw new IllegalStateException("factory.makeContext() returned Context instance already associated with some thread"); } cx.factory = factory; factory.onContextCreated(cx); if (factory.isSealed() && !cx.isSealed()) { cx.seal(null); } VMBridge.instance.setContext(contextHelper, cx); return cx; }
public static Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (scope == null) throw new IllegalArgumentException(); if (cx.topCallScope != null) throw new IllegalStateException(); Object result; cx.topCallScope = ScriptableObject.getTopLevelScope(scope); cx.useDynamicScope = cx.hasFeature(Context.FEATURE_DYNAMIC_SCOPE); ContextFactory f = cx.getFactory(); try { result = f.doTopCall(callable, cx, scope, thisObj, args); } finally { cx.topCallScope = null; // Cleanup cached references cx.cachedXMLLib = null; if (cx.currentActivationCall != null) { // Function should always call exitActivationFunction // if it creates activation record throw new IllegalStateException(); } } return result; }
/** * To be used by <code>WindowWrapper</code>. */ void callHandler(final Function handler, final Object[] args) { contextFactory.call(new ContextAction() { public Object run(Context cx) { handler.call(cx, globalObject, globalObject, args); return null; } }); }