Search in sources :

Example 1 with SlingScriptEngineManager

use of org.apache.sling.scripting.core.impl.helper.SlingScriptEngineManager in project sling by apache.

the class ScriptEngineManagerFactory method refreshScriptEngineManager.

/**
     * Refresh the script engine manager.
     */
private void refreshScriptEngineManager() {
    // create (empty) script engine manager
    final ClassLoader loader = getClass().getClassLoader();
    final SlingScriptEngineManager tmp = new SlingScriptEngineManager(loader);
    // register script engines from bundles
    synchronized (this.engineSpiBundles) {
        for (final Bundle bundle : this.engineSpiBundles) {
            registerFactories(tmp, bundle);
        }
    }
    // register script engines from registered services
    synchronized (this.engineSpiServices) {
        for (final Map.Entry<ScriptEngineFactory, Map<Object, Object>> factory : this.engineSpiServices.entrySet()) {
            registerFactory(tmp, factory.getKey(), factory.getValue());
        }
    }
    scriptEngineManager.setDelegatee(tmp);
    final List<ScriptEngineFactory> factories = tmp.getEngineFactories();
    for (final ScriptEngineFactory factory : factories) {
        log.info("ScriptEngine {}/{} is now handling {}, {}, {}.", new Object[] { factory.getEngineName(), factory.getEngineVersion(), factory.getExtensions(), factory.getMimeTypes(), factory.getNames() });
    }
}
Also used : SlingScriptEngineManager(org.apache.sling.scripting.core.impl.helper.SlingScriptEngineManager) Bundle(org.osgi.framework.Bundle) ScriptEngineFactory(javax.script.ScriptEngineFactory) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ScriptEngineFactory (javax.script.ScriptEngineFactory)1 SlingScriptEngineManager (org.apache.sling.scripting.core.impl.helper.SlingScriptEngineManager)1 Bundle (org.osgi.framework.Bundle)1