fix: window restart error
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
7f32062dca
commit
824c440f63
3
pom.xml
3
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>MiaoScript</artifactId>
|
||||
<version>0.9.6</version>
|
||||
<version>0.9.7</version>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>502647092</id>
|
||||
@ -54,6 +54,7 @@
|
||||
<properties>
|
||||
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
|
||||
<update.changes>
|
||||
§620-12-07 §afix: 修复 Windows 环境 重载异常;
|
||||
§620-11-19 §afeat: 新增 JavaScriptTask 类;
|
||||
§620-11-11 §afeat: 新增 package 版本锁定逻辑;
|
||||
§620-09-21 §afeat: 完善 upgrade 逻辑;
|
||||
|
@ -13,12 +13,14 @@ import java.nio.file.Paths;
|
||||
* @author 喵♂呜 Created on 2017/10/25 21:01.
|
||||
*/
|
||||
public class ScriptEngine {
|
||||
private final String root;
|
||||
private final ClassLoader loader;
|
||||
private final Object logger;
|
||||
private final String root;
|
||||
private final Base base;
|
||||
private MiaoScriptEngine engine;
|
||||
|
||||
public ScriptEngine(String root, Object logger, Object instance) {
|
||||
this.loader = Thread.currentThread().getContextClassLoader();
|
||||
this.root = root;
|
||||
this.logger = logger;
|
||||
this.base = new Base(instance);
|
||||
@ -38,6 +40,8 @@ public class ScriptEngine {
|
||||
@SneakyThrows
|
||||
public void enableEngine() {
|
||||
createEngine();
|
||||
ClassLoader originLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(this.loader);
|
||||
Path bios = Paths.get(root, "bios.js");
|
||||
// 如果存在自定义bios就加载自定义的
|
||||
if (Files.exists(bios)) {
|
||||
@ -46,6 +50,7 @@ public class ScriptEngine {
|
||||
this.engine.eval("load('classpath:bios.js')");
|
||||
}
|
||||
engine.invokeFunction("boot", root, logger);
|
||||
Thread.currentThread().setContextClassLoader(originLoader);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
Loading…
Reference in New Issue
Block a user