java.lang.Object
com.oracle.coherence.concurrent.executor.tasks.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:
  • Field Details

    • 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.
  • Constructor Details

    • 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
  • Method Details

    • getTask

      public Task<T> getTask()
      Obtains the CronTask.
      Returns:
      the CronTask
    • 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
    • execute

      public T execute(Task.Context<T> context) throws Exception
      Description copied from interface: Task
      Executes the Task.
      Specified by:
      execute in interface Task<T>
      Parameters:
      context - the Task.Context
      Returns:
      the result of executing the Task
      Throws:
      Exception
    • 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
    • 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
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString 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