com.pamirs.pradar.script.ScriptManager Maven / Gradle / Ivy
package com.pamirs.pradar.script;
import com.pamirs.pradar.script.bsh.BshScriptEvaluator;
import java.util.HashMap;
import java.util.Map;
/**
* @author xiaobin.zfb|[email protected]
* @since 2021/6/18 2:57 下午
*/
public class ScriptManager {
private Map evaluators;
public ScriptManager() {
this.evaluators = new HashMap();
BshScriptEvaluator bshScriptEvaluator = new BshScriptEvaluator();
bshScriptEvaluator.setClassLoader(ScriptManager.class.getClassLoader());
evaluators.put(bshScriptEvaluator.getType(), bshScriptEvaluator);
}
private static ScriptManager INSTANCE;
public static ScriptManager getInstance() {
if (INSTANCE == null) {
synchronized (ScriptManager.class) {
if (INSTANCE == null) {
INSTANCE = new ScriptManager();
}
}
}
return INSTANCE;
}
public ScriptEvaluator getScriptEvaluator(String type) {
return evaluators.get(type);
}
}