All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pamirs.pradar.script.ScriptManager Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy