Skip to content

Commit

Permalink
跟spring boot集成时不支持动态编译
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed Oct 21, 2022
1 parent 714f475 commit 2a86398
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lealone-db/src/main/java/org/lealone/db/service/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ public void setExecutor(ServiceExecutor executor) {

// 延迟创建executor的实例,因为执行create service语句时,依赖的服务实现类还不存在
public ServiceExecutor getExecutor() {
return getExecutor(false);
}

public ServiceExecutor getExecutor(boolean disableDynamicCompile) {
if (executor == null) {
synchronized (this) {
if (executor == null) {
// 跟spring boot集成时不支持动态编译
if (disableDynamicCompile) {
executor = new JavaServiceExecutor(this);
return executor;
}
if (executorCode != null) {
String code = executorCode.toString();
executorCode = null;
Expand Down Expand Up @@ -132,6 +141,11 @@ public static Value execute(ServerSession session, String serviceName, String me

// 通过http调用
public static String execute(String serviceName, String methodName, Map<String, Object> methodArgs) {
return execute(serviceName, methodName, methodArgs, false);
}

public static String execute(String serviceName, String methodName, Map<String, Object> methodArgs,
boolean disableDynamicCompile) {
String[] a = StringUtils.arraySplit(serviceName, '.');
if (a.length == 3) {
Database db = LealoneDatabase.getInstance().getDatabase(a[0]);
Expand All @@ -140,7 +154,7 @@ public static String execute(String serviceName, String methodName, Map<String,
methodName = methodName.toUpperCase();
}
Service service = getService(null, db, a[1], a[2]);
return service.getExecutor().executeService(methodName, methodArgs);
return service.getExecutor(disableDynamicCompile).executeService(methodName, methodArgs);
} else {
throw new RuntimeException("service " + serviceName + " not found");
}
Expand Down

0 comments on commit 2a86398

Please sign in to comment.