| 
					
				 | 
			
			
				@@ -2,22 +2,15 @@ package com.ym.mec.task.core; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import javax.sql.DataSource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.quartz.Scheduler; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.InitializingBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.context.annotation.Bean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.context.annotation.Configuration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.context.annotation.Primary; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.core.io.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.task.dal.model.Task; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.task.service.TaskService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.scheduling.quartz.SchedulerFactoryBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Configuration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class TaskSchedulerBootstrap implements InitializingBean { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -28,47 +21,13 @@ public class TaskSchedulerBootstrap implements InitializingBean { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private TaskService taskService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private DataSource dataSource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private LocalJobFactory jobFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private SchedulerFactoryBean schedulerFactoryBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	@Value("${task.configLocation}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	private Resource configLocation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	@Value("${task.autoStartup}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	private boolean autoStartup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	@Value("${task.startupDelay}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//	private int startupDelay; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Bean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Primary 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public Scheduler getScheduler() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return schedulerFactoryBean.getScheduler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		LocalSchedulerFactoryBean factoryBean = new LocalSchedulerFactoryBean(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setDataSource(dataSource); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setOverwriteExistingJobs(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setConfigLocation(configLocation); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setJobFactory(jobFactory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setWaitForJobsToCompleteOnShutdown(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setStartupDelay(startupDelay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.setAutoStartup(autoStartup); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		factoryBean.afterPropertiesSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//		return factoryBean.getObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private LocalSchedulerFactoryBean localSchedulerFactoryBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@SuppressWarnings("unchecked") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void afterPropertiesSet() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Scheduler scheduler = getScheduler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Scheduler scheduler = localSchedulerFactoryBean.getScheduler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (scheduler == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new IllegalArgumentException("[TaskSchedulerBootstrap]在实例化过程中,参数[scheduler]没有被设置,请检查配置"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -82,11 +41,12 @@ public class TaskSchedulerBootstrap implements InitializingBean { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			if (BaseTask.class.isAssignableFrom(clazz)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				QuartzHelper.addJob(scheduler, task.getName(), task.getGroup(), task.getName(), task.getGroup(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						(Class<? extends BaseTask>) Class.forName(task.getJobClass()), task.getTimeExp()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				LOGGER.info("Successed add jobs[{}.{}] to Schedule", task.getGroup(), task.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				LOGGER.info("Successed add job[{}.{}] to Schedule", task.getGroup(), task.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				LOGGER.warn("Failed add jobs[{}.{}],because class[{}] not implements com.yqh.p2p.task.BaseTask", task.getGroup(), task.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				LOGGER.warn("Failed add job[{}.{}],because class[{}] not implements com.yqh.p2p.task.BaseTask", task.getGroup(), task.getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						task.getJobClass()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |