Quartz 2.x,如何获得触发类型?

时间:2017-04-17 00:39:36

标签: java triggers quartz

我正在使用quartz 2.x版本。

我需要从TRIGGER_TYPE表中获取列QRTZ_TRIGGERS

使用API​​,如何获取TRIGGER_TYPE

这是我的代码:



for (String group : scheduler.getTriggerGroupNames()) {
    for (TriggerKey triggerKey : scheduler.getTriggerKeys(GroupMatcher.<TriggerKey>groupEquals(group))) {
        Trigger trigger = scheduler.getTrigger(triggerKey(triggerKey.getName(), triggerKey.getGroup()));
        System.out.println(scheduler.getSchedulerName());
        System.out.println(triggerKey.getName());
        System.out.println(triggerKey.getGroup());
        System.out.println(trigger.getJobKey());
        //job name
        //job group
        System.out.println(trigger.getDescription());
        System.out.println(trigger.getNextFireTime());
        System.out.println(trigger.getPreviousFireTime());
        System.out.println(trigger.getPriority());
        System.out.println(scheduler.getTriggerState(triggerKey(triggerKey.getName(), triggerKey.getGroup())));
        //trigger type
        System.out.println(trigger.getStartTime());
        System.out.println(trigger.getEndTime());
        System.out.println(trigger.getCalendarName());
        System.out.println(trigger.getMisfireInstruction());
    }
}
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

有两种触发类型,SimpleTrigger和CronTrigger。

也许看看他们的API。你可能会在那里找到关于如何区分两者的线索。

答案 1 :(得分:0)

$userid = "116899029375914044550"; $url = "https://www.googleapis.com/plus/v1/people/".$userid."/"; $params = array( 'key' => 'YOURKEY' ); $param_string = array(); foreach( $params as $key => $param ){ $param_string[] = $key.'='.urlencode(trim($param)); } $url = $url.'?'.implode('&',$param_string); $ch = curl_init( $url ); curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true ); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response); $url = $data->url; echo $url; 中的TRIGGER_TYPE信息在运行时反映在QRTZ_TRIGGERS实现的特定Java类型中:

  • Trigger - &gt; CalendarIntervalTriggerImpl
  • TTYPE_CAL_INT - &gt; CronTriggerImpl
  • TTYPE_CRON - &gt; DailyTimeIntervalTriggerImpl
  • TTYPE_DAILY_TIME_INT - &gt; SimpleTriggerImpl

自定义TTYPE_SIMPLE类型还有一种默认触发类型:Trigger

请注意,如果您确实想在运行时访问该信息,最好使用以下代码:

TTYPE_BLOB