本文整理匯總了Java中org.quartz.TriggerKey類的典型用法代碼示例。如果您正苦於以下問題:Java TriggerKey類的具體用法?Java TriggerKey怎麽用?Java TriggerKey使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TriggerKey類屬於org.quartz包,在下文中一共展示了TriggerKey類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTriggerState
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Get the current state of the identified <code>{@link Trigger}</code>.
* </p>
*
* @see Trigger.TriggerState
*/
@Override
public Trigger.TriggerState getTriggerState(org.quartz.TriggerKey key) throws JobPersistenceException {
TriggerWrapper tw;
lock();
try {
tw = triggerFacade.get(key);
} finally {
unlock();
}
if (tw == null) { return Trigger.TriggerState.NONE; }
if (tw.getState() == TriggerState.COMPLETE) { return Trigger.TriggerState.COMPLETE; }
if (tw.getState() == TriggerState.PAUSED) { return Trigger.TriggerState.PAUSED; }
if (tw.getState() == TriggerState.PAUSED_BLOCKED) { return Trigger.TriggerState.PAUSED; }
if (tw.getState() == TriggerState.BLOCKED) { return Trigger.TriggerState.BLOCKED; }
if (tw.getState() == TriggerState.ERROR) { return Trigger.TriggerState.ERROR; }
return Trigger.TriggerState.NORMAL;
}
示例2: removeJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* @Description 移除一個任務(使用默認的任務組名,觸發器名,觸發器組名)
* @param jobName
*
*
*/
public static void removeJob(String jobName) {
TriggerKey triggerKey = TriggerKey.triggerKey(
jobName, TRIGGER_GROUP_NAME);
JobKey jobKey = JobKey.jobKey(jobName, JOB_GROUP_NAME);
try {
Scheduler sched = gSchedulerFactory.getScheduler();
Trigger trigger = (Trigger) sched.getTrigger(triggerKey);
if (trigger == null) {
return;
}
sched.pauseTrigger(triggerKey);;// 停止觸發器
sched.unscheduleJob(triggerKey);// 移除觸發器
sched.deleteJob(jobKey);// 刪除任務
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: deleteTrigger
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Delete the base trigger data for a trigger.
* </p>
*
* @param conn
* the DB Connection
* @return the number of rows deleted
*/
public int deleteTrigger(Connection conn, TriggerKey triggerKey) throws SQLException {
PreparedStatement ps = null;
deleteTriggerExtension(conn, triggerKey);
try {
ps = conn.prepareStatement(rtp(DELETE_TRIGGER));
ps.setString(1, triggerKey.getName());
ps.setString(2, triggerKey.getGroup());
return ps.executeUpdate();
} finally {
closeStatement(ps);
}
}
示例4: updateOneTimeJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* Update one time scheduled job.
*/
@Override
public boolean updateOneTimeJob(String jobName, Date date) {
System.out.println("Request received for updating one time job.");
String jobKey = jobName;
System.out.println("Parameters received for updating one time job : jobKey :"+jobKey + ", date: "+date);
try {
//Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
Trigger newTrigger = JobUtil.createSingleTrigger(jobKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
Date dt = schedulerFactoryBean.getScheduler().rescheduleJob(TriggerKey.triggerKey(jobKey), newTrigger);
System.out.println("Trigger associated with jobKey :"+jobKey+ " rescheduled successfully for date :"+dt);
return true;
} catch ( Exception e ) {
System.out.println("SchedulerException while updating one time job with key :"+jobKey + " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例5: unScheduleJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* Remove the indicated Trigger from the scheduler.
* If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.
*/
@Override
public boolean unScheduleJob(String jobName) {
System.out.println("Request received for Unscheduleding job.");
String jobKey = jobName;
TriggerKey tkey = new TriggerKey(jobKey);
System.out.println("Parameters received for unscheduling job : tkey :"+jobKey);
try {
boolean status = schedulerFactoryBean.getScheduler().unscheduleJob(tkey);
System.out.println("Trigger associated with jobKey :"+jobKey+ " unscheduled with status :"+status);
return status;
} catch (SchedulerException e) {
System.out.println("SchedulerException while unscheduling job with key :"+jobKey + " message :"+e.getMessage());
e.printStackTrace();
return false;
}
}
示例6: updateMisfiredTrigger
import org.quartz.TriggerKey; //導入依賴的package包/類
protected boolean updateMisfiredTrigger(Connection conn,
TriggerKey triggerKey, String newStateIfNotComplete, boolean forceState)
throws JobPersistenceException {
try {
OperableTrigger trig = retrieveTrigger(conn, triggerKey);
long misfireTime = System.currentTimeMillis();
if (getMisfireThreshold() > 0) {
misfireTime -= getMisfireThreshold();
}
if (trig.getNextFireTime().getTime() > misfireTime) {
return false;
}
doUpdateOfMisfiredTrigger(conn, trig, forceState, newStateIfNotComplete, false);
return true;
} catch (Exception e) {
throw new JobPersistenceException(
"Couldn't update misfired trigger '" + triggerKey + "': " + e.getMessage(), e);
}
}
示例7: notifySchedulerListenersUnscheduled
import org.quartz.TriggerKey; //導入依賴的package包/類
public void notifySchedulerListenersUnscheduled(TriggerKey triggerKey) {
// build a list of all scheduler listeners that are to be notified...
List<SchedulerListener> schedListeners = buildSchedulerListenerList();
// notify all scheduler listeners
for(SchedulerListener sl: schedListeners) {
try {
if(triggerKey == null)
sl.schedulingDataCleared();
else
sl.jobUnscheduled(triggerKey);
} catch (Exception e) {
getLog().error(
"Error while notifying SchedulerListener of unscheduled job."
+ " Triger=" + (triggerKey == null ? "ALL DATA" : triggerKey), e);
}
}
}
示例8: getTriggersForJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Get all of the Triggers that are associated to the given Job.
* </p>
* <p>
* If there are no matches, a zero-length array should be returned.
* </p>
*/
@Override
public List<OperableTrigger> getTriggersForJob(final JobKey jobKey) throws JobPersistenceException {
List<OperableTrigger> trigList = new ArrayList<OperableTrigger>();
lock();
try {
for (TriggerKey triggerKey : triggerFacade.allTriggerKeys()) {
TriggerWrapper tw = triggerFacade.get(triggerKey);
if (tw.getJobKey().equals(jobKey)) {
trigList.add(tw.getTriggerClone());
}
}
} finally {
unlock();
}
return trigList;
}
示例9: selectTriggerKeysForJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Get the names of all of the triggers associated with the given job.
* </p>
*
* @param conn
* the DB Connection
* @return an array of <code>{@link
* org.quartz.utils.Key}</code> objects
*/
public List<TriggerKey> selectTriggerKeysForJob(Connection conn, JobKey jobKey) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_FOR_JOB));
ps.setString(1, jobKey.getName());
ps.setString(2, jobKey.getGroup());
rs = ps.executeQuery();
LinkedList<TriggerKey> list = new LinkedList<TriggerKey>();
while (rs.next()) {
String trigName = rs.getString(COL_TRIGGER_NAME);
String trigGroup = rs.getString(COL_TRIGGER_GROUP);
list.add(triggerKey(trigName, trigGroup));
}
return list;
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例10: pauseTrigger
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Pause the <code>{@link org.quartz.Trigger}</code> with the given name.
* </p>
*
* @see #resumeTrigger(Connection, TriggerKey)
*/
public void pauseTrigger(Connection conn,
TriggerKey triggerKey)
throws JobPersistenceException {
try {
String oldState = getDelegate().selectTriggerState(conn,
triggerKey);
if (oldState.equals(STATE_WAITING)
|| oldState.equals(STATE_ACQUIRED)) {
getDelegate().updateTriggerState(conn, triggerKey,
STATE_PAUSED);
} else if (oldState.equals(STATE_BLOCKED)) {
getDelegate().updateTriggerState(conn, triggerKey,
STATE_PAUSED_BLOCKED);
}
} catch (SQLException e) {
throw new JobPersistenceException("Couldn't pause trigger '"
+ triggerKey + "': " + e.getMessage(), e);
}
}
示例11: selectTriggerGroups
import org.quartz.TriggerKey; //導入依賴的package包/類
public List<String> selectTriggerGroups(Connection conn, GroupMatcher<TriggerKey> matcher) throws SQLException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.prepareStatement(rtp(SELECT_TRIGGER_GROUPS_FILTERED));
ps.setString(1, toSqlLikeClause(matcher));
rs = ps.executeQuery();
LinkedList<String> list = new LinkedList<String>();
while (rs.next()) {
list.add(rs.getString(1));
}
return list;
} finally {
closeResultSet(rs);
closeStatement(ps);
}
}
示例12: initScanReminderJob
import org.quartz.TriggerKey; //導入依賴的package包/類
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);
}
}
示例13: resumeTriggers
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Calls the equivalent method on the 'proxied' <code>QuartzScheduler</code>.
* </p>
*/
public void resumeTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException {
try {
getRemoteScheduler().resumeTriggers(matcher);
} catch (RemoteException re) {
throw invalidateHandleCreateException(
"Error communicating with remote scheduler.", re);
}
}
示例14: unscheduleJob
import org.quartz.TriggerKey; //導入依賴的package包/類
/**
* <p>
* Remove the indicated <code>{@link org.quartz.Trigger}</code> from the
* scheduler.
* </p>
*/
public boolean unscheduleJob(TriggerKey triggerKey) throws SchedulerException {
validateState();
if (resources.getJobStore().removeTrigger(triggerKey)) {
notifySchedulerThread(0L);
notifySchedulerListenersUnscheduled(triggerKey);
} else {
return false;
}
return true;
}
示例15: resumeJob
import org.quartz.TriggerKey; //導入依賴的package包/類
public void resumeJob(TaskScheduled scheduleJob) {
try {
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
scheduler.resumeTrigger(triggerKey);
} catch (Exception e) {
logger.error("Try to resume Job cause error : ", e);
throw new BusinessException(e);
}
}