Class CronTask<T>

  • Type Parameters:
    T - the type of the Task
    All Implemented Interfaces:
    Task<T>, com.oracle.coherence.concurrent.executor.TaskExecutorService.Registration.Option, ExternalizableLite, PortableObject, Serializable

    public class CronTask<T>
    extends Object
    implements Task<T>, PortableObject, com.oracle.coherence.concurrent.executor.TaskExecutorService.Registration.Option
    A Task that can run repeatedly at scheduled time, like a crontab job.
    Since:
    21.12
    Author:
    lh, bo
    See Also:
    Serialized Form
    • Field Detail

      • m_origTask

        protected Task<T> m_origTask
        The original Task.
      • m_task

        protected Task<T> m_task
        The actual Task.
      • m_sCronPattern

        protected String m_sCronPattern
        The crontab scheduling pattern for the Task.
      • m_ldtNextExecutionMillis

        protected long m_ldtNextExecutionMillis
        The next execution time.
      • m_fClone

        protected boolean m_fClone
        Flag indicating whether the task should be cloned after each execution;
    • Constructor Detail

      • CronTask

        public CronTask()
        Constructs a CronTask (required for serialization).
      • CronTask

        public CronTask​(Task<T> task,
                        String sPattern)
        Constructs a CronTask.
        Parameters:
        task - the task
        sPattern - the crontab scheduling pattern
      • CronTask

        public CronTask​(Task<T> task,
                        String sPattern,
                        boolean fClone)
        Constructs a CronTask.
        Parameters:
        task - the task
        sPattern - the crontab scheduling pattern
        fClone - true (the default) if the given Task should be cloned after each successful execution
    • Method Detail

      • getCronPattern

        public String getCronPattern()
        Returns the crontab schedule pattern.
        Returns:
        the crontab schedule pattern
      • getNextExecutionMillis

        public long getNextExecutionMillis​(long cMillis)
        Returns the next execution time in milliseconds.
        Parameters:
        cMillis - The timestamp, as a UNIX-era millis value.
        Returns:
        the next execution time in milliseconds
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Description copied from interface: ExternalizableLite
        Restore the contents of this object by loading the object's state from the passed DataInput object.
        Specified by:
        readExternal in interface ExternalizableLite
        Parameters:
        in - the DataInput stream to read data from in order to restore the state of this object
        Throws:
        IOException - if an I/O exception occurs
        NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Description copied from interface: ExternalizableLite
        Save the contents of this object by storing the object's state into the passed DataOutput object.
        Specified by:
        writeExternal in interface ExternalizableLite
        Parameters:
        out - the DataOutput stream to write the state of this object to
        Throws:
        IOException - if an I/O exception occurs
      • readExternal

        public void readExternal​(PofReader in)
                          throws IOException
        Description copied from interface: PortableObject
        Restore the contents of a user type instance by reading its state using the specified PofReader object.
        Specified by:
        readExternal in interface PortableObject
        Parameters:
        in - the PofReader from which to read the object's state
        Throws:
        IOException - if an I/O error occurs
      • writeExternal

        public void writeExternal​(PofWriter out)
                           throws IOException
        Description copied from interface: PortableObject
        Save the contents of a POF user type instance by writing its state using the specified PofWriter object.
        Specified by:
        writeExternal in interface PortableObject
        Parameters:
        out - the PofWriter to which to write the object's state
        Throws:
        IOException - if an I/O error occurs
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • clone

        public static Object clone​(Object object)
        Creates a clone of the given object.
        Parameters:
        object - the object to clone
        Returns:
        the cloned object
      • of

        public static <T> CronTask<T> of​(Task<T> task,
                                         String sCronPattern)
        Obtains a CronTask.
        Type Parameters:
        T - the type of the Task
        Parameters:
        task - the task to be scheduled
        sCronPattern - the task schedule pattern
        Returns:
        a CronTask
      • of

        public static <T> CronTask<T> of​(Task<T> task,
                                         String sCronPattern,
                                         boolean fClone)
        Obtains a CronTask.
        Type Parameters:
        T - the type of the Task
        Parameters:
        task - the task to be scheduled
        sCronPattern - the task schedule pattern
        fClone - should the task be cloned after each successful task execution
        Returns:
        a CronTask