Pre Merge pull request !31 from 卖小姑娘的火柴/spring-el-spport

pull/31/MERGE
卖小姑娘的火柴 4 years ago committed by Gitee
commit 1756a1cec3

@ -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.");
}

Loading…
Cancel
Save