org.zodiac.script.engine.DynamicScriptEngineFactory Maven / Gradle / Ivy
package org.zodiac.script.engine;
import java.util.Map;
import org.zodiac.commons.util.Colls;
import org.zodiac.script.engine.groovy.GroovyEngine;
import org.zodiac.script.engine.java.JavaEngine;
import org.zodiac.script.engine.js.JavaScriptEngine;
import org.zodiac.script.engine.ognl.OgnlEngine;
import org.zodiac.script.engine.python.PythonScriptEngine;
import org.zodiac.script.engine.ruby.RubyScriptEngine;
import org.zodiac.script.engine.spel.SpelEngine;
public final class DynamicScriptEngineFactory {
private static final Map map = Colls.map();
static {
JavaScriptEngine engine = new JavaScriptEngine();
map.put("js", engine);
map.put("javascript", engine);
map.put("groovy", new GroovyEngine());
map.put("ruby", new RubyScriptEngine());
map.put("python", new PythonScriptEngine());
try {
map.put("java", new JavaEngine());
} catch (Exception e) {
}
try {
Class.forName("org.springframework.expression.ExpressionParser");
map.put("spel", new SpelEngine());
} catch (ClassNotFoundException e) {
}
try {
Class.forName("ognl.Ognl");
map.put("ognl", new OgnlEngine());
} catch (ClassNotFoundException e) {
}
}
public static final DynamicScriptEngine getEngine(String type) {
return map.get(type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy