in src/main/java/org/apache/sling/scripting/sightly/js/impl/jsapi/SlyBindingsValuesProvider.java [267:291]
private Script loadQScript(ResourceResolver resolver) {
Context context = Context.enter();
context.initStandardObjects();
context.setOptimizationLevel(9);
InputStream reader = null;
try {
Resource resource = resolver.getResource(Q_PATH);
if (resource == null) {
LOGGER.warn("Could not load Q library at path: " + Q_PATH);
return null;
}
reader = resource.adaptTo(InputStream.class);
if (reader == null) {
LOGGER.warn("Could not read content of Q library");
return null;
}
return context.compileReader(new InputStreamReader(reader, StandardCharsets.UTF_8), Q_PATH, 0, null);
} catch (IOException e) {
LOGGER.error("Unable to compile the Q library at path " + Q_PATH + ".", e);
} finally {
Context.exit();
IOUtils.closeQuietly(reader);
}
return null;
}