Java Code Examples for org.mozilla.javascript.ContextFactory#initGlobal()
The following examples show how to use
org.mozilla.javascript.ContextFactory#initGlobal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppRunnerInterpreter.java From PHONK with GNU General Public License v3.0 | 6 votes |
public void init() { //this can be initiated only once if (mScriptContextFactory == null) { mScriptContextFactory = new ScriptContextFactory(); ContextFactory.initGlobal(mScriptContextFactory); } mScriptContextFactory.setInterpreter(this); rhino = Context.enter(); // observingDebugger = new ObservingDebugger(); // rhino.setDebugger(observingDebugger, new Integer(0)); // rhino.setGeneratingDebug(true); // give some android love rhino.setOptimizationLevel(-1); scope = rhino.initStandardObjects(); //let rhino do some java <-> js transformations for us rhino.getWrapFactory().setJavaPrimitiveWrap(false); }
Example 2
Source File: SecureJavascriptConfigurator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected synchronized void initSecureScriptContextFactory() { if (secureScriptContextFactory == null) { secureScriptContextFactory = new SecureScriptContextFactory(); secureScriptContextFactory.setOptimizationLevel(getScriptOptimizationLevel()); if (isEnableClassWhiteListing() || getWhiteListedClasses() != null || classWhitelister != null) { if (classWhitelister == null) { classWhitelister = new DefaultClassWhitelister(); if (getWhiteListedClasses() != null && getWhiteListedClasses().size() > 0) { ((DefaultClassWhitelister)classWhitelister).setWhiteListedClasses(getWhiteListedClasses()); } } secureScriptClassShutter = new SecureScriptClassShutter(); secureScriptClassShutter.setClassWhitelister(classWhitelister); secureScriptContextFactory.setClassShutter(secureScriptClassShutter); } if (getMaxScriptExecutionTime() > 0L) { secureScriptContextFactory.setMaxScriptExecutionTime(getMaxScriptExecutionTime()); } if (getMaxMemoryUsed() > 0L) { secureScriptContextFactory.setMaxMemoryUsed(getMaxMemoryUsed()); } if (getMaxStackDepth() > 0) { secureScriptContextFactory.setMaxStackDepth(getMaxStackDepth()); } if (getMaxScriptExecutionTime() > 0L || getMaxMemoryUsed() > 0L) { secureScriptContextFactory.setObserveInstructionCount(getNrOfInstructionsBeforeStateCheckCallback()); } ContextFactory.initGlobal(secureScriptContextFactory); } }
Example 3
Source File: SecureJavascriptConfigurator.java From flowable-engine with Apache License 2.0 | 5 votes |
protected synchronized void initSecureScriptContextFactory() { if (secureScriptContextFactory == null) { secureScriptContextFactory = new SecureScriptContextFactory(); secureScriptContextFactory.setOptimizationLevel(getScriptOptimizationLevel()); if (isEnableClassWhiteListing() || getWhiteListedClasses() != null) { secureScriptClassShutter = new SecureScriptClassShutter(); if (getWhiteListedClasses() != null && getWhiteListedClasses().size() > 0) { secureScriptClassShutter.setWhiteListedClasses(getWhiteListedClasses()); } secureScriptContextFactory.setClassShutter(secureScriptClassShutter); } if (getMaxScriptExecutionTime() > 0L) { secureScriptContextFactory.setMaxScriptExecutionTime(getMaxScriptExecutionTime()); } if (getMaxMemoryUsed() > 0L) { secureScriptContextFactory.setMaxMemoryUsed(getMaxMemoryUsed()); } if (getMaxStackDepth() > 0) { secureScriptContextFactory.setMaxStackDepth(getMaxStackDepth()); } if (getMaxScriptExecutionTime() > 0L || getMaxMemoryUsed() > 0L) { secureScriptContextFactory.setObserveInstructionCount(getNrOfInstructionsBeforeStateCheckCallback()); } secureScriptContextFactory.setEnableAccessToBeans(isEnableAccessToBeans()); ContextFactory.initGlobal(secureScriptContextFactory); } }
Example 4
Source File: JavascriptEngineFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public static void initMyFactory( ) { ContextFactory.initGlobal( new MyFactory( ) ); if ( System.getSecurityManager( ) != null ) { SecurityController.initGlobal( ScriptUtil .createSecurityController( ) ); } }