use of org.apache.sling.scripting.sightly.js.impl.JsEnvironment in project sling by apache.
the class SlyBindingsValuesProvider method ensureFactoriesLoaded.
private void ensureFactoriesLoaded(Bindings bindings) {
JsEnvironment jsEnvironment = null;
ResourceResolver resolver = null;
try {
ScriptEngine scriptEngine = obtainEngine();
if (scriptEngine == null) {
return;
}
jsEnvironment = new JsEnvironment(scriptEngine);
jsEnvironment.initialize();
resolver = rrf.getServiceResourceResolver(null);
factories = new HashMap<>(scriptPaths.size());
for (Map.Entry<String, String> entry : scriptPaths.entrySet()) {
factories.put(entry.getKey(), loadFactory(resolver, jsEnvironment, entry.getValue(), bindings));
}
qScript = loadQScript(resolver);
} catch (LoginException e) {
LOGGER.error("Cannot load HTL Use-API factories.", e);
} finally {
if (jsEnvironment != null) {
jsEnvironment.cleanup();
}
if (resolver != null) {
resolver.close();
}
}
}
Aggregations