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


Java ModuleScriptProvider类代码示例

本文整理汇总了Java中org.mozilla.javascript.commonjs.module.ModuleScriptProvider的典型用法代码示例。如果您正苦于以下问题:Java ModuleScriptProvider类的具体用法?Java ModuleScriptProvider怎么用?Java ModuleScriptProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModuleScriptProvider类属于org.mozilla.javascript.commonjs.module包,在下文中一共展示了ModuleScriptProvider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MultiModuleScriptProvider

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
/**
 * Creates a new multiplexing module script provider tht gathers the
 * specified providers
 * @param providers the providers to multiplex.
 */
public MultiModuleScriptProvider(Iterable<? extends ModuleScriptProvider> providers) {
    final List<ModuleScriptProvider> l = new LinkedList<ModuleScriptProvider>();
    for (ModuleScriptProvider provider : providers) {
        l.add(provider);
    }
    this.providers = l.toArray(new ModuleScriptProvider[l.size()]);
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:13,代码来源:MultiModuleScriptProvider.java

示例2: getModuleScript

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri,
                                    URI base, Scriptable paths) throws Exception {
    for (ModuleScriptProvider provider : providers) {
        final ModuleScript script = provider.getModuleScript(cx, moduleId,
                uri, base, paths);
        if(script != null) {
            return script;
        }
    }
    return null;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:12,代码来源:MultiModuleScriptProvider.java

示例3: MultiModuleScriptProvider

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
/**
 * Creates a new multiplexing module script provider tht gathers the 
 * specified providers
 * @param providers the providers to multiplex.
 */
public MultiModuleScriptProvider(Iterable<? extends ModuleScriptProvider> providers) {
    final List<ModuleScriptProvider> l = new LinkedList<ModuleScriptProvider>();
    for (ModuleScriptProvider provider : providers) {
        l.add(provider);
    }
    this.providers = l.toArray(new ModuleScriptProvider[l.size()]);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:13,代码来源:MultiModuleScriptProvider.java

示例4: getModuleScript

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri,
                                    Scriptable paths) throws Exception {
    for (ModuleScriptProvider provider : providers) {
        final ModuleScript script = provider.getModuleScript(cx, moduleId,
                uri, paths);
        if(script != null) {
            return script;
        }
    }
    return null;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:12,代码来源:MultiModuleScriptProvider.java

示例5: getModuleScript

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
@Override
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri,
                                      URI base, Scriptable paths) throws Exception {
      for (ModuleScriptProvider provider : providers) {
          final ModuleScript script = provider.getModuleScript(cx, moduleId,
                  uri, base, paths);
          if(script != null) {
              return script;
          }
      }
      return null;
  }
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:13,代码来源:MultiModuleScriptProvider.java

示例6: getModuleScript

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
@Override
public ModuleScript getModuleScript(Context cx, String moduleId, URI uri,
                                       URI base, Scriptable paths) throws Exception {
       for (ModuleScriptProvider provider : providers) {
           final ModuleScript script = provider.getModuleScript(cx, moduleId,
                   uri, base, paths);
           if(script != null) {
               return script;
           }
       }
       return null;
   }
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:13,代码来源:MultiModuleScriptProvider.java

示例7: executeInternal

import org.mozilla.javascript.commonjs.module.ModuleScriptProvider; //导入依赖的package包/类
private Object executeInternal(final String script, final String scriptName, final ScriptContext context,
	final boolean function, final Class<?> expectedResultClass) throws ScriptException
{
	// never ever execute an empty script, it's just a waste of time
	if( !Check.isEmpty(script) )
	{
		// In most cases apart from calls from birt, we can expect that
		// there'll be no current context, thus one will be generated by
		// this call into the ContextFactory
		return ContextFactory.getGlobal().call(new ContextAction()
		{
			@Override
			public Object run(Context cx)
			{
				Logger errorLogger = context.getLogger();
				if( errorLogger == null )
				{
					errorLogger = logger;
				}

				Scriptable userScriptScope = ((DefaultScriptContext) context).getUserScriptScope(cx);
				ScriptableModuleSourceProvider sourceProvider = new ScriptableModuleSourceProvider(userScriptScope);
				ModuleScriptProvider scriptProvider = new SoftCachingModuleScriptProvider(sourceProvider);

				cx.initStandardObjects();
				Scriptable scope = ((DefaultScriptContext) context).getScope(cx);

				RequireBuilder builder = new RequireBuilder();
				// The "uri" property must not exist in a sandbox
				builder.setSandboxed(false);
				builder.setModuleScriptProvider(scriptProvider);

				Require require = builder.createRequire(cx, scope);

				cx.setOptimizationLevel(-1);
				cx.setErrorReporter(new ScriptErrorReporter(errorLogger));


				final String execScript = (function ? "function runScript() {\n" + script + "\n}\n runScript();"
					: script);
				final String execScriptName = (scriptName != null ? scriptName : "script");

				try
				{
					context.scriptEnter();
					require.install(scope);

					Object result = cx.evaluateString(scope, execScript, execScriptName, 1, null);

					context.scriptExit();
					if( expectedResultClass == String.class )
					{
						return result.toString();
					}
					return result;
				}
				catch( JavaScriptException js )
				{
					throw new ScriptException(js);
				}
				catch( EcmaError ec )
				{
					throw new ScriptException(ec);
				}
				catch( EvaluatorException ev )
				{
					throw new ScriptException(ev);
				}
			}
		});
	}
	return Boolean.TRUE;

}
 
开发者ID:equella,项目名称:Equella,代码行数:75,代码来源:ScriptingServiceImpl.java


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