本文整理匯總了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet方法的典型用法代碼示例。如果您正苦於以下問題:Java SchedulerFactoryBean.afterPropertiesSet方法的具體用法?Java SchedulerFactoryBean.afterPropertiesSet怎麽用?Java SchedulerFactoryBean.afterPropertiesSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.scheduling.quartz.SchedulerFactoryBean
的用法示例。
在下文中一共展示了SchedulerFactoryBean.afterPropertiesSet方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: before
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Before
public void before() throws Exception
{
// Create fresh scheduler
SchedulerFactoryBean sfb = new SchedulerFactoryBean();
sfb.setSchedulerFactoryClass(AlfrescoSchedulerFactory.class);
sfb.setAutoStartup(false);
sfb.afterPropertiesSet();
scheduler = sfb.getScheduler();
}
示例2: createSchedulerFactoryBean
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
/**
* 創建調度服務
* 每一個批次啟動後,創建一個調度服務
*/
public SchedulerFactoryBean createSchedulerFactoryBean(BatchRunConfDto conf, ResourceManagement drm) throws Exception {
this.conf = conf;
this.jobKeyStatusService = drm.getJobKeyStatusService();
this.argumentService = drm.getArgumentService();
getAllTaskForMap();
initGroupTaskMap(drm.getJobKeyList());
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
// 配置DataSource後,將會出現異常
// JobLauncher實例化對象無法序列化
// schedulerFactoryBean.setDataSource(dataSource);
schedulerFactoryBean.setSchedulerName(conf.getBatchId());
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(true);
schedulerFactoryBean.setAutoStartup(false);
// 獲取指定批次的所有任務Job
ArrayList<SimpleTrigger> arrayList = new ArrayList<SimpleTrigger>();
for (String jobId : jobKeyStatusService.getAllJob().keySet()) {
SimpleTrigger simpleTrigger = createSimpleTrigger(jobId);
schedulerFactoryBean.setTriggers(simpleTrigger);
arrayList.add(simpleTrigger);
}
SimpleTrigger[] simpleTriggers = new SimpleTrigger[arrayList.size()];
for (int i = 0; i < arrayList.size(); i++) {
simpleTriggers[i] = arrayList.get(i);
}
schedulerFactoryBean.setTriggers(simpleTriggers);
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.getScheduler().pauseAll();
schedulerFactoryBean.start();
return schedulerFactoryBean;
}
示例3: init
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
/**
* Creates the Spring {@code SchedulerFactoryBean}.
*/
@PostConstruct
public void init() {
schedulerFactoryBean = new SchedulerFactoryBean();
schedulerFactoryBean.setQuartzProperties(schedulerProperties);
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(getBooleanWithDefault(schedulerProperties.getProperty("scheduler.waitForJobsToCompleteOnShutdown"), true));
schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
schedulerFactoryBean.setApplicationContext(applicationContext);
try {
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.getScheduler().start();
} catch (Exception e) {
throw new SchedulerInstantiationException("Failed to instantiate scheduler with configuration from quartz.properties", e);
}
}
示例4: quartzScheduler
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public Scheduler quartzScheduler(ApplicationContext context) throws Exception {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setApplicationContext(context);
factory.setExposeSchedulerInRepository(true);
factory.setApplicationContextSchedulerContextKey(APPLICATION_CONTEXT_KEY);
factory.setJobFactory(glassJobFactory);
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
properties.setProperty("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
properties.setProperty("org.quartz.threadPool.threadCount", "15");
properties.setProperty("org.quartz.threadPool.threadPriority", "4");
if (configuration().isInMemory()) {
properties.setProperty("org.quartz.jobStore.class", RAMJobStore.class.getName());
} else {
factory.setDataSource(dataSource());
properties.setProperty("org.quartz.jobStore.tablePrefix", configuration().getTablePrefix());
properties.setProperty("org.quartz.jobStore.isClustered", "false");
properties.setProperty("org.quartz.jobStore.driverDelegateClass", configuration().getDriverDelegateClass());
}
factory.setQuartzProperties(properties);
factory.afterPropertiesSet();
Scheduler scheduler = factory.getObject();
scheduler.getListenerManager().addJobListener(glassJobListener);
scheduler.getListenerManager().addSchedulerListener(glassSchedulerListener);
scheduler.start();
return scheduler;
}
示例5: scheduler
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
@Bean
public Scheduler scheduler() throws Exception {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setTriggers(new Trigger[] { jobDetailTrigger() });
factory.setJobFactory(new SpringBeanJobFactory());
factory.setDataSource(dataSource());
factory.setSchedulerContextAsMap(new HashMap<String, Object>() {{
put("job", job());
put("jobLauncher", jobLauncher);
}});
factory.afterPropertiesSet();
return factory.getObject();
}
示例6: start
import org.springframework.scheduling.quartz.SchedulerFactoryBean; //導入方法依賴的package包/類
public void start() throws Exception {
LOG.info("start crontab");
if (application.getCrontab() != null && application.getCrontab().getCrons() != null) {
Trigger[] triggers = new Trigger[application.getCrontab().getCrons().size()];
for (int i = 0; i < triggers.length; i ++) {
Cron cron = application.getCrontab().getCrons().get(i);
String desc = cron.getDescription();
String exp = cron.getSchedule();
String script = cron.getScript();
MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
jobDetailFactory.setBeanName("jobDetail" + script);
jobDetailFactory.setName("jobDetail" + script);
jobDetailFactory.setTargetObject(this);
jobDetailFactory.setTargetMethod("execute");
jobDetailFactory.setArguments(new Object[]{script, exp, desc});
jobDetailFactory.setConcurrent(application.getCrontab().isConcurrent());
jobDetailFactory.afterPropertiesSet();
JobDetail jobDetail = jobDetailFactory.getObject();
CronTriggerBean trigger = new CronTriggerBean();
trigger.setBeanName("trigger" + script);
trigger.setName("trigger" + script);
trigger.setJobDetail(jobDetail);
trigger.setCronExpression(exp);
trigger.afterPropertiesSet();
triggers[i] = trigger;
}
Properties properties = new Properties();
properties.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
schedulerFactory = new SchedulerFactoryBean();
schedulerFactory.setBeanName("schedulerFactory");
schedulerFactory.setTriggers(triggers);
schedulerFactory.setQuartzProperties(properties);
//schedulerFactory.setAutoStartup(true);
schedulerFactory.afterPropertiesSet();
schedulerFactory.start();
}
}