use of com.serotonin.m2m2.rt.event.handlers.EventHandlerInterface in project ma-core-public by MangoAutomation.
the class ScriptEventHandlerDefinition method createRuntimeInternal.
private ScriptEventHandlerRT createRuntimeInternal(ScriptEventHandlerVO vo) {
Map<String, Object> bindings = Collections.singletonMap(ScriptEventHandlerRT.EVENT_HANDLER_KEY, vo);
EvalContext context = new EvalContext(bindings);
PermissionHolder user = Common.getUser();
if (permissionService.hasPermission(user, standardStreamsPermission.getPermission())) {
context.setWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
context.setErrorWriter(new BufferedWriter(new OutputStreamWriter(System.err)));
context.setReader(new BufferedReader(new InputStreamReader(System.in)));
}
EventHandlerInterface scriptHandlerDelegate = scriptService.getInterface(vo.toMangoScript(), EventHandlerInterface.class, context);
return new ScriptEventHandlerRT(vo, scriptHandlerDelegate);
}
use of com.serotonin.m2m2.rt.event.handlers.EventHandlerInterface in project ma-core-public by infiniteautomation.
the class ScriptEventHandlerDefinition method createRuntimeInternal.
private ScriptEventHandlerRT createRuntimeInternal(ScriptEventHandlerVO vo) {
Map<String, Object> bindings = Collections.singletonMap(ScriptEventHandlerRT.EVENT_HANDLER_KEY, vo);
EvalContext context = new EvalContext(bindings);
PermissionHolder user = Common.getUser();
if (permissionService.hasPermission(user, standardStreamsPermission.getPermission())) {
context.setWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
context.setErrorWriter(new BufferedWriter(new OutputStreamWriter(System.err)));
context.setReader(new BufferedReader(new InputStreamReader(System.in)));
}
EventHandlerInterface scriptHandlerDelegate = scriptService.getInterface(vo.toMangoScript(), EventHandlerInterface.class, context);
return new ScriptEventHandlerRT(vo, scriptHandlerDelegate);
}
Aggregations