use of org.apache.sling.scripting.javascript.helper.SlingWrapFactory in project sling by apache.
the class RhinoJavaScriptEngineFactory method activate.
// ---------- SCR integration
@Activate
protected void activate(final ComponentContext context, final RhinoJavaScriptEngineFactoryConfiguration configuration) {
Dictionary<?, ?> props = context.getProperties();
boolean debugging = getProperty("org.apache.sling.scripting.javascript.debug", props, context.getBundleContext(), false);
optimizationLevel = readOptimizationLevel(configuration);
// setup the wrap factory
wrapFactory = new SlingWrapFactory();
// initialize the Rhino Context Factory
SlingContextFactory.setup(this);
Context cx = Context.enter();
setEngineName(getEngineName() + " (" + cx.getImplementationVersion() + ")");
languageVersion = String.valueOf(cx.getLanguageVersion());
Context.exit();
setExtensions(ECMA_SCRIPT_EXTENSION, ESP_SCRIPT_EXTENSION);
setMimeTypes("text/javascript", "application/ecmascript", "application/javascript");
setNames("javascript", ECMA_SCRIPT_EXTENSION, ESP_SCRIPT_EXTENSION);
final ContextFactory contextFactory = ContextFactory.getGlobal();
if (contextFactory instanceof SlingContextFactory) {
((SlingContextFactory) contextFactory).setDebugging(debugging);
}
// set the dynamic class loader as the application class loader
final DynamicClassLoaderManager dclm = this.dynamicClassLoaderManager;
if (dclm != null) {
contextFactory.initApplicationClassLoader(dynamicClassLoaderManager.getDynamicClassLoader());
}
log.info("Activated with optimization level {}", optimizationLevel);
}
Aggregations