本文整理汇总了Java中org.springframework.scheduling.quartz.CronTriggerFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java CronTriggerFactoryBean类的具体用法?Java CronTriggerFactoryBean怎么用?Java CronTriggerFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CronTriggerFactoryBean类属于org.springframework.scheduling.quartz包,在下文中一共展示了CronTriggerFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTransferJob
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
public void initTransferJob(TransferJob transferJob) throws ClassNotFoundException, NoSuchMethodException, ParseException, SchedulerException {
MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
jobDetailFactory.setTargetObject(this);
jobDetailFactory.setTargetMethod("runReceiveJob");
jobDetailFactory.setConcurrent(false);
jobDetailFactory.setArguments(new Object[]{transferJob});
jobDetailFactory.setName(transferJob.getId() + "_job");
jobDetailFactory.afterPropertiesSet();
JobDetail jobDetail = jobDetailFactory.getObject();
CronTriggerFactoryBean triggerFactory = new CronTriggerFactoryBean();
triggerFactory.setCronExpression(transferJob.getCronExpression());
triggerFactory.setName(transferJob.getName() + "_trigger");
triggerFactory.setJobDetail(jobDetail);
triggerFactory.afterPropertiesSet();
scheduler.scheduleJob(jobDetail,triggerFactory.getObject());
LOGGER.debug("Transfer job: {}({}) initialized", transferJob.getName(),transferJob.getId());
}
示例2: afterPropertiesSet
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Override
public void afterPropertiesSet () throws Exception
{
Map<String, AbstractJob> webappBeanNames =
applicationContext.getBeansOfType (AbstractJob.class);
triggers = new HashMap<> ();
for (String webappBeanName : webappBeanNames.keySet ())
{
AbstractJob cron = webappBeanNames.get (webappBeanName);
CronTriggerFactoryBean trigger = new CronTriggerFactoryBean ();
JobDetail job = JobBuilder.newJob (cron.getClass ()).
storeDurably (true).build ();
trigger.setJobDetail (job);
trigger.setCronExpression (cron.getCronExpression ());
trigger.setName (webappBeanName + "Trigger");
trigger.afterPropertiesSet ();
triggers.put (cron.getClass(), trigger.getObject ());
}
super.setTriggers (triggers.values ().toArray (
new Trigger[triggers.size ()]));
super.setJobFactory (autowiringJobFactory);
super.afterPropertiesSet ();
}
示例3: registerSchedulerTriggerBean
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
/**
*
* @param acf
* @param sch
* @return
*/
private Trigger registerSchedulerTriggerBean(DefaultListableBeanFactory acf, AbstractJob sch) {
//注册JobDetail
String jobDetailBeanName = sch.getJobName() + "JobDetail";
if (context.containsBean(jobDetailBeanName)) {
throw new RuntimeException("duplicate jobName[" + sch.getJobName() + "] defined!!");
}
BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder
.genericBeanDefinition(MethodInvokingJobDetailFactoryBean.class);
beanDefBuilder.addPropertyValue("targetObject", sch);
beanDefBuilder.addPropertyValue("targetMethod", "execute");
beanDefBuilder.addPropertyValue("concurrent", false);
acf.registerBeanDefinition(jobDetailBeanName, beanDefBuilder.getRawBeanDefinition());
//注册Trigger
String triggerBeanName = sch.getJobName() + "Trigger";
beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(CronTriggerFactoryBean.class);
beanDefBuilder.addPropertyReference("jobDetail", jobDetailBeanName);
beanDefBuilder.addPropertyValue("cronExpression", sch.getCronExpr());
beanDefBuilder.addPropertyValue("group", groupName);
acf.registerBeanDefinition(triggerBeanName, beanDefBuilder.getRawBeanDefinition());
logger.info("register scheduler task [{}] ok!!", sch.getJobName());
return (Trigger) context.getBean(triggerBeanName);
}
示例4: build
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
public SchedulerFactoryBean build() throws Exception {
SchedulerFactoryBean bean = new SchedulerFactoryBean();
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource(config));
propertiesFactoryBean.afterPropertiesSet();
Properties props = propertiesFactoryBean.getObject();
List<Trigger> triggers = Lists.newArrayList();
List<JobModel> jobList = getJobs(props);
for (JobModel job : jobList) {
if (!job.isEnable()) {
continue;
}
JobDetailFactoryBean detail = createJobDetail(job.getName(), Class.forName(job.getJob()));
CronTriggerFactoryBean trigger = createCronTrigger(job.getName(), detail.getObject(), job.getCorn());
CronTrigger t = trigger.getObject();
triggers.add(t);
}
bean.setTriggers(triggers.toArray(new Trigger[0]));
//bean.afterPropertiesSet();
return bean;
}
示例5: registerSchedulerTriggerBean
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
/**
*
* @param acf
* @param sch
* @return
*/
private Trigger registerSchedulerTriggerBean(DefaultListableBeanFactory acf,AbstractJob sch) {
//注册JobDetail
String jobDetailBeanName = sch.getJobName() + "JobDetail";
if(context.containsBean(jobDetailBeanName)){
throw new RuntimeException("duplicate jobName["+sch.getJobName()+"] defined!!");
}
BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingJobDetailFactoryBean.class);
beanDefBuilder.addPropertyValue("targetObject", sch);
beanDefBuilder.addPropertyValue("targetMethod", "execute");
beanDefBuilder.addPropertyValue("concurrent", false);
acf.registerBeanDefinition(jobDetailBeanName, beanDefBuilder.getRawBeanDefinition());
//注册Trigger
String triggerBeanName = sch.getJobName() + "Trigger";
beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(CronTriggerFactoryBean.class);
beanDefBuilder.addPropertyReference("jobDetail", jobDetailBeanName);
beanDefBuilder.addPropertyValue("cronExpression", sch.getCronExpr());
beanDefBuilder.addPropertyValue("group", groupName);
acf.registerBeanDefinition(triggerBeanName, beanDefBuilder.getRawBeanDefinition());
return (Trigger) context.getBean(triggerBeanName);
}
示例6: cronJobTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
/**
* attention:
* Details:配置定时任务的触发器,也就是什么时候触发执行定时任务
*/
@Bean(name = "jobTrigger")
public CronTriggerFactoryBean cronJobTrigger(MethodInvokingJobDetailFactoryBean jobDetail) {
CronTriggerFactoryBean tigger = new CronTriggerFactoryBean();
tigger.setJobDetail(jobDetail.getObject());
/*tigger.setCronExpression("0 30 20 * * ?");// 初始时的cron表达式 */
tigger.setCronExpression("59 39 17 * * ?"); //初始的时候cron表达式,每天的下午17:40:00准时调度
tigger.setName("srd-chhliu");// trigger的name
return tigger;
}
示例7: cronTriggerFactoryBean
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean(name = "cleanUpCronTriggerFactoryBean")
public CronTriggerFactoryBean cronTriggerFactoryBean() {
com.sap.cloud.lm.sl.cf.core.util.Configuration configuration = com.sap.cloud.lm.sl.cf.core.util.Configuration.getInstance();
CronTriggerFactoryBean factory = new CronTriggerFactoryBean();
factory.setJobDetail(jobDetailFactoryBean().getObject());
factory.setCronExpression(configuration.getCronExpressionForOldData());
factory.setGroup(TRIGGER_GROUP);
factory.setName(CLEAN_UP_TRIGGER_NAME);
return factory;
}
示例8: createSimpleCronTrigger2
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean(name="cronTrigger2")
public CronTriggerFactoryBean createSimpleCronTrigger2(@Qualifier("cronJobDetail") JobDetail jobDetail) {
Map<String, Object> map = new HashMap<>(1);
map.put("myKey", "myValue");
return QuartzUtils.createCronTrigger(jobDetail, "CTName2", "Cron", "CTDesc2", "0 0 0/1 1/1 * ? *",
CronTrigger.MISFIRE_INSTRUCTION_SMART_POLICY, map, 10000L, new Date(), "Europe/Berlin", 1234);
}
示例9: createCronTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
private CronTriggerFactoryBean createCronTrigger(String name, JobDetail jobDetail, String corn)
throws ParseException {
CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
factoryBean.setName(name);
factoryBean.setJobDetail(jobDetail);
factoryBean.setCronExpression(corn);
factoryBean.afterPropertiesSet();
return factoryBean;
}
示例10: gravatarTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean
public CronTriggerFactoryBean gravatarTrigger() {
CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
cronTriggerFactoryBean.setJobDetail(gravatarJob().getObject());
cronTriggerFactoryBean.setCronExpression("0 30 * * * ?"); // Every hour
cronTriggerFactoryBean.setGroup("lemonaid-quartz");
return cronTriggerFactoryBean;
}
示例11: locationTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean
public CronTriggerFactoryBean locationTrigger() {
CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
cronTriggerFactoryBean.setJobDetail(locationJob().getObject());
cronTriggerFactoryBean.setCronExpression("0 15 0 * * ?"); // Every day
cronTriggerFactoryBean.setGroup("lemonaid-quartz");
return cronTriggerFactoryBean;
}
示例12: insideTrackTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean
public CronTriggerFactoryBean insideTrackTrigger() {
CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
cronTriggerFactoryBean.setJobDetail(insideTrackJob().getObject());
cronTriggerFactoryBean.setCronExpression("0 0 * * * ?"); // Every hour
cronTriggerFactoryBean.setGroup("lemonaid-quartz");
return cronTriggerFactoryBean;
}
示例13: QuartzCronTriggerBuilder
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
public QuartzCronTriggerBuilder() {
triggerFactoryBean = new CronTriggerFactoryBean();
}
示例14: createSimpleCronTrigger
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
@Bean(name="cronTrigger")
public CronTriggerFactoryBean createSimpleCronTrigger(@Qualifier("cronJobDetail") JobDetail jobDetail) {
return QuartzUtils.createCronTrigger(jobDetail, null, "Cron", null, "0 0 0/1 1/1 * ? *", 5000L, null);
}
示例15: getTriggerFactoryBean
import org.springframework.scheduling.quartz.CronTriggerFactoryBean; //导入依赖的package包/类
/**
*
* @return
*/
public CronTriggerFactoryBean getTriggerFactoryBean() {
return triggerFactoryBean;
}