|
|
@ -1,23 +1,23 @@
|
|
|
|
package ${basePackage}.config;
|
|
|
|
package ${basePackage}.config;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
|
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
|
|
|
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
|
|
|
import org.springframework.beans.factory.support.BeanNameGenerator;
|
|
|
|
import org.springframework.beans.factory.support.BeanNameGenerator;
|
|
|
|
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
|
|
|
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Profile;
|
|
|
|
import org.springframework.context.annotation.Profile;
|
|
|
|
import org.springframework.core.type.filter.AssignableTypeFilter;
|
|
|
|
import org.springframework.core.type.filter.AssignableTypeFilter;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import ${basePackage}.frame.schedule.RunTask;
|
|
|
|
import ${basePackage}.frame.schedule.RunTask;
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
import ${basePackage}.frame.utils.LogUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 计划调度配置,可以指定环境生效,根据实际情况是否需要开启
|
|
|
|
* 计划调度配置,可以指定环境生效,根据实际情况是否需要开启
|
|
|
@ -40,7 +40,7 @@ public class ScheduleConfig extends ThreadPoolTaskScheduler implements BeanDefin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean createOrRepeat(RunTask task) {
|
|
|
|
public boolean createOrRepeat(RunTask task) {
|
|
|
|
if (futureMap.containsKey(task.taskId())){
|
|
|
|
if (futureMap.containsKey(task.taskId())) {
|
|
|
|
ScheduledFuture<?> scheduledFuture = futureMap.get(task.taskId());
|
|
|
|
ScheduledFuture<?> scheduledFuture = futureMap.get(task.taskId());
|
|
|
|
scheduledFuture.cancel(false);
|
|
|
|
scheduledFuture.cancel(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -51,7 +51,13 @@ public class ScheduleConfig extends ThreadPoolTaskScheduler implements BeanDefin
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
|
|
|
|
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
|
|
|
|
registryTask("${basePackage}.task", beanDefinitionRegistry);
|
|
|
|
String aPackage = this.getClass().getPackage().getName();
|
|
|
|
|
|
|
|
Pattern compile = Pattern.compile("(.*)\\.config");
|
|
|
|
|
|
|
|
Matcher matcher = compile.matcher(aPackage);
|
|
|
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
|
|
|
String basePackage = matcher.group(1);
|
|
|
|
|
|
|
|
registryTask(basePackage + ".task", beanDefinitionRegistry);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|