diff --git a/dinky-admin/src/main/java/org/dinky/service/task/BaseTask.java b/dinky-admin/src/main/java/org/dinky/service/task/BaseTask.java index bb41ea9db1..f13659fd3f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/task/BaseTask.java +++ b/dinky-admin/src/main/java/org/dinky/service/task/BaseTask.java @@ -39,6 +39,10 @@ @AllArgsConstructor public abstract class BaseTask { + + private static final Set> taskRegistry = + ClassUtil.scanPackageBySuper(BaseTask.class.getPackage().getName(), BaseTask.class); + final TaskDTO task; public abstract JobResult execute() throws Exception; @@ -58,9 +62,7 @@ public ObjectNode getJobPlan() throws NotSupportExplainExcepition { } public static BaseTask getTask(TaskDTO taskDTO) { - Set> classes = - ClassUtil.scanPackageBySuper(BaseTask.class.getPackage().getName(), BaseTask.class); - for (Class clazz : classes) { + for (Class clazz : taskRegistry) { SupportDialect annotation = clazz.getAnnotation(SupportDialect.class); if (annotation != null) { for (Dialect dialect : annotation.value()) {