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


Java TriggerBuilder.usingJobData方法代码示例

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


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

示例1: createTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
protected Trigger createTrigger(JobDataMap data, Date start, int interval,
		int repeat, Date end) {

	TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();

	if (data != null) {
		triggerBuilder.usingJobData(data);
	}
	if (interval > 0) {
		SimpleScheduleBuilder schedule = SimpleScheduleBuilder
				.simpleSchedule();
		schedule.withIntervalInMilliseconds(interval).withRepeatCount(
				repeat);
		triggerBuilder.withSchedule(schedule);
	}

	if (start != null) {
		triggerBuilder.startAt(start);
	} else {
		triggerBuilder.startNow();
	}

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

	return triggerBuilder.build();
}
 
开发者ID:ludup,项目名称:hypersocket-framework,代码行数:29,代码来源:SchedulerServiceImpl.java

示例2: 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


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