use of com.infiniteautomation.mango.spring.script.MangoScriptException.ScriptInterfaceException in project ma-core-public by MangoAutomation.
the class ScriptService method getInterface.
public <T> T getInterface(MangoScript script, Class<T> clazz, EvalContext evalContext) {
ScriptAndEngine scriptAndEngine = getScriptEngine(script);
ScriptEngine engine = scriptAndEngine.engine;
if (!(engine instanceof Invocable)) {
throw new EngineNotInvocableException(engine);
}
evalScript(scriptAndEngine, evalContext);
T instance = ((Invocable) engine).getInterface(clazz);
if (instance == null) {
throw new ScriptInterfaceException(clazz);
}
ScriptEngineDefinition engineDefinition = scriptAndEngine.engineDefinition;
T runAsInstance = runAs.runAsProxy(script, instance);
if (engineDefinition.singleThreadedAccess()) {
return synchronizedProxy(scriptAndEngine.synchronizationObject, runAsInstance);
}
return runAsInstance;
}
use of com.infiniteautomation.mango.spring.script.MangoScriptException.ScriptInterfaceException in project ma-core-public by infiniteautomation.
the class ScriptService method getInterface.
public <T> T getInterface(MangoScript script, Class<T> clazz, EvalContext evalContext) {
ScriptAndEngine scriptAndEngine = getScriptEngine(script);
ScriptEngine engine = scriptAndEngine.engine;
if (!(engine instanceof Invocable)) {
throw new EngineNotInvocableException(engine);
}
evalScript(scriptAndEngine, evalContext);
T instance = ((Invocable) engine).getInterface(clazz);
if (instance == null) {
throw new ScriptInterfaceException(clazz);
}
ScriptEngineDefinition engineDefinition = scriptAndEngine.engineDefinition;
T runAsInstance = runAs.runAsProxy(script, instance);
if (engineDefinition.singleThreadedAccess()) {
return synchronizedProxy(scriptAndEngine.synchronizationObject, runAsInstance);
}
return runAsInstance;
}
Aggregations