当前位置: 首页>>代码示例>>Java>>正文


Java ContextFactory.initGlobal方法代码示例

本文整理汇总了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);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:22,代码来源:AppRunnerInterpreter.java

示例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();
}
 
开发者ID:macbury,项目名称:BotLogic,代码行数:26,代码来源:GameManager.java

示例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);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:34,代码来源:SecureJavascriptConfigurator.java

示例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!");
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:32,代码来源:GlobalScriptManager.java

示例6: initMyFactory

import org.mozilla.javascript.ContextFactory; //导入方法依赖的package包/类
public static void initMyFactory( )
{
	ContextFactory.initGlobal( new MyFactory( ) );
	if ( System.getSecurityManager( ) != null )
	{
		SecurityController.initGlobal( ScriptUtil
				.createSecurityController( ) );
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:10,代码来源:JavascriptEngineFactory.java

示例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());
}

  }
 
开发者ID:mschachtel,项目名称:cloutree-modelevaluator,代码行数:12,代码来源:JavaScriptProcessor.java

示例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);
}
 
开发者ID:effektif,项目名称:effektif,代码行数:7,代码来源:RhinoSandboxedScriptService.java

示例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);
}
 
开发者ID:DavidGoldman,项目名称:MinecraftScripting,代码行数:49,代码来源:ScriptingMod.java


注:本文中的org.mozilla.javascript.ContextFactory.initGlobal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。