⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jobstoretx.java

📁 定时器开源项目, 相对于 jcrontab, Quartz 算是更完整的一个项目, 随著开发的版本上来, 他已经脱离只是写在程序里面的计时器, 在指定的时间或区间, 处理所指定的事件. 也加入了 se
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     *      * <p>     * If removal of the <code>Trigger</code> results in an 'orphaned' <code>Job</code>     * that is not 'durable', then the <code>Job</code> should be deleted     * also.     * </p>     *      * @param triggerName     *          The name of the <code>Trigger</code> to be removed.     * @param groupName     *          The group name of the <code>Trigger</code> to be removed.     * @return <code>true</code> if a <code>Trigger</code> with the given     *         name & group was found and removed from the store.     */    public boolean removeTrigger(SchedulingContext ctxt, String triggerName,            String groupName) throws JobPersistenceException {        Connection conn = getConnection();        boolean transOwner = false;        try {            getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);            transOwner = true;            //getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);            boolean removed = removeTrigger(conn, ctxt, triggerName, groupName);            commitConnection(conn);            return removed;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);                      closeConnection(conn);        }    }    /**      * @see org.quartz.spi.JobStore#replaceTrigger(org.quartz.core.SchedulingContext, java.lang.String, java.lang.String, org.quartz.Trigger)     */    public boolean replaceTrigger(SchedulingContext ctxt, String triggerName, String groupName, Trigger newTrigger) throws JobPersistenceException {        Connection conn = getConnection();        boolean transOwner = false;        try {            getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);            transOwner = true;            //getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);            boolean removed = replaceTrigger(conn, ctxt, triggerName, groupName, newTrigger);            commitConnection(conn);            return removed;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);                      closeConnection(conn);        }    }            /**     * <p>     * Retrieve the given <code>{@link org.quartz.Trigger}</code>.     * </p>     *      * @param triggerName     *          The name of the <code>Trigger</code> to be retrieved.     * @param groupName     *          The group name of the <code>Trigger</code> to be retrieved.     * @return The desired <code>Trigger</code>, or null if there is no     *         match.     */    public Trigger retrieveTrigger(SchedulingContext ctxt, String triggerName,            String groupName) throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            Trigger trigger = retrieveTrigger(conn, ctxt, triggerName,                    groupName);            commitConnection(conn);            return trigger;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Store the given <code>{@link org.quartz.Calendar}</code>.     * </p>     *      * @param calName     *          The name of the calendar.     * @param calendar     *          The <code>Calendar</code> to be stored.     * @param replaceExisting     *          If <code>true</code>, any <code>Calendar</code> existing     *          in the <code>JobStore</code> with the same name & group     *          should be over-written.     * @throws ObjectAlreadyExistsException     *           if a <code>Calendar</code> with the same name already     *           exists, and replaceExisting is set to false.     */    public void storeCalendar(SchedulingContext ctxt, String calName,            Calendar calendar, boolean replaceExisting, boolean updateTriggers)            throws ObjectAlreadyExistsException, JobPersistenceException {        Connection conn = getConnection();        boolean lockOwner = false;        try {            if(isLockOnInsert() || updateTriggers) {                getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);                lockOwner = true;            }                        storeCalendar(conn, ctxt, calName, calendar, replaceExisting, updateTriggers);            commitConnection(conn);        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            releaseLock(conn, LOCK_TRIGGER_ACCESS, lockOwner);                      closeConnection(conn);        }    }    /**     * <p>     * Remove (delete) the <code>{@link org.quartz.Calendar}</code> with the     * given name.     * </p>     *      * <p>     * If removal of the <code>Calendar</code> would result in     * <code.Trigger</code>s pointing to non-existent calendars, then a     * <code>JobPersistenceException</code> will be thrown.</p>     *       *     * @param calName The name of the <code>Calendar</code> to be removed.     * @return <code>true</code> if a <code>Calendar</code> with the given name     * was found and removed from the store.     */    public boolean removeCalendar(SchedulingContext ctxt, String calName)            throws JobPersistenceException {        Connection conn = getConnection();        try {            getLockHandler().obtainLock(conn, LOCK_CALENDAR_ACCESS);            boolean removed = removeCalendar(conn, ctxt, calName);            commitConnection(conn);            return removed;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            releaseLock(conn, LOCK_CALENDAR_ACCESS, true);                      closeConnection(conn);        }    }    /**     * <p>     * Retrieve the given <code>{@link org.quartz.Trigger}</code>.     * </p>     *      * @param calName     *          The name of the <code>Calendar</code> to be retrieved.     * @return The desired <code>Calendar</code>, or null if there is no     *         match.     */    public Calendar retrieveCalendar(SchedulingContext ctxt, String calName)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            Calendar cal = retrieveCalendar(conn, ctxt, calName);            commitConnection(conn);            return cal;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    //---------------------------------------------------------------------------    // informational methods    //---------------------------------------------------------------------------    /**     * <p>     * Get the number of <code>{@link org.quartz.Job}</code> s that are     * stored in the <code>JobStore</code>.     * </p>     */    public int getNumberOfJobs(SchedulingContext ctxt)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            int numJobs = getNumberOfJobs(conn, ctxt);            commitConnection(conn);            return numJobs;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Get the number of <code>{@link org.quartz.Trigger}</code> s that are     * stored in the <code>JobsStore</code>.     * </p>     */    public int getNumberOfTriggers(SchedulingContext ctxt)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            int numTriggers = getNumberOfTriggers(conn, ctxt);            commitConnection(conn);            return numTriggers;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Get the number of <code>{@link org.quartz.Calendar}</code> s that are     * stored in the <code>JobsStore</code>.     * </p>     */    public int getNumberOfCalendars(SchedulingContext ctxt)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            int numCals = getNumberOfCalendars(conn, ctxt);            commitConnection(conn);            return numCals;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }        public Set getPausedTriggerGroups(SchedulingContext ctxt)         throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            Set groups = getPausedTriggerGroups(conn, ctxt);            commitConnection(conn);            return groups;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }        /**     * <p>     * Get the names of all of the <code>{@link org.quartz.Job}</code> s that     * have the given group name.     * </p>     *      * <p>     * If there are no jobs in the given group name, the result should be a     * zero-length array (not <code>null</code>).     * </p>     */    public String[] getJobNames(SchedulingContext ctxt, String groupName)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            String[] jobNames = getJobNames(conn, ctxt, groupName);            commitConnection(conn);            return jobNames;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Get the names of all of the <code>{@link org.quartz.Trigger}</code> s     * that have the given group name.     * </p>     *      * <p>     * If there are no triggers in the given group name, the result should be a     * zero-length array (not <code>null</code>).     * </p>     */    public String[] getTriggerNames(SchedulingContext ctxt, String groupName)            throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            String[] triggerNames = getTriggerNames(conn, ctxt, groupName);            commitConnection(conn);            return triggerNames;        } catch (JobPersistenceException e) {            rollbackConnection(conn);            throw e;        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Get the names of all of the <code>{@link org.quartz.Job}</code>     * groups.     * </p>     *      * <p>     * If there are no known group names, the result should be a zero-length     * array (not <code>null</code>).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -