Java 类org.quartz.impl.triggers.CronTriggerImpl 实例源码

项目:uflo    文件:SchedulerServiceImpl.java   
private void initScanReminderJob(){
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("UfloScanReminderTrigger");
    trigger.setKey(new TriggerKey("UfloScanReminderTrigger"));
    try {
        trigger.setCronExpression(SCAN_REMINDER_CRON);
        ScanReminderJob job=new ScanReminderJob();
        ScanReminderJobDetail detail=new ScanReminderJobDetail();
        detail.setSchedulerService(this);
        detail.setTaskService(taskService);
        detail.setReminderTaskList(reminderTaskList);
        detail.setJobClass(job.getClass());
        detail.setKey(new JobKey("UfloScanReminderJob"));
        scheduler.scheduleJob(detail, trigger);
    } catch (Exception e1) {
        throw new RuntimeException(e1);
    }
}
项目:light-task-scheduler    文件:QuartzSchedulerBeanTargetEditor.java   
@Override
@SuppressWarnings({"unchecked"})
public void setValue(Object value) {

    List<Object> nativeQuartzTriggers = new ArrayList<Object>();

    if (value != null && value instanceof Collection) {

        Collection<Trigger> triggers = (Collection<Trigger>) value;
        List<QuartzCronJob> quartzCronJobs = new ArrayList<QuartzCronJob>(triggers.size());
        for (Trigger trigger : triggers) {
            if (trigger instanceof CronTriggerImpl) {
                quartzCronJobs.add(buildQuartzCronJob((CronTriggerImpl) trigger));
            } else {
                LOGGER.warn("Can't Proxy " + trigger.getClass().getName() + " Then Use Quartz Scheduler");
                nativeQuartzTriggers.add(trigger);
            }
        }
        context.getAgent().startProxy(quartzCronJobs);
    }
    super.setValue(nativeQuartzTriggers);
}
项目:motech    文件:MotechSchedulerServiceImpl.java   
private void scheduleDayOfWeekJob(DayOfWeekSchedulableJob job, boolean update) {
    logObjectIfNotNull(job);

    validateDayOfWeekSchedulableJob(job);

    MotechEvent motechEvent = job.getMotechEvent();
    Time time = job.getTime();

    CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.atHourAndMinuteOnGivenDaysOfWeek(time.getHour(),
            time.getMinute(), job.getCronDays()
                    .toArray(new Integer[job.getCronDays().size()]));

    CronTriggerImpl cronTrigger = (CronTriggerImpl) cronScheduleBuilder.build();
    CronSchedulableJob cronSchedulableJob = new CronSchedulableJob(motechEvent, cronTrigger.getCronExpression(),
            job.getStartDate(), job.getEndDate(), job.isIgnorePastFiresAtStart(), job.isUiDefined());

    scheduleCronJob(cronSchedulableJob, true, update);
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void storeTrigger() throws Exception {
    CronTriggerImpl trigger = getCronTrigger();
    trigger.getJobDataMap().put("foo", "bar");

    jobStore.storeTrigger(trigger, false);

    final String triggerHashKey = schema.triggerHashKey(trigger.getKey());
    Map<String, String> triggerMap = jedis.hgetAll(triggerHashKey);
    assertThat(triggerMap, hasKey("description"));
    assertEquals(trigger.getDescription(), triggerMap.get("description"));
    assertThat(triggerMap, hasKey("trigger_class"));
    assertEquals(trigger.getClass().getName(), triggerMap.get("trigger_class"));

    assertTrue("The trigger hash key is not a member of the triggers set.", jedis.sismember(schema.triggersSet(), triggerHashKey));
    assertTrue("The trigger group set key is not a member of the trigger group set.", jedis.sismember(schema.triggerGroupsSet(), schema.triggerGroupSetKey(trigger.getKey())));
    assertTrue(jedis.sismember(schema.triggerGroupSetKey(trigger.getKey()), triggerHashKey));
    assertTrue(jedis.sismember(schema.jobTriggersSetKey(trigger.getJobKey()), triggerHashKey));
    String triggerDataMapHashKey = schema.triggerDataMapHashKey(trigger.getKey());
    MatcherAssert.assertThat(jedis.exists(triggerDataMapHashKey), equalTo(true));
    MatcherAssert.assertThat(jedis.hget(triggerDataMapHashKey, "foo"), equalTo("bar"));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void removeTrigger() throws Exception {
    JobDetail job = getJobDetail();
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup", job.getKey());
    trigger1.getJobDataMap().put("foo", "bar");
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup", job.getKey());

    jobStore.storeJob(job, false);
    jobStore.storeTrigger(trigger1, false);
    jobStore.storeTrigger(trigger2, false);

    jobStore.removeTrigger(trigger1.getKey());

    // ensure that the trigger was removed, but the job was not
    assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());
    assertThat(jobStore.retrieveJob(job.getKey()), not(nullValue()));

    // remove the second trigger
    jobStore.removeTrigger(trigger2.getKey());

    //  ensure that both the trigger and job were removed
    assertThat(jobStore.retrieveTrigger(trigger2.getKey()), nullValue());
    assertThat(jobStore.retrieveJob(job.getKey()), nullValue());
    MatcherAssert.assertThat(jedis.exists(schema.triggerDataMapHashKey(trigger1.getKey())), equalTo(false));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void getTriggerState() throws Exception {
    SchedulerSignaler signaler = mock(SchedulerSignaler.class);
    AbstractRedisStorage storageDriver = new RedisStorage(new RedisJobStoreSchema(), new ObjectMapper(), signaler, "scheduler1", 2000);

    // attempt to retrieve the state of a non-existent trigger
    Trigger.TriggerState state = jobStore.getTriggerState(new TriggerKey("foobar"));
    assertEquals(Trigger.TriggerState.NONE, state);

    // store a trigger
    JobDetail job = getJobDetail();
    CronTriggerImpl cronTrigger = getCronTrigger("trigger1", "group1", job.getKey());
    jobStore.storeTrigger(cronTrigger, false);

    // the newly-stored trigger's state should be NONE
    state = jobStore.getTriggerState(cronTrigger.getKey());
    assertEquals(Trigger.TriggerState.NORMAL, state);

    // set the trigger's state
    storageDriver.setTriggerState(RedisTriggerState.WAITING, 500, schema.triggerHashKey(cronTrigger.getKey()), jedis);

    // the trigger's state should now be NORMAL
    state = jobStore.getTriggerState(cronTrigger.getKey());
    assertEquals(Trigger.TriggerState.NORMAL, state);
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void pauseTriggersStartsWith() throws Exception {
    JobDetail job = getJobDetail();
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger1", "group2", job.getKey());
    CronTriggerImpl trigger3 = getCronTrigger("trigger1", "foogroup1", job.getKey());
    storeJobAndTriggers(job, trigger1, trigger2, trigger3);

    Collection<String> pausedTriggerGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupStartsWith("group"));

    assertThat(pausedTriggerGroups, hasSize(2));
    assertThat(pausedTriggerGroups, containsInAnyOrder("group1", "group2"));

    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger3.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void pauseTriggersEndsWith() throws Exception {
    JobDetail job = getJobDetail();
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger1", "group2", job.getKey());
    CronTriggerImpl trigger3 = getCronTrigger("trigger1", "foogroup1", job.getKey());
    storeJobAndTriggers(job, trigger1, trigger2, trigger3);

    Collection<String> pausedGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupEndsWith("oup1"));

    assertThat(pausedGroups, hasSize(2));
    assertThat(pausedGroups, containsInAnyOrder("group1", "foogroup1"));

    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger2.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger3.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void resumeTrigger() throws Exception {
    // create and store a job and trigger
    JobDetail job = getJobDetail();
    jobStore.storeJob(job, false);
    CronTriggerImpl trigger = getCronTrigger("trigger1", "group1", job.getKey());
    trigger.computeFirstFireTime(new WeeklyCalendar());
    jobStore.storeTrigger(trigger, false);

    // pause the trigger
    jobStore.pauseTrigger(trigger.getKey());
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger.getKey()));

    // resume the trigger
    jobStore.resumeTrigger(trigger.getKey());
    // the trigger state should now be NORMAL
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));

    // attempt to resume the trigger, again
    jobStore.resumeTrigger(trigger.getKey());
    // the trigger state should not have changed
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void resumeTriggersStartsWith() throws Exception {
    JobDetail job = getJobDetail();
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "mygroup1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "group1", job.getKey());
    CronTriggerImpl trigger3 = getCronTrigger("trigger3", "group2", job.getKey());
    CronTriggerImpl trigger4 = getCronTrigger("trigger4", "group3", job.getKey());
    storeJobAndTriggers(job, trigger1, trigger2, trigger3, trigger4);

    Collection<String> pausedGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupStartsWith("my"));

    assertThat(pausedGroups, hasSize(1));
    assertThat(pausedGroups, containsInAnyOrder("mygroup1"));

    // ensure that the triggers were actually paused
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));

    // resume triggers
    Collection<String> resumedGroups = jobStore.resumeTriggers(GroupMatcher.triggerGroupStartsWith("my"));

    assertThat(resumedGroups, hasSize(1));
    assertThat(resumedGroups, containsInAnyOrder("mygroup1"));

    // ensure that the triggers were actually resumed
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger1.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void replaceTriggerSingleTriggerNonDurableJob() throws Exception {
    // store trigger and job
    JobDetail job = getJobDetail();
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
    storeJobAndTriggers(job, trigger1);

    CronTriggerImpl newTrigger = getCronTrigger("newTrigger", "group1", job.getKey());

    assertTrue(jobStore.replaceTrigger(trigger1.getKey(), newTrigger));

    // ensure that the proper trigger was replaced
    assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());

    List<OperableTrigger> jobTriggers = jobStore.getTriggersForJob(job.getKey());

    assertThat(jobTriggers, hasSize(1));

    // ensure that the job still exists
    assertThat(jobStore.retrieveJob(job.getKey()), not(nullValue()));
}
项目:quartz-redis-jobstore    文件:StoreJobTest.java   
@Test
public void removeJob() throws Exception {
    // attempt to remove a non-existent job
    assertFalse(jobStore.removeJob(JobKey.jobKey("foo", "bar")));

    // create and store a job with multiple triggers
    JobDetail job = getJobDetail("job1", "jobGroup1");
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job.getKey());
    Set<Trigger> triggersSet = new HashSet<>();
    triggersSet.add(trigger1);
    triggersSet.add(trigger2);
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = new HashMap<>();
    jobsAndTriggers.put(job, triggersSet);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    assertTrue(jobStore.removeJob(job.getKey()));

    // ensure that the job and all of its triggers were removed
    assertThat(jobStore.retrieveJob(job.getKey()), nullValue());
    assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());
    assertThat(jobStore.retrieveTrigger(trigger2.getKey()), nullValue());
    assertThat(jedis.get(schema.triggerHashKey(trigger1.getKey())), nullValue());
}
项目:quartz-redis-jobstore    文件:StoreJobTest.java   
@Test
public void pauseJob() throws Exception {
    // create and store a job with multiple triggers
    JobDetail job = getJobDetail("job1", "jobGroup1");
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job.getKey());
    Set<Trigger> triggersSet = new HashSet<>();
    triggersSet.add(trigger1);
    triggersSet.add(trigger2);
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = new HashMap<>();
    jobsAndTriggers.put(job, triggersSet);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    // pause the job
    jobStore.pauseJob(job.getKey());

    // ensure that the job's triggers were paused
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreJobTest.java   
@Test
public void pauseJobsStartsWith() throws Exception {
    JobDetail job1 = getJobDetail("job1", "jobGroup1");
    storeJobAndTriggers(job1, getCronTrigger("trigger1", "triggerGroup1", job1.getKey()), getCronTrigger("trigger2", "triggerGroup1", job1.getKey()));
    JobDetail job2 = getJobDetail("job2", "yobGroup1");
    CronTriggerImpl trigger3 = getCronTrigger("trigger3", "triggerGroup3", job2.getKey());
    CronTriggerImpl trigger4 = getCronTrigger("trigger4", "triggerGroup4", job2.getKey());
    storeJobAndTriggers(job2, trigger3, trigger4);

    // pause jobs with groups beginning with "yob"
    Collection<String> pausedJobs = jobStore.pauseJobs(GroupMatcher.jobGroupStartsWith("yob"));
    assertThat(pausedJobs, hasSize(1));
    assertThat(pausedJobs, containsInAnyOrder("yobGroup1"));

    // ensure that the job was added to the paused jobs set
    assertTrue(jedis.sismember(schema.pausedJobGroupsSet(), schema.jobGroupSetKey(job2.getKey())));

    // ensure that the job's triggers have been paused
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger3.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger4.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreJobTest.java   
@Test
public void pauseJobsEndsWith() throws Exception {
    JobDetail job1 = getJobDetail("job1", "jobGroup1");
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job1.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job1.getKey());
    storeJobAndTriggers(job1, trigger1, trigger2);
    JobDetail job2 = getJobDetail("job2", "yobGroup2");
    CronTriggerImpl trigger3 = getCronTrigger("trigger3", "triggerGroup3", job2.getKey());
    CronTriggerImpl trigger4 = getCronTrigger("trigger4", "triggerGroup4", job2.getKey());
    storeJobAndTriggers(job2, trigger3, trigger4);

    // pause job groups ending with "1"
    Collection<String> pausedJobs = jobStore.pauseJobs(GroupMatcher.jobGroupEndsWith("1"));
    assertThat(pausedJobs, hasSize(1));
    assertThat(pausedJobs, containsInAnyOrder("jobGroup1"));

    // ensure that the job was added to the paused jobs set
    assertTrue(jedis.sismember(schema.pausedJobGroupsSet(), schema.jobGroupSetKey(job1.getKey())));

    // ensure that the job's triggers have been paused
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreJobTest.java   
@Test
public void resumeJob() throws Exception {
    // create and store a job with multiple triggers
    JobDetail job = getJobDetail("job1", "jobGroup1");
    CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job.getKey());
    storeJobAndTriggers(job, trigger1, trigger2);

    // pause the job
    jobStore.pauseJob(job.getKey());

    // ensure that the job's triggers have been paused
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));

    // resume the job
    jobStore.resumeJob(job.getKey());

    // ensure that the triggers have been resumed
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger1.getKey()));
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger2.getKey()));
}
项目:quartz-redis-jobstore    文件:TriggeredJobCompleteTest.java   
@Test
public void triggeredJobCompleteNonConcurrent() throws JobPersistenceException {
    JobDetail job = JobBuilder.newJob(TestJobNonConcurrent.class)
            .withIdentity("testJobNonConcurrent1", "jobGroupNonConcurrent1")
            .usingJobData("timeout", 42)
            .withDescription("I am describing a job!")
            .build();
    CronTriggerImpl trigger1 = getCronTrigger("triggerNonConcurrent1", "triggerNonConcurrentGroup1", job.getKey());
    CronTriggerImpl trigger2 = getCronTrigger("triggerNonConcurrent2", "triggerNonConcurrentGroup1", job.getKey());
    storeJobAndTriggers(job, trigger1, trigger2);

    jobStore.triggeredJobComplete(trigger1, job, Trigger.CompletedExecutionInstruction.SET_TRIGGER_COMPLETE);

    assertEquals(Trigger.TriggerState.COMPLETE, jobStore.getTriggerState(trigger1.getKey()));

    final String jobHashKey = schema.jobHashKey(job.getKey());
    assertFalse(jedis.sismember(schema.blockedJobsSet(), jobHashKey));
}
项目:qb-archetype    文件:JobTriggerVo.java   
public CronTrigger toQuartzCronTrigger() throws ParseException {
        CronTriggerImpl ct = new CronTriggerImpl();
        ct.setName(trigger_name);
        ct.setGroup("".equals(trigger_group) ? null : trigger_group);
        ct.setCalendarName("".equals(calendar_name) ? null : calendar_name);
        ct.setCronExpression(cron_expression);
        ct.setDescription(description);
        if(end_time > 0) {
            ct.setEndTime(new Date(end_time));
        }
        ct.setJobGroup("".equals(job_group) ? null : job_group);
        ct.setJobName(job_name);
        ct.setMisfireInstruction(misfire_instr);
//      ct.setNextFireTime(new Date(next_fire_time));
//      ct.setPreviousFireTime(new Date(prev_fire_time));
        ct.setPriority(priority);
        if(start_time > 0) {
            ct.setStartTime(new Date(start_time));
        }
        ct.setJobDataMap(dataMap);
        return ct;
    }
项目:nextreports-server    文件:CleanHistorySettingsPanel.java   
protected void afterChange(Form<?> form, AjaxRequestTarget target) {
    Settings settings = (Settings) form.getModelObject();
    if (!oldCronExpression.equals(settings.getCleanHistory().getCronExpression())) {
        // reschedule clean history
        StdScheduler scheduler = (StdScheduler) NextServerApplication.get().getSpringBean("scheduler");
        CronTriggerImpl cronTrigger = (CronTriggerImpl) NextServerApplication.get()
                .getSpringBean("cleanHistoryTrigger");
        try {
            cronTrigger.setCronExpression(settings.getCleanHistory().getCronExpression());
            scheduler.rescheduleJob(cronTrigger.getKey(), cronTrigger);
        } catch (Exception e) {
            e.printStackTrace();
            LOG.error(e.getMessage(), e);
        }
    }
}
项目:argo    文件:DefaultTaskSchedulerFactoryBean.java   
public void scheduleJob(Job job) throws Exception{
       if(!TaskConfig.instance.isEnabled()){
        return;
    }

       Map app = SiteConfig.instance.getApp();
       String appName = (String)app.get("name");

    JobDetail jobDetail = JobBuilder.newJob(job.getClass()).withIdentity(job.getName(), appName).build();

    CronTriggerImpl trigger = new CronTriggerImpl();
    trigger.setCronExpression(job.getCronExpression());
    trigger.setJobName(job.getName());
    trigger.setJobGroup(appName);

    this.getScheduler().scheduleJob(jobDetail, trigger);
}
项目:swiftly    文件:SayHelloJobTest.java   
public static void main(String[] args) throws SchedulerException, ParseException {
    SchedulerFactory sf = new StdSchedulerFactory();
    Scheduler sched = sf.getScheduler();

    JobDetail jobDetail = JobBuilder.newJob(SayHelloJobTest.class).withDescription("haha job").withIdentity("1",
                                                                                                            "group_1").build();

    CronTriggerImpl trigger = new CronTriggerImpl();
    trigger.setName("trigger");
    trigger.setJobGroup("trigger_group");
    trigger.setCronExpression("*/10 * * * * ?");

    sched.scheduleJob(jobDetail, trigger);

    sched.start();

}
项目:swiftly    文件:SayHelloJobTest.java   
public static void main(String[] args) throws SchedulerException, ParseException {
    SchedulerFactory sf = new StdSchedulerFactory();
    Scheduler sched = sf.getScheduler();

    JobDetail jobDetail = JobBuilder.newJob(SayHelloJobTest.class).withDescription("haha job").withIdentity("1",
                                                                                                            "group_1").build();

    CronTriggerImpl trigger = new CronTriggerImpl();
    trigger.setName("trigger");
    trigger.setJobGroup("trigger_group");
    trigger.setCronExpression("*/10 * * * * ?");

    sched.scheduleJob(jobDetail, trigger);

    sched.start();

}
项目:javasec    文件:JobTriggerVo.java   
public CronTrigger toQuartzCronTrigger() throws ParseException {
        CronTriggerImpl ct = new CronTriggerImpl();
        ct.setName(trigger_name);
        ct.setGroup("".equals(trigger_group) ? null : trigger_group);
        ct.setCalendarName("".equals(calendar_name) ? null : calendar_name);
        ct.setCronExpression(cron_expression);
        ct.setDescription(description);
        if(end_time > 0) {
            ct.setEndTime(new Date(end_time));
        }
        ct.setJobGroup("".equals(job_group) ? null : job_group);
        ct.setJobName(job_name);
        ct.setMisfireInstruction(misfire_instr);
//      ct.setNextFireTime(new Date(next_fire_time));
//      ct.setPreviousFireTime(new Date(prev_fire_time));
        ct.setPriority(priority);
        if(start_time > 0) {
            ct.setStartTime(new Date(start_time));
        }
        ct.setJobDataMap(dataMap);
        return ct;
    }
项目:lams    文件:CronScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users, but
 * will rather be invoked by a TriggerBuilder which this ScheduleBuilder is
 * given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    CronTriggerImpl ct = new CronTriggerImpl();

    ct.setCronExpression(cronExpression);
    ct.setTimeZone(cronExpression.getTimeZone());
    ct.setMisfireInstruction(misfireInstruction);

    return ct;
}
项目:lams    文件:CronTriggerSupport.java   
public static OperableTrigger newTrigger(CompositeData cData) throws ParseException {
    CronTriggerImpl result = new CronTriggerImpl();
    result.setCronExpression((String) cData.get("cronExpression"));
    if(cData.containsKey("timeZone")) {
        result.setTimeZone(TimeZone.getTimeZone((String)cData.get("timeZone")));
    }
    TriggerSupport.initializeTrigger(result, cData);
    return result;
}
项目:lams    文件:CronTriggerSupport.java   
public static OperableTrigger newTrigger(Map<String, Object> attrMap) throws ParseException {
    CronTriggerImpl result = new CronTriggerImpl();
    result.setCronExpression((String) attrMap.get("cronExpression"));
    if(attrMap.containsKey("timeZone")) {
        result.setTimeZone(TimeZone.getTimeZone((String)attrMap.get("timeZone")));
    }
    TriggerSupport.initializeTrigger(result, attrMap);
    return result;
}
项目:stage-job    文件:XxlJobDynamicScheduler.java   
/**
    * fill job info
    *
    * @param jobInfo
    */
public static void fillJobInfo(XxlJobInfo jobInfo) {
    // TriggerKey : name + group
       String group = String.valueOf(jobInfo.getJobGroup());
       String name = String.valueOf(jobInfo.getId());
       TriggerKey triggerKey = TriggerKey.triggerKey(name, group);

       try {
        Trigger trigger = scheduler.getTrigger(triggerKey);

        TriggerState triggerState = scheduler.getTriggerState(triggerKey);

        // parse params
        if (trigger!=null && trigger instanceof CronTriggerImpl) {
            String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
            jobInfo.setJobCron(cronExpression);
        }

        //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
           //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
           //String jobClass = jobDetail.getJobClass().getName();

        if (triggerState!=null) {
            jobInfo.setJobStatus(triggerState.name());
        }

    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
}
项目:azeroth    文件:AbstractJob.java   
private CronTriggerImpl getTrigger() {
    try {
        if (this.cronTrigger == null) {
            if (getScheduler() == null)
                return null;
            Trigger trigger = getScheduler().getTrigger(triggerKey);
            this.cronTrigger = (CronTriggerImpl) trigger;
        }
    } catch (SchedulerException e) {
        logger.error("Job_" + jobName + " Invoke getTrigger error", e);
    }
    return cronTrigger;
}
项目:xxl-job    文件:XxlJobDynamicScheduler.java   
public static void fillJobInfo(XxlJobInfo jobInfo) {
    // TriggerKey : name + group
       String group = String.valueOf(jobInfo.getJobGroup());
       String name = String.valueOf(jobInfo.getId());
       TriggerKey triggerKey = TriggerKey.triggerKey(name, group);

       try {
        Trigger trigger = scheduler.getTrigger(triggerKey);

        TriggerState triggerState = scheduler.getTriggerState(triggerKey);

        // parse params
        if (trigger!=null && trigger instanceof CronTriggerImpl) {
            String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
            jobInfo.setJobCron(cronExpression);
        }

        //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
           //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
           //String jobClass = jobDetail.getJobClass().getName();

        if (triggerState!=null) {
            jobInfo.setJobStatus(triggerState.name());
        }

    } catch (SchedulerException e) {
        e.printStackTrace();
    }
}
项目:jaffa-framework    文件:TriggerHelper.java   
/** Creates a CronTrigger with the given expression.
 */
private static CronTriggerImpl createCronTrigger(String cronExpression) throws FrameworkException, ApplicationExceptions {
    try {
        final CronTriggerImpl trigger = new CronTriggerImpl();
        trigger.setCronExpression(cronExpression);
        return trigger;
    } catch (ParseException e) {
        log.error("Error parsing cron expression " + cronExpression, e);
        throw new ApplicationExceptions(new JaffaSchedulerApplicationException(JaffaSchedulerApplicationException.INVALID_TRIGGER, new Object[] {cronExpression}));
    }
}
项目:bdf2    文件:HeartSystemJobProvider.java   
public Trigger getTrigger() {
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("HeartJobTrigger");
    try {
        trigger.setCronExpression(heartJobCronExpression);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
    return trigger;
}
项目:bdf2    文件:DaemonStatusController.java   
@Override
protected ModelAndView doHandleRequest(HttpServletRequest req,HttpServletResponse res) throws Exception {
    SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Scheduler scheduler=instanceDetection.getScheduler();
    StringBuffer sb=new StringBuffer();
    sb.append("<strong>Status</strong>:");
    if(scheduler.isInStandbyMode()){
        sb.append("Standby");
    }
    if(scheduler.isShutdown()){
        sb.append("Shutdown");
    }
    if(scheduler.isStarted()){
        sb.append("Started");
    }
    sb.append("<br>");
    for (String groupName : scheduler.getJobGroupNames()) {
         for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
             JobDetail jobDetail=scheduler.getJobDetail(jobKey);
             sb.append("<strong>JobClass:</strong>");
             sb.append(jobDetail.getJobClass().getName());

             Trigger trigger=scheduler.getTriggersOfJob(jobDetail.getKey()).get(0);
             sb.append("<br><strong>PreviousFireDate:</strong>");
             if(trigger.getPreviousFireTime()!=null){
                 sb.append(sd.format(trigger.getPreviousFireTime()));                    
             }
             sb.append("<br><strong>NextFireDate:</strong>");
             if(sd.format(trigger.getNextFireTime())!=null){
                 sb.append(sd.format(trigger.getNextFireTime()));                    
             }
             if(trigger instanceof CronTriggerImpl){
                 CronTriggerImpl cron=(CronTriggerImpl)trigger;
                 sb.append("<br><strong>CronExpression:</strong>");
                 sb.append(cron.getCronExpression());
             }

         }
    }
    res.setContentType("text/html; charset=utf-8");
    PrintWriter pw=res.getWriter();
    pw.write(sb.toString());
    pw.flush();
    pw.close();
    return null;
}
项目:bdf2    文件:InstanceDetection.java   
private void iniTtrigger(){
    trigger=new CronTriggerImpl();
    trigger.setName("HeartbeatTrigger");
    trigger.setKey(new TriggerKey("HeartbeatTrigger"));
    try {
        trigger.setCronExpression(detectionCron);
    } catch (ParseException e1) {
        e1.printStackTrace();
        throw new RuntimeException(e1);
    }
}
项目:bdf2    文件:JobServiceImpl.java   
public void updateTrigger(String jobDefId,String companyId,String cronExpression) throws SchedulerException {
    Scheduler scheduler=schedulerService.retrieveScheduler();
    CronTriggerImpl trigger=(CronTriggerImpl)scheduler.getTrigger(new TriggerKey(TRIGGER_PREFIX+jobDefId,companyId));
    try {
        trigger.setCronExpression(cronExpression);
    } catch (ParseException e) {
        e.printStackTrace();
        throw new SchedulerException(e);
    }
    scheduler.scheduleJob(trigger);
}
项目:bdf2    文件:SystemScanJobProvider.java   
public Trigger getTrigger() {
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("trigger"+ScanJobExecutor.JOB_ID);
    try {
        trigger.setCronExpression(scanJobCronExpression);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
    return trigger;
}
项目:bdf2    文件:ScanTaskReminderJobProvider.java   
public Trigger getTrigger() {
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("trigger"+ScanTaskReminderJob.JOB_ID);
    try {
        trigger.setCronExpression(scanTaskReminderJobCronExpression);
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
    return trigger;
}
项目:uflo    文件:HeartbeatDetectionJob.java   
private Trigger buildHeartJobTrigger() {
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("UfloHeartJobTrigger");
    try {
        trigger.setCronExpression(heartJobCronExpression);
        return trigger;
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
}
项目:uflo    文件:InstanceDetection.java   
private Trigger initTrigger(){
    CronTriggerImpl trigger=new CronTriggerImpl();
    trigger.setName("UfloHeartbeatTrigger");
    trigger.setKey(new TriggerKey("UfloHeartbeatTrigger"));
    try {
        trigger.setCronExpression(detectionCron);
        return trigger;
    } catch (ParseException e1) {
        throw new RuntimeException(e1);
    }
}
项目:uflo    文件:SchedulerServiceImpl.java   
public void addReminderJob(TaskReminder reminder,ProcessInstance processInstance,Task task) {
    try {
        AbstractTrigger<? extends Trigger> trigger=null;
        if(reminder.getType().equals(ReminderType.Once)){
            SimpleTriggerImpl simpleTrigger=new SimpleTriggerImpl();
            simpleTrigger.setRepeatCount(0);
            trigger=simpleTrigger;
            long executeTime=reminder.getStartDate().getTime()+10000;
            long now=(new Date()).getTime();
            if(executeTime<=now){
                return;
            }
        }else{
            CronTriggerImpl cronTrigger=new CronTriggerImpl();
            cronTrigger.setCronExpression(reminder.getCron());
            trigger=cronTrigger;
        }
        trigger.setName("trigger_"+reminder.getId());
        trigger.setStartTime(reminder.getStartDate());
        ReminderJobDetail jobDetail=new ReminderJobDetail();
        jobDetail.setJobClass(ReminderJob.class);
        ReminderHandler handler=(ReminderHandler)applicationContext.getBean(reminder.getReminderHandlerBean());
        jobDetail.setReminderHandlerBean(handler);
        if(task==null){
            task=taskService.getTask(reminder.getTaskId());             
        }
        jobDetail.setTask(task);
        jobDetail.setProcessInstance(processService.getProcessInstanceById(task.getProcessInstanceId()));
        jobDetail.setKey(new JobKey(JOB_NAME_PREFIX+reminder.getId(),JOB_GROUP_PREFIX));
        Calendar calendar=getCalendar(reminder,processInstance,task);
        if(calendar!=null){
            String calendarName=REMINDER_CALENDAR_PREFIX+reminder.getId();
            scheduler.addCalendar(calendarName, calendar,false, false);
            trigger.setCalendarName(calendarName);
        }
        scheduler.scheduleJob(jobDetail, trigger);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }   
}
项目:spring4-understanding    文件:CronTriggerFactoryBean.java   
@Override
public void afterPropertiesSet() throws ParseException {
    if (this.name == null) {
        this.name = this.beanName;
    }
    if (this.group == null) {
        this.group = Scheduler.DEFAULT_GROUP;
    }
    if (this.jobDetail != null) {
        this.jobDataMap.put("jobDetail", this.jobDetail);
    }
    if (this.startDelay > 0 || this.startTime == null) {
        this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
    }
    if (this.timeZone == null) {
        this.timeZone = TimeZone.getDefault();
    }

    CronTriggerImpl cti = new CronTriggerImpl();
    cti.setName(this.name);
    cti.setGroup(this.group);
    cti.setJobKey(this.jobDetail.getKey());
    cti.setJobDataMap(this.jobDataMap);
    cti.setStartTime(this.startTime);
    cti.setCronExpression(this.cronExpression);
    cti.setTimeZone(this.timeZone);
    cti.setCalendarName(this.calendarName);
    cti.setPriority(this.priority);
    cti.setMisfireInstruction(this.misfireInstruction);
    cti.setDescription(this.description);
    this.cronTrigger = cti;
}