本文整理了Java中javax.script.ScriptEngine.setContext()
方法的一些代码示例,展示了ScriptEngine.setContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScriptEngine.setContext()
方法的具体详情如下:
包路径:javax.script.ScriptEngine
类名称:ScriptEngine
方法名:setContext
[英]Sets the default ScriptContext of the ScriptEngine whose Bindings, Readers and Writers are used for script executions when no ScriptContext is specified.
[中]设置ScriptEngine的默认ScriptContext,当未指定ScriptContext时,其绑定、读卡器和写卡器用于脚本执行。
代码示例来源:origin: looly/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: looly/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: looly/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: looly/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: OpenNMS/opennms
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
@Override
代码示例来源:origin: com.xiaoleilu/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: org.opennms.features/org.opennms.features.osgi-jsr223
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
@Override
代码示例来源:origin: rhq-project/rhq
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: org.scijava/scijava-common
@Override
public void setContext(final ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: com.xiaoleilu/hutool
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: cn.hutool/hutool-all
@Override
public void setContext(ScriptContext context) {
engine.setContext(context);
}
代码示例来源:origin: org.apache.myfaces.extensions.cdi.bundles/myfaces-extcdi-bundle-jsf20
/**
* {@inheritDoc}
*/
public void setContext(ScriptContext context)
{
getScriptEngine().setContext(context);
}
代码示例来源:origin: org.apache.myfaces.extensions.cdi.modules/myfaces-extcdi-scripting-module-impl
/**
* {@inheritDoc}
*/
public void setContext(ScriptContext context)
{
getScriptEngine().setContext(context);
}
代码示例来源:origin: com.github.adrianbk/http-stub-server-core
private ScriptEngine createEngine() {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
engine.setContext(new SimpleScriptContext());
return engine;
}
代码示例来源:origin: org.apache.myfaces.extensions.cdi.bundles/myfaces-extcdi-bundle-jsf12
/**
* {@inheritDoc}
*/
public void setContext(ScriptContext context)
{
getScriptEngine().setContext(context);
}
代码示例来源:origin: pentaho/pentaho-reporting
public Object eval( final String script, final String scriptLanguage ) throws ScriptException {
final ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName( scriptLanguage );
if ( scriptEngine == null ) {
throw new ScriptException( String.format(
"DataFactoryScriptingSupport: Failed to locate scripting engine for language '%s'.", scriptLanguage ) );
}
scriptEngine.setContext( context );
return scriptEngine.eval( script );
}
代码示例来源:origin: stackoverflow.com
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("nashorn");
ScriptContext ctx = new SimpleScriptContext();
ctx.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
engine.eval("function hello() { return 'Hello!'; }", ctx);
engine.setContext(ctx);
((Invocable) engine).invokeFunction("hello");
代码示例来源:origin: stackoverflow.com
ScriptContext context = new SimpleScriptContext();
context.setWriter(writer);
ScriptEngine engine = manager.getEngineByName("python");
// CHANGE: Set the context in the engine, so that invoking functions
// is done in the same scope as evaluating the script.
engine.setContext(context);
engine.eval(new FileReader("test.py"));
Invocable inv = (Invocable)engine;
inv.invokeFunction("func_name", param1, param2);
内容来源于网络,如有侵权,请联系作者删除!