/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.sling.scripting.core.impl.helper;

import java.util.ArrayList;
import java.util.List;

import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;

public class SlingScriptEngineManager extends ScriptEngineManager {

    List<ScriptEngineFactory> factories = new ArrayList<ScriptEngineFactory>();

    public SlingScriptEngineManager(ClassLoader classLoader) {
        super(classLoader);
    }

    public void registerScriptEngineFactory(ScriptEngineFactory factory) {
        for (Object ext : factory.getExtensions()) {
            registerEngineExtension((String) ext, factory);
        }

        for (Object mime : factory.getMimeTypes()) {
            registerEngineMimeType((String) mime, factory);
        }

        for (Object name : factory.getNames()) {
            registerEngineName((String) name, factory);
        }

        factories.add(factory);
    }

    @Override
    public List<ScriptEngineFactory> getEngineFactories() {
        return factories;
    }

}

@@ -900,22 +900,169 @@
 va.util.
-List;%0A
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport javax.script.Bindings;%0Aimport javax.script.ScriptContext;%0Aimport javax.script.ScriptEngine;
 %0Aimport 
@@ -1210,16 +1210,30 @@
  %7B%0A%0A    
+private final 
 List%3CScr
@@ -1300,16 +1300,20 @@
 ory%3E();%0A
+    
 %0A    pub
@@ -1397,24 +1397,475 @@
 ader);%0A    %7D
+%0A    %0A    public SlingScriptEngineManager() %7B%0A        super();%0A    %7D%0A%0A    @Override%0A    public List%3CScriptEngineFactory%3E getEngineFactories() %7B%0A        @SuppressWarnings(%22unchecked%22)%0A        List%3CScriptEngineFactory%3E baseFactories = super.getEngineFactories();%0A        %0A        List%3CScriptEngineFactory%3E result = new ArrayList%3CScriptEngineFactory%3E();%0A        result.addAll(factories);%0A        result.addAll(baseFactories);%0A        return result;%0A    %7D
 %0A%0A    public
@@ -2336,113 +2336,6 @@
  %7D%0A%0A
-    @Override%0A    public List%3CScriptEngineFactory%3E getEngineFactories() %7B%0A        return factories;%0A    %7D%0A%0A
 %7D%0A

Return all ScriptEngineFactorys from the SlingScriptEngineManager