当前位置: 首页>>代码示例>>Java>>正文


Java TriggerBuilder.withIdentity方法代码示例

本文整理汇总了Java中org.quartz.TriggerBuilder.withIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerBuilder.withIdentity方法的具体用法?Java TriggerBuilder.withIdentity怎么用?Java TriggerBuilder.withIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.TriggerBuilder的用法示例。


在下文中一共展示了TriggerBuilder.withIdentity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMember

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Override
public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception {

    String id = UUID.randomUUID().toString();

    TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
    triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule((String) state.getProperty("cron")));
    triggerBuilder.withIdentity(id);
    Trigger trigger = triggerBuilder.build();

    TriggerResource resource = new TriggerResource(this, trigger);

    JobDataMap dataMap = new JobDataMap();
    dataMap.put("resource", resource);

    JobBuilder jobBuilder = JobBuilder.newJob();
    jobBuilder.withIdentity(id);
    jobBuilder.ofType(LiveOakJob.class);
    jobBuilder.setJobData(dataMap);

    JobDetail jobDetail = jobBuilder.build();

    this.scheduler.scheduleJob(jobDetail, trigger);
    this.children.put(id, resource);
    responder.resourceCreated(resource);
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:27,代码来源:SchedulerResource.java

示例2: addScript

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private void addScript(ScheduledScript script) throws Exception {
    TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
    triggerBuilder.withIdentity(script.getId());

    if (script.getCron() != null) {
        triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(script.getCron()));
    }

    if (script.getAt() != null) {
        triggerBuilder.startAt(script.getAt());
    }

    if (script.getUntil() != null) {
        triggerBuilder.endAt(script.getUntil());
    }

    Trigger trigger = triggerBuilder.build();

    JobDataMap dataMap = new JobDataMap();
    dataMap.put(SCRIPT_DATAMAP_KEY, script);
    dataMap.put(SCRIPT_MANAGER_DATAMAP_KEY, scriptManager);

    JobBuilder jobBuilder = JobBuilder.newJob();
    jobBuilder.withIdentity(script.getId());
    jobBuilder.ofType(ScriptJob.class);
    jobBuilder.setJobData(dataMap);

    scheduler.scheduleJob(jobBuilder.build(), trigger);
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:30,代码来源:ScheduleManager.java

示例3: addTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public JSONResult addTrigger(String schedulerName, String jobName, String jobGroup,
                             String triggerName, String triggerGroup, String cronExpression, String description,
                             String priority, Date startDate, Date endDate, Map<String, Object> dataMap) {

    try {
        Assert.notEmpty(schedulerName, "schedulerName can not be empty");
        Assert.notEmpty(jobName, "jobName can not be empty");
        Assert.notEmpty(jobGroup, "jobGroup can not be empty");
        Assert.notEmpty(triggerName, "triggerName can not be empty");
        Assert.notEmpty(triggerGroup, "triggerGroup can not be empty");
        Assert.isCronExpression(cronExpression, "cronExpression is error");
        TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
        triggerTriggerBuilder = triggerTriggerBuilder.withIdentity(triggerName, triggerGroup);
        if (!StringUtils.isEmpty(description)) {
            triggerTriggerBuilder = triggerTriggerBuilder.withDescription(description);
        }
        if (!StringUtils.isEmpty(priority) && StringUtils.isInteger(priority)) {
            Assert.isInteger(priority, "priority must be int");
            triggerTriggerBuilder.withPriority(Integer.parseInt(priority));
        }
        if (startDate != null) {
            triggerTriggerBuilder.startAt(startDate);
        }
        if (endDate != null) {
            triggerTriggerBuilder.endAt(endDate);
        }
        //jobDataMap
        if (dataMap != null && dataMap.size() > 0) {
            JobDataMap jobDataMap = new JobDataMap();
            for (Map.Entry<String, Object> dataKey : dataMap.entrySet()) {
                if (!StringUtils.isEmpty(dataKey.getKey())) {
                    jobDataMap.put(dataKey.getKey(), dataKey.getValue());
                }
            }
            triggerTriggerBuilder.usingJobData(jobDataMap);
        }
        triggerTriggerBuilder.forJob(jobName, jobGroup);
        CronTrigger trigger = triggerTriggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
                .build();
        //JobDetail jobDetail = QuartzWebManager.getJob(schedulerName, jobName, jobGroup);
        // 存在更新不存在,添加
        if (!QuartzWebManager.checkTriggerExists(schedulerName, triggerName, triggerGroup)) {
            QuartzWebManager.addTriggerForJob(schedulerName, trigger);
        } else {
            QuartzWebManager.updateTriggerForJob(schedulerName, trigger);
        }

        return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok");
    } catch (Exception e) {
        e.printStackTrace();
        return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage());
    }
}
 
开发者ID:quartzweb,项目名称:quartz-web,代码行数:54,代码来源:TriggerServiceStrategy.java

示例4: configureTriggerJob

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private Trigger configureTriggerJob(String jobName, String jobGroup, Job job) {
 TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
 		 
 // base trigger configuration 
 triggerBuilder.withIdentity(jobName, jobGroup);
 
 if (job.getStartTime() != null)
	 triggerBuilder.startAt(job.getStartTime());
 else {
	 if (job.getActive())
		 triggerBuilder.startNow();
 }

 if (job.getEndTime() != null)
	 triggerBuilder.endAt(job.getEndTime());		 
	 
 triggerBuilder.withPriority(job.getJobTriggerPriority());
 
 // propietary trigger configuration
 if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) {
	 SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
	 
	 if (job.getJobInterval() != null) {
		 if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.SECOND.name()))
			 simpleScheduleBuilder.withIntervalInSeconds(job.getJobInterval());
		 else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.MINUTE.name()))
			 simpleScheduleBuilder.withIntervalInMinutes(job.getJobInterval());
		 else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.HOUR.name()))
			 simpleScheduleBuilder.withIntervalInHours(job.getJobInterval());
		 else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.DAY.name()))
			 simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24);
		 else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.WEEK.name()))
			 simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24 * 7);
	 }
	
	 if (job.getRepeatCount() != null)
		 simpleScheduleBuilder.withRepeatCount(job.getRepeatCount());
	 else
		 simpleScheduleBuilder.repeatForever();
	 
     triggerBuilder.withSchedule(simpleScheduleBuilder);
		 
 }
 else if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.CRON.name())) {
	 CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
	 
	 triggerBuilder.withSchedule(cronScheduleBuilder);
 }
 						 
 return triggerBuilder.build();
}
 
开发者ID:thingtrack,项目名称:konekti,代码行数:52,代码来源:JobManagerServiceImpl.java


注:本文中的org.quartz.TriggerBuilder.withIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。