fix: engineDisable override

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-09-22 16:48:44 +08:00
parent 7e36b6109d
commit 40760713ff
2 changed files with 2 additions and 4 deletions

View File

@ -17,18 +17,16 @@ public class ScriptEngine {
private Object logger; private Object logger;
private Base base; private Base base;
private MiaoScriptEngine engine; private MiaoScriptEngine engine;
private ScriptEngineManager manager;
public ScriptEngine(String root, Object logger, Object instance) { public ScriptEngine(String root, Object logger, Object instance) {
this.root = root; this.root = root;
this.logger = logger; this.logger = logger;
this.base = new Base(instance); this.base = new Base(instance);
this.manager = new ScriptEngineManager();
} }
public synchronized MiaoScriptEngine createEngine() { public synchronized MiaoScriptEngine createEngine() {
if (this.engine == null) { if (this.engine == null) {
this.engine = new MiaoScriptEngine(manager, "nashorn"); this.engine = new MiaoScriptEngine(new ScriptEngineManager(), "nashorn");
this.engine.put("base", this.base); this.engine.put("base", this.base);
this.engine.put("ScriptEngineContextHolder", this); this.engine.put("ScriptEngineContextHolder", this);
} }

View File

@ -9,7 +9,7 @@
global.logger = logger; global.logger = logger;
global.ScriptEngineStartTime = new Date().getTime() global.ScriptEngineStartTime = new Date().getTime()
global.engineLoad = load; global.engineLoad = load;
global.noop = global.engineDisable = engineDisable = function () { }; global.noop = function () { };
global.load = load = function __PreventGlobalLoadFunction__() { throw new Error('Internal engine system not allow use `load` function!'); } global.load = load = function __PreventGlobalLoadFunction__() { throw new Error('Internal engine system not allow use `load` function!'); }
global.setGlobal = function (key, value, config) { global.setGlobal = function (key, value, config) {
if (config) { if (config) {