當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。