當前位置: 首頁>>代碼示例>>Java>>正文


Java TriggerKey類代碼示例

本文整理匯總了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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:DefaultClusteredJobStore.java

示例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);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:24,代碼來源:MicroQuartzManager.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:StdJDBCDelegate.java

示例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;
	}
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:24,代碼來源:JobServiceImpl.java

示例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;
	}
}
 
開發者ID:javabypatel,項目名稱:spring-boot-quartz-demo,代碼行數:23,代碼來源:JobServiceImpl.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:JobStoreSupport.java

示例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);
        }
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:QuartzScheduler.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:DefaultClusteredJobStore.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:StdJDBCDelegate.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:JobStoreSupport.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:StdJDBCDelegate.java

示例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);
	}
}
 
開發者ID:youseries,項目名稱:uflo,代碼行數:19,代碼來源:SchedulerServiceImpl.java

示例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);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:RemoteScheduler.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:QuartzScheduler.java

示例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);
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:10,代碼來源:SchedulerManager.java


注:本文中的org.quartz.TriggerKey類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。