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

📄 jobstorecmt.java

📁 定时器开源项目, 相对于 jcrontab, Quartz 算是更完整的一个项目, 随著开发的版本上来, 他已经脱离只是写在程序里面的计时器, 在指定的时间或区间, 处理所指定的事件. 也加入了 se
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            closeConnection(conn);        }    }    /**     * <p>     * Retrieve the <code>{@link org.quartz.JobDetail}</code> for the given     * <code>{@link org.quartz.Job}</code>.     * </p>     *      * @param jobName     *          The name of the <code>Job</code> to be retrieved.     * @param groupName     *          The group name of the <code>Job</code> to be retrieved.     * @return The desired <code>Job</code>, or null if there is no match.     */    public JobDetail retrieveJob(SchedulingContext ctxt, String jobName,            String groupName) throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            return retrieveJob(conn, ctxt, jobName, groupName);        } finally {            closeConnection(conn);        }    }    /**     * <p>     * Store the given <code>{@link org.quartz.Trigger}</code>.     * </p>     *      * @param newTrigger     *          The <code>Trigger</code> to be stored.     * @param replaceExisting     *          If <code>true</code>, any <code>Trigger</code> existing in     *          the <code>JobStore</code> with the same name & group should     *          be over-written.     * @throws ObjectAlreadyExistsException     *           if a <code>Trigger</code> with the same name/group already     *           exists, and replaceExisting is set to false.     */    public void storeTrigger(SchedulingContext ctxt, Trigger newTrigger,            boolean replaceExisting) throws ObjectAlreadyExistsException,            JobPersistenceException {        Connection conn = getConnection();        boolean transOwner = false;        try {            if(isLockOnInsert() || replaceExisting) {                getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);                transOwner = true;            }            storeTrigger(conn, ctxt, newTrigger, null, replaceExisting,                    STATE_WAITING, false, false);        } finally {            releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);                      closeConnection(conn);        }    }    /**     * <p>     * Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the     * given name.     * </p>     *      * <p>     * If removal of the <code>Trigger</code> results in an empty group, the     * group should be removed from the <code>JobStore</code>'s list of     * known group names.     * </p>     *      * <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;            return removeTrigger(conn, ctxt, triggerName, groupName);        } 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;            return replaceTrigger(conn, ctxt, triggerName, groupName, newTrigger);        } 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...            return retrieveTrigger(conn, ctxt, triggerName, groupName);        } 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);        } 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);            return removeCalendar(conn, ctxt, calName);        } 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...            return retrieveCalendar(conn, ctxt, calName);        } 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...            return getNumberOfJobs(conn, ctxt);        } 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...            return getNumberOfTriggers(conn, ctxt);        } 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...            return getNumberOfCalendars(conn, ctxt);        } finally {            closeConnection(conn);        }    }    public Set getPausedTriggerGroups(SchedulingContext ctxt)     throws JobPersistenceException {        Connection conn = getConnection();        try {            // no locks necessary for read...            Set groups = getPausedTriggerGroups(conn, ctxt);            return groups;        } 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...            return getJobNames(conn, ctxt, groupName);        } 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...            return getTriggerNames(conn, ctxt, groupName);        } 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>).     * </p>     */    public String[] getJobGroupNames(SchedulingContext ctxt)

⌨️ 快捷键说明

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