use of org.apache.sling.scripting.xproc.xpl.api.Pipeline in project sling by apache.
the class XProcScriptEngine method eval.
public Object eval(Reader reader, ScriptContext scriptContext) throws ScriptException {
Bindings bindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
SlingScriptHelper helper = (SlingScriptHelper) bindings.get(SlingBindings.SLING);
if (helper == null) {
throw new ScriptException("SlingScriptHelper missing from bindings");
}
String scriptName = helper.getScript().getScriptResource().getPath();
try {
XplBuilder xplBuilder = new XplBuilder();
Pipeline xpl = (Pipeline) xplBuilder.build(reader);
xpl.getEnv().setSling(helper);
xpl.eval();
} catch (Throwable t) {
log.error("Failure running XProc script.", t);
final ScriptException se = new ScriptException("Failure running XProc script " + scriptName);
se.initCause(t);
throw se;
}
return null;
}
Aggregations