类org.quartz.utils.Key源码实例Demo

下面列出了怎么用org.quartz.utils.Key的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: TriggerBuilder.java
/**
 * Produce the <code>Trigger</code>.
 * 
 * @return a Trigger that meets the specifications of the builder.
 */
@SuppressWarnings("unchecked")
public T build() {

    if(scheduleBuilder == null)
        scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
    MutableTrigger trig = scheduleBuilder.build();
    
    trig.setCalendarName(calendarName);
    trig.setDescription(description);
    trig.setStartTime(startTime);
    trig.setEndTime(endTime);
    if(key == null)
        key = new TriggerKey(Key.createUniqueName(null), null);
    trig.setKey(key); 
    if(jobKey != null)
        trig.setJobKey(jobKey);
    trig.setPriority(priority);
    
    if(!jobDataMap.isEmpty())
        trig.setJobDataMap(jobDataMap);
    
    return (T) trig;
}
 
源代码2 项目: lams   文件: JobBuilder.java
/**
 * Produce the <code>JobDetail</code> instance defined by this 
 * <code>JobBuilder</code>.
 * 
 * @return the defined JobDetail.
 */
public JobDetail build() {

    JobDetailImpl job = new JobDetailImpl();
    
    job.setJobClass(jobClass);
    job.setDescription(description);
    if(key == null)
        key = new JobKey(Key.createUniqueName(null), null);
    job.setKey(key); 
    job.setDurability(durability);
    job.setRequestsRecovery(shouldRecover);
    
    
    if(!jobDataMap.isEmpty())
        job.setJobDataMap(jobDataMap);
    
    return job;
}
 
源代码3 项目: AsuraFramework   文件: JobStoreSupport.java
protected boolean removeJob(Connection conn, SchedulingContext ctxt,
        String jobName, String groupName, boolean activeDeleteSafe)
    throws JobPersistenceException {

    try {
        Key[] jobTriggers = getDelegate().selectTriggerNamesForJob(conn,
                jobName, groupName);
        for (int i = 0; i < jobTriggers.length; ++i) {
            deleteTriggerAndChildren(
                conn, jobTriggers[i].getName(), jobTriggers[i].getGroup());
        }

        return deleteJobAndChildren(conn, ctxt, jobName, groupName);
    } catch (SQLException e) {
        throw new JobPersistenceException("Couldn't remove job: "
                + e.getMessage(), e);
    }
}
 
源代码4 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Get the names of all of the triggers that have misfired.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectMisfiredTriggers(Connection conn, long ts)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码5 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Select all of the triggers in a given state.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param state
 *          the state the triggers must be in
 * @return an array of trigger <code>Key</code> s
 */
public Key[] selectTriggersInState(Connection conn, String state)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_IN_STATE));
        ps.setString(1, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            list.add(new Key(rs.getString(1), rs.getString(2)));
        }

        Key[] sArr = (Key[]) list.toArray(new Key[list.size()]);
        return sArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码6 项目: AsuraFramework   文件: StdJDBCDelegate.java
public Key[] selectMisfiredTriggersInState(Connection conn, String state,
        long ts) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码7 项目: AsuraFramework   文件: StdJDBCDelegate.java
public List selectStatefulJobsOfTriggerGroup(Connection conn,
        String groupName) throws SQLException {
    ArrayList jobList = new ArrayList();
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn
                .prepareStatement(rtp(SELECT_STATEFUL_JOBS_OF_TRIGGER_GROUP));
        ps.setString(1, groupName);
        setBoolean(ps, 2, true);
        rs = ps.executeQuery();

        while (rs.next()) {
            jobList.add(new Key(rs.getString(COL_JOB_NAME), rs
                    .getString(COL_JOB_GROUP)));
        }
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }

    return jobList;
}
 
源代码8 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Select the trigger that will be fired at the given fire time.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param fireTime
 *          the time that the trigger will be fired
 * @return a <code>{@link org.quartz.utils.Key}</code> representing the
 *         trigger that will be fired at the given fire time, or null if no
 *         trigger will be fired at that time
 */
public Key selectTriggerForFireTime(Connection conn, long fireTime)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGER_FOR_FIRE_TIME));
        ps.setString(1, STATE_WAITING);
        ps.setBigDecimal(2, new BigDecimal(String.valueOf(fireTime)));
        rs = ps.executeQuery();

        if (rs.next()) {
            return new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP));
        } else {
            return null;
        }
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码9 项目: AsuraFramework   文件: StdJDBCDelegate.java
public Key[] selectVolatileTriggers(Connection conn) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_VOLATILE_TRIGGERS));
        setBoolean(ps, 1, true);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码10 项目: AsuraFramework   文件: StdJDBCDelegate.java
public Key[] selectVolatileJobs(Connection conn) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_VOLATILE_JOBS));
        setBoolean(ps, 1, true);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_JOB_NAME);
            String groupName = rs.getString(COL_JOB_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码11 项目: AsuraFramework   文件: JobChainingJobListener.java
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {

        Key sj = (Key) chainLinks.get(context.getJobDetail().getKey());

        if(sj == null) {
            return;
        }

        getLog().info("Job '" + context.getJobDetail().getFullName() + "' will now chain to Job '" + sj + "'");

        try {
            if(context.getJobDetail().isVolatile() || context.getTrigger().isVolatile()) {
                context.getScheduler().triggerJobWithVolatileTrigger(sj.getName(), sj.getGroup());
            } else {
                context.getScheduler().triggerJob(sj.getName(), sj.getGroup());
            }
        } catch(SchedulerException se) {
            getLog().error("Error encountered during chaining to Job '" + sj + "'", se);
        }
    }
 
源代码12 项目: spring-batch-rest   文件: JobParamsDetail.java
public JobParamsDetail(JobDetail jobDetail) {

		this.setJobClass(jobDetail.getJobClass());
		this.setDescription(jobDetail.getDescription());
		if (jobDetail.getKey() == null)
			this.setKey(new JobKey(Key.createUniqueName(null), null));
		this.setKey(jobDetail.getKey());
		this.setDurability(jobDetail.isDurable());
		this.setRequestsRecovery(jobDetail.requestsRecovery());

		if (!jobDetail.getJobDataMap().isEmpty())
			this.setJobDataMap(jobDetail.getJobDataMap());
	}
 
源代码13 项目: AsuraFramework   文件: JobStoreSupport.java
/**
 * <p>
 * Removes all volatile data.
 * </p>
 * 
 * @throws JobPersistenceException
 *           if jobs could not be recovered
 */
protected void cleanVolatileTriggerAndJobs(Connection conn)
    throws JobPersistenceException {
    try {
        // find volatile jobs & triggers...
        Key[] volatileTriggers = getDelegate().selectVolatileTriggers(conn);
        Key[] volatileJobs = getDelegate().selectVolatileJobs(conn);

        for (int i = 0; i < volatileTriggers.length; i++) {
            removeTrigger(conn, null, volatileTriggers[i].getName(),
                    volatileTriggers[i].getGroup());
        }
        getLog().info(
                "Removed " + volatileTriggers.length
                        + " Volatile Trigger(s).");

        for (int i = 0; i < volatileJobs.length; i++) {
            removeJob(conn, null, volatileJobs[i].getName(),
                    volatileJobs[i].getGroup(), true);
        }
        getLog().info(
                "Removed " + volatileJobs.length + " Volatile Job(s).");

        // clean up any fired trigger entries
        getDelegate().deleteVolatileFiredTriggers(conn);

    } catch (Exception e) {
        throw new JobPersistenceException("Couldn't clean volatile data: "
                + e.getMessage(), e);
    }
}
 
源代码14 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Get the names of all of the triggers in the given states that have
 * misfired - according to the given timestamp.  No more than count will
 * be returned.
 * </p>
 * 
 * @param conn The DB Connection
 * @param count The most misfired triggers to return, negative for all
 * @param resultList Output parameter.  A List of 
 *      <code>{@link org.quartz.utils.Key}</code> objects.  Must not be null.
 *          
 * @return Whether there are more misfired triggers left to find beyond
 *         the given count.
 */
public boolean selectMisfiredTriggersInStates(Connection conn, String state1, String state2,
    long ts, int count, List resultList) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_STATES));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state1);
        ps.setString(3, state2);
        rs = ps.executeQuery();

        boolean hasReachedLimit = false;
        while (rs.next() && (hasReachedLimit == false)) {
            if (resultList.size() == count) {
                hasReachedLimit = true;
            } else {
                String triggerName = rs.getString(COL_TRIGGER_NAME);
                String groupName = rs.getString(COL_TRIGGER_GROUP);
                resultList.add(new Key(triggerName, groupName));
            }
        }
        
        return hasReachedLimit;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码15 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Get the names of all of the triggers in the given group and state that
 * have misfired.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectMisfiredTriggersInGroupInState(Connection conn,
        String groupName, String state, long ts) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn
                .prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_GROUP_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, groupName);
        ps.setString(3, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码16 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Get the names of all of the triggers associated with the given job.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param jobName
 *          the name of the job
 * @param groupName
 *          the group containing the job
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectTriggerNamesForJob(Connection conn, String jobName,
        String groupName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_FOR_JOB));
        ps.setString(1, jobName);
        ps.setString(2, groupName);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList(10);
        while (rs.next()) {
            String trigName = rs.getString(COL_TRIGGER_NAME);
            String trigGroup = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(trigName, trigGroup));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码17 项目: AsuraFramework   文件: StdJDBCDelegate.java
/**
 * <p>
 * Select the next trigger which will fire to fire between the two given timestamps 
 * in ascending order of fire time, and then descending by priority.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param noLaterThan
 *          highest value of <code>getNextFireTime()</code> of the triggers (exclusive)
 * @param noEarlierThan 
 *          highest value of <code>getNextFireTime()</code> of the triggers (inclusive)
 *          
 * @return A (never null, possibly empty) list of the identifiers (Key objects) of the next triggers to be fired.
 */
public List selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    List nextTriggers = new LinkedList();
    try {
        ps = conn.prepareStatement(rtp(SELECT_NEXT_TRIGGER_TO_ACQUIRE));
        
        // Try to give jdbc driver a hint to hopefully not pull over 
        // more than the few rows we actually need.
        ps.setFetchSize(5);
        ps.setMaxRows(5);
        
        ps.setString(1, STATE_WAITING);
        ps.setBigDecimal(2, new BigDecimal(String.valueOf(noLaterThan)));
        ps.setBigDecimal(3, new BigDecimal(String.valueOf(noEarlierThan)));
        rs = ps.executeQuery();
        
        while (rs.next() && nextTriggers.size() < 5) {
            nextTriggers.add(new Key(
                    rs.getString(COL_TRIGGER_NAME),
                    rs.getString(COL_TRIGGER_GROUP)));
        }
        
        return nextTriggers;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }      
}
 
源代码18 项目: AsuraFramework   文件: StdJDBCDelegate.java
public List selectInstancesFiredTriggerRecords(Connection conn,
        String instanceName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        List lst = new LinkedList();

        ps = conn.prepareStatement(rtp(SELECT_INSTANCES_FIRED_TRIGGERS));
        ps.setString(1, instanceName);
        rs = ps.executeQuery();

        while (rs.next()) {
            FiredTriggerRecord rec = new FiredTriggerRecord();

            rec.setFireInstanceId(rs.getString(COL_ENTRY_ID));
            rec.setFireInstanceState(rs.getString(COL_ENTRY_STATE));
            rec.setFireTimestamp(rs.getLong(COL_FIRED_TIME));
            rec.setSchedulerInstanceId(rs.getString(COL_INSTANCE_NAME));
            rec.setTriggerIsVolatile(getBoolean(rs, COL_IS_VOLATILE));
            rec.setTriggerKey(new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP)));
            if (!rec.getFireInstanceState().equals(STATE_ACQUIRED)) {
                rec.setJobIsStateful(getBoolean(rs, COL_IS_STATEFUL));
                rec.setJobRequestsRecovery(rs
                        .getBoolean(COL_REQUESTS_RECOVERY));
                rec.setJobKey(new Key(rs.getString(COL_JOB_NAME), rs
                        .getString(COL_JOB_GROUP)));
            }
            rec.setPriority(rs.getInt(COL_PRIORITY));
            lst.add(rec);
        }

        return lst;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
源代码19 项目: AsuraFramework   文件: JobChainingJobListener.java
/**
 * Add a chain mapping - when the Job identified by the first key completes
 * the job identified by the second key will be triggered.
 *
 * @param firstJob a Key with the name and group of the first job
 * @param secondJob a Key with the name and group of the follow-up job
 */
public void addJobChainLink(Key firstJob, Key secondJob) {

    if(firstJob == null || secondJob == null) {
        throw new IllegalArgumentException("Key cannot be null!");
    }

    if(firstJob.getName() == null || secondJob.getName() == null) {
        throw new IllegalArgumentException("Key cannot have a null name!");
    }

    chainLinks.put(firstJob, secondJob);
}
 
源代码20 项目: nexus-public   文件: ReadEntityByKeyAction.java
@Nullable
public EntityT execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(key.getName(), key.getGroup());

  if (results.isEmpty()) {
    return null;
  }
  return adapter.readEntity(results.get(0));
}
 
源代码21 项目: nexus-public   文件: DeleteEntityByKeyAction.java
public boolean execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  int records = db.command(new OCommandSQL(query))
      .execute(key.getName(), key.getGroup());

  return records == 1;
}
 
源代码22 项目: nexus-public   文件: ExistsByKeyAction.java
public boolean execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(key.getName(), key.getGroup());

  return results.get(0).<Long>field("count") == 1;
}
 
源代码23 项目: lams   文件: AndMatcher.java
/**
 * Create an AndMatcher that depends upon the result of both of the given matchers.
 */
public static <U extends Key<?>> AndMatcher<U> and(Matcher<U> leftOperand, Matcher<U> rightOperand) {
    return new AndMatcher<U>(leftOperand, rightOperand);
}
 
源代码24 项目: lams   文件: NameMatcher.java
/**
 * Create a NameMatcher that matches names equaling the given string.
 */
public static <T extends Key<?>> NameMatcher<T> nameEquals(String compareTo) {
    return new NameMatcher<T>(compareTo, StringOperatorName.EQUALS);
}
 
源代码25 项目: lams   文件: NameMatcher.java
/**
 * Create a NameMatcher that matches names starting with the given string.
 */
public static <U extends Key<?>> NameMatcher<U> nameStartsWith(String compareTo) {
    return new NameMatcher<U>(compareTo, StringOperatorName.STARTS_WITH);
}
 
源代码26 项目: lams   文件: NameMatcher.java
/**
 * Create a NameMatcher that matches names ending with the given string.
 */
public static <U extends Key<?>> NameMatcher<U> nameEndsWith(String compareTo) {
    return new NameMatcher<U>(compareTo, StringOperatorName.ENDS_WITH);
}
 
源代码27 项目: lams   文件: NameMatcher.java
/**
 * Create a NameMatcher that matches names containing the given string.
 */
public static <U extends Key<?>> NameMatcher<U> nameContains(String compareTo) {
    return new NameMatcher<U>(compareTo, StringOperatorName.CONTAINS);
}
 
源代码28 项目: lams   文件: NotMatcher.java
/**
 * Create a NotMatcher that reverses the result of the given matcher.
 */
public static <U extends Key<?>> NotMatcher<U> not(Matcher<U> operand) {
    return new NotMatcher<U>(operand);
}
 
源代码29 项目: lams   文件: KeyMatcher.java
/**
 * Create a KeyMatcher that matches Keys that equal the given key. 
 */
public static <U extends Key<?>> KeyMatcher<U> keyEquals(U compareTo) {
    return new KeyMatcher<U>(compareTo);
}
 
源代码30 项目: lams   文件: GroupMatcher.java
/**
 * Create a GroupMatcher that matches groups equaling the given string.
 */
public static <T extends Key<T>> GroupMatcher<T> groupEquals(String compareTo) {
    return new GroupMatcher<T>(compareTo, StringOperatorName.EQUALS);
}
 
 类所在包
 类方法
 同包方法