    001    package org.apache.turbine.services.schedule;
    002
    003    /*
    004     * Licensed to the Apache Software Foundation (ASF) under one
    005     * or more contributor license agreements.  See the NOTICE file
    006     * distributed with this work for additional information
    007     * regarding copyright ownership.  The ASF licenses this file
    008     * to you under the Apache License, Version 2.0 (the
    009     * "License"); you may not use this file except in compliance
    010     * with the License.  You may obtain a copy of the License at
    011     *
    012     *   http://www.apache.org/licenses/LICENSE-2.0
    013     *
    014     * Unless required by applicable law or agreed to in writing,
    015     * software distributed under the License is distributed on an
    016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017     * KIND, either express or implied.  See the License for the
    018     * specific language governing permissions and limitations
    019     * under the License.
    020     */
    021
    022
    023    import java.util.Date;
    024
    025    import org.apache.torque.om.Persistent;
    026    import org.apache.turbine.util.TurbineException;
    027
    028    /**
    029     * This is a interface for a scheduled job. It does not specify how to
    030     * configure when to run, that is left to subclasses.  See the JobEntryTorque
    031     * for an example of a JobEntry backed by Torque objects.
    032     *
    033     * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    034     * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
    035     * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
    036     * @version $Id: JobEntryInterface.java 1066938 2011-02-03 20:14:53Z ludwig $
    037     */
    038    public interface JobEntryInterface extends Comparable<JobEntry>, Persistent
    039    {
    040
    041        /**
    042             * Used for ordering Jobentries Note: this comparator imposes orderings
    043             * that are inconsistent with equals.
    044             *
    045             * @param je The first <code>JobEntry</code> object.
    046             * @return An <code>int</code> indicating the result of the comparison.
    047             */
    048        public int compareTo(Object je);
    049
    050        /**
    051             * Sets whether the job is running.
    052             *
    053             * @param isActive Whether the job is running.
    054             */
    055        public void setActive(boolean isActive);
    056
    057        /**
    058             * Check to see if job is currently active/running
    059             *
    060             * @return true if job is currently being run by the workerthread,
    061             *         otherwise false
    062             */
    063        public boolean isActive();
    064
    065
    066            /**
    067             * Get the Task
    068             *
    069             * @return String
    070             */
    071            public String getTask();
    072
    073            /**
    074              * Set the value of Task
    075              *
    076              * @param v new value
    077              */
    078             public void setTask(String v);
    079        /**
    080             * Get the next runtime for this job as a long.
    081             *
    082             * @return The next run time as a long.
    083             */
    084        public long getNextRuntime();
    085
    086        /**
    087             * Gets the next runtime as a date
    088             *
    089             * @return Next run date
    090             */
    091        public Date getNextRunDate();
    092
    093        /**
    094             * Get the next runtime for this job as a String.
    095             *
    096             * @return The next run time as a String.
    097             */
    098        public String getNextRunAsString();
    099
    100        /**
    101             * Calculate how long before the next runtime. <br>
    102             *
    103             * The runtime determines it's position in the job queue. Here's the logic:
    104             * <br>
    105             *  1. Create a date the represents when this job is to run. <br>
    106             *  2. If this date has expired, them "roll" appropriate date fields
    107             * forward to the next date. <br>
    108             *  3. Calculate the diff in time between the current time and the next run
    109             * time. <br>
    110             *
    111             * @exception TurbineException a generic exception.
    112             */
    113        public void calcRunTime() throws TurbineException;
    114
    115    }