本文整理汇总了Java中org.mozilla.javascript.ContextFactory.initGlobal方法的典型用法代码示例。如果您正苦于以下问题:Java ContextFactory.initGlobal方法的具体用法?Java ContextFactory.initGlobal怎么用?Java ContextFactory.initGlobal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ContextFactory
的用法示例。
在下文中一共展示了ContextFactory.initGlobal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
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);
}
示例2: create
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
@Override
public void create() {
Gdx.app.log(TAG, "created");
Tween.registerAccessor(ModelEntity.class, new ModelEntityAccessor());
Tween.registerAccessor(RTSCameraController.class, new CameraAccessor());
Tween.registerAccessor(RobotEntity.class, new RobotEntityAccessor());
ContextFactory.initGlobal(new ScriptContextFactory());
BotLogic.game = this;
BotLogic.inputManager = new InputManager();
BotLogic.audio = new AudioManager();
BotLogic.skin = new FlatSkin();
BotLogic.models = new ModelManager();
BotLogic.sprites = new SpritesManager();
BotLogic.entities = new EntityManager();
BotLogic.config = new ConfigManager();
BotLogic.screens = new ScreenManager(this);// always last!!!
BotLogic.config.load();
loading = false;
fpsLogger = new FPSLogger();
BotLogic.screens.goToMainMenu();
}
示例3: createContext
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
protected Context createContext() {
if (!ContextFactory.hasExplicitGlobal()) {
ContextFactory.initGlobal(new InterruptibleAndroidContextFactory(new File(mAndroidContext.getCacheDir(), "classes")));
}
Context context = new RhinoAndroidHelper(mAndroidContext).enterContext();
contextCount++;
context.setOptimizationLevel(-1);
context.setLanguageVersion(Context.VERSION_ES6);
return context;
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:11,代码来源:RhinoJavaScriptEngine.java
示例4: initSecureScriptContextFactory
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
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());
}
ContextFactory.initGlobal(secureScriptContextFactory);
}
}
示例5: init
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
public void init(TaleCraft taleCraft, CommonProxy proxy) {
TaleCraft.logger.info("Initializing Rhino Script Engine...");
globalScope = new NativeObject();
globalClassShutter = new GlobalClassShutter();
cache = new WrapperClassCache();
globalContextFactory = new GlobalContextFactory();
ContextFactory.initGlobal(globalContextFactory);
Context cx = Context.enter();
try {
ScriptRuntime.initStandardObjects(cx, globalScope, true);
globalScriptObject = new GlobalScriptObject(this);
ScriptableObject.putProperty(globalScope, "system", Context.javaToJS(globalScriptObject, globalScope));
consoleOutput = new ConsoleOutput();
ScriptableObject.putProperty(globalScope, "out", Context.javaToJS(consoleOutput, globalScope));
// String loadMe = "RegExp; getClass; java; Packages; JavaAdapter;";
// cx.evaluateString(globalScope , loadMe, "lazyLoad", 0, null);
// Startup Script Test
String startupTestScript = "msg = \"Rhino Time!\"; msg;";
Object startupTestScriptResult = cx.evaluateString(globalScope, startupTestScript, "<cmd>", 0, null);
TaleCraft.logger.info("Startup Script Test: " + startupTestScriptResult);
} finally {
Context.exit();
}
TaleCraft.logger.info("Script Engine initialized!");
}
示例6: initMyFactory
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
public static void initMyFactory( )
{
ContextFactory.initGlobal( new MyFactory( ) );
if ( System.getSecurityManager( ) != null )
{
SecurityController.initGlobal( ScriptUtil
.createSecurityController( ) );
}
}
示例7: JavaScriptProcessor
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
/**
* Constructor which initializes a local JavaScript context. This is for security reasons to not access any
* System or application ressources but only process on parameters and variables.
*/
public JavaScriptProcessor() {
if(ContextFactory.getGlobal() == null || ContextFactory.getGlobal() instanceof SandboxContextFactory) {
ContextFactory.initGlobal(new SandboxContextFactory());
}
}
示例8: brew
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
@Override
public void brew(Brewery brewery) {
this.maxScriptDurationInMillis = 1*1000; // 10 seconds
this.contextFactory = new SandboxContextFactory();
ContextFactory.initGlobal(this.contextFactory);
}
示例9: init
import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
@EventHandler
public void init(FMLInitializationEvent event) {
/*
* Initialize our special context factory
*/
ContextFactory.initGlobal(new SandboxContextFactory());
ReflectionHelper.init();
DefaultFilters.init(new File(new File(proxy.getMinecraftDir(), "scripts"), "server"));
FMLCommonHandler.instance().bus().register(this);
DISPATCHER.initialize();
addAbbreviation("Vec3", ScriptVec3.class);
addAbbreviation("Vec2", ScriptVec2.class);
addAbbreviation("ItemStack", ScriptItemStack.class);
addAbbreviation("Rand", ScriptRandom.class);
addAbbreviation("Array", ScriptArray.class);
addAbbreviation("IO", ScriptIO.class);
addAbbreviation("Script", ScriptHelper.class);
addAbbreviation("Block", ScriptBlock.class);
addAbbreviation("Item", ScriptItem.class);
addAbbreviation("Setting", Setting.class);
addAbbreviation("SettingBoolean", SettingBoolean.class);
addAbbreviation("SettingInt", SettingInt.class);
addAbbreviation("SettingFloat", SettingFloat.class);
addAbbreviation("SettingString", SettingString.class);
addAbbreviation("SettingList", SettingList.class);
addAbbreviation("SettingBlock", SettingBlock.class);
addAbbreviation("SettingItem", SettingItem.class);
addAbbreviation("DataWatcher", ScriptDataWatcher.class);
addAbbreviation("Entity", ScriptEntity.class);
addAbbreviation("TileEntity", ScriptTileEntity.class);
addAbbreviation("TAG_Byte", TAG_Byte.class);
addAbbreviation("TAG_Byte_Array", TAG_Byte_Array.class);
addAbbreviation("TAG_Compound", TAG_Compound.class);
addAbbreviation("TAG_Double", TAG_Double.class);
addAbbreviation("TAG_Float", TAG_Float.class);
addAbbreviation("TAG_Int", TAG_Int.class);
addAbbreviation("TAG_Int_Array", TAG_Int_Array.class);
addAbbreviation("TAG_List", TAG_List.class);
addAbbreviation("TAG_Long", TAG_Long.class);
addAbbreviation("TAG_Short", TAG_Short.class);
addAbbreviation("TAG_String", TAG_String.class);
}