本文整理汇总了Java中javax.script.SimpleBindings.put方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleBindings.put方法的具体用法?Java SimpleBindings.put怎么用?Java SimpleBindings.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.script.SimpleBindings
的用法示例。
在下文中一共展示了SimpleBindings.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeScriptWithConsole
import javax.script.SimpleBindings; //导入方法依赖的package包/类
public Object executeScriptWithConsole(ScriptType type, String script, Map<String, Object> params, StringWriter console) {
ScriptEngine scriptEngine = produceScriptEngine(type);
if (console != null) {
scriptEngine.getContext().setWriter(console);
}
SimpleBindings bindings = new SimpleBindings();
bindings.putAll(params);
bindings.put("spring", context);
try {
return scriptEngine.eval(script, bindings);
} catch (ScriptException ex) {
throw new GeneralException(ex);
}
}
示例2: execute
import javax.script.SimpleBindings; //导入方法依赖的package包/类
private Object execute(MapAttribute wellKnowsAttributes) throws MetaException {
try {
SimpleBindings bindings = new SimpleBindings();
bindings.put("attributes", wellKnowsAttributes);
Invocable invocable = (Invocable)engines.getCachedEngine(javascriptPath);
return invocable.invokeFunction("create", wellKnowsAttributes);
} catch (ScriptException|NoSuchMethodException|IOException|URISyntaxException ex) {
throw new MetaException("Error executing script.", ex);
}
}
示例3: handle
import javax.script.SimpleBindings; //导入方法依赖的package包/类
@Override
public void handle(ByteBuf buf, MapleClient client) {
buf.readByte();
String startwp = readMapleAsciiString(buf);
buf.readShort();
MaplePortal portal = client.getCharacter().getMap().getPortal(startwp);
if (portal == null) {
client.sendReallowActions();
return;
}
if(portal.isBlocked(client.getCharacter())){
client.sendReallowActions();
return;
}
if(client.getCharacter().getMapId() == 910000000){
client.getCharacter().changeMap(client.getCharacter().getFmReturnMap());
}else if(portal.getTargetMapId() == 999999999){
MapleScript script = new MapleScript("scripts/portal/"+portal.getScriptName()+".js", "scripts/portal/fallback.js");
PortalScriptManager pm = new PortalScriptManager(client.getCharacter(), portal);
client.getLogger().debug("Running portal script "+script.getFile().getPath());
SimpleBindings sb = new SimpleBindings();
sb.put("pm", pm);
try {
script.execute(sb).startPortal();
} catch (Exception e) {
e.printStackTrace();
client.getLogger().error("Error running script "+portal.getScriptName());
}
client.sendReallowActions();
}else{
portal.enterPortal(client);
}
}
示例4: openSimpleTextNpc
import javax.script.SimpleBindings; //导入方法依赖的package包/类
public void openSimpleTextNpc(String text){
SimpleBindings sb = new SimpleBindings();
sb.put("text", text);
openNpc(new MapleScript("scripts/npc/simple_talk.js"), sb, MapleLifeFactory.getNPC(2080005));
}