From 3041902c33271494603a96f5efdde5681159391b Mon Sep 17 00:00:00 2001 From: "Alice.Liu" <1360737271@qq.com> Date: Tue, 17 Aug 2021 13:16:51 +0800 Subject: [PATCH] add spring el support --- .../core/executor/impl/XxlJobSpringExecutor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java index 0e689f41..f32f1b6c 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java @@ -26,6 +26,15 @@ import java.util.Map; public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationContextAware, SmartInitializingSingleton, DisposableBean { private static final Logger logger = LoggerFactory.getLogger(XxlJobSpringExecutor.class); + /** + * Prefix for system property placeholders: "${". + */ + public static final String PLACEHOLDER_PREFIX = "${"; + + /** + * Suffix for system property placeholders: "}". + */ + public static final String PLACEHOLDER_SUFFIX = "}"; // start @Override @@ -113,6 +122,10 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC if (name.trim().length() == 0) { throw new RuntimeException("xxl-job method-jobhandler name invalid, for[" + bean.getClass() + "#" + executeMethod.getName() + "] ."); } + // support spring environment + if (name.startsWith(PLACEHOLDER_PREFIX) && name.endsWith(PLACEHOLDER_SUFFIX)){ + name = applicationContext.getEnvironment().getProperty(name.replace(PLACEHOLDER_PREFIX,"").replace(PLACEHOLDER_SUFFIX,"")); + } if (loadJobHandler(name) != null) { throw new RuntimeException("xxl-job jobhandler[" + name + "] naming conflicts."); }