Class WorkEvent

  • All Implemented Interfaces:
    java.io.Serializable

    public class WorkEvent
    extends java.util.EventObject
    This class models the various events that occur during the processing of a Work instance.
    Version:
    1.0
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int DURATION_IDX  
      private WorkException e
      The exception that occured during Work processing.
      private static int EXCPEPTION_IDX  
      private static java.io.ObjectStreamField[] serialPersistentFields
      Persistence fields information
      private static long serialVersionUID
      Serial version uid
      private long startDuration
      The start delay duration (in milliseconds).
      private int type
      The event type.
      private static int TYPE_IDX  
      private Work work
      The Work object on which the event occured.
      static int WORK_ACCEPTED
      Indicates Work instance has been accepted.
      static int WORK_COMPLETED
      Indicates Work instance has completed execution.
      private static int WORK_IDX  
      static int WORK_REJECTED
      Indicates Work instance has been rejected.
      static int WORK_STARTED
      Indicates Work instance has started execution.
      • Fields inherited from class java.util.EventObject

        source
    • Constructor Summary

      Constructors 
      Constructor Description
      WorkEvent​(java.lang.Object source, int type, Work work, WorkException exc)
      Constructor.
      WorkEvent​(java.lang.Object source, int type, Work work, WorkException exc, long startDuration)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WorkException getException()
      Return the WorkException.
      long getStartDuration()
      Return the start interval duration.
      int getType()
      Return the type of this event.
      Work getWork()
      Return the Work instance which is the cause of the event.
      private void readObject​(java.io.ObjectInputStream ois)
      Read object
      private void writeObject​(java.io.ObjectOutputStream oos)
      Write object
      • Methods inherited from class java.util.EventObject

        getSource, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serial version uid
      • serialPersistentFields

        private static final java.io.ObjectStreamField[] serialPersistentFields
        Persistence fields information
      • WORK_ACCEPTED

        public static final int WORK_ACCEPTED
        Indicates Work instance has been accepted.
        See Also:
        Constant Field Values
      • WORK_REJECTED

        public static final int WORK_REJECTED
        Indicates Work instance has been rejected.
        See Also:
        Constant Field Values
      • WORK_STARTED

        public static final int WORK_STARTED
        Indicates Work instance has started execution.
        See Also:
        Constant Field Values
      • WORK_COMPLETED

        public static final int WORK_COMPLETED
        Indicates Work instance has completed execution.
        See Also:
        Constant Field Values
      • type

        private int type
        The event type.
      • work

        private Work work
        The Work object on which the event occured.
      • e

        private WorkException e
        The exception that occured during Work processing.
      • startDuration

        private long startDuration
        The start delay duration (in milliseconds).
    • Constructor Detail

      • WorkEvent

        public WorkEvent​(java.lang.Object source,
                         int type,
                         Work work,
                         WorkException exc)
        Constructor.
        Parameters:
        source - The object on which the event initially occurred.
        type - The event type.
        work - The Work object on which the event occured.
        exc - The exception that occured during Work processing.
      • WorkEvent

        public WorkEvent​(java.lang.Object source,
                         int type,
                         Work work,
                         WorkException exc,
                         long startDuration)
        Constructor.
        Parameters:
        source - The object on which the event initially occurred.
        type - The event type.
        work - The Work object on which the event occured.
        exc - The exception that occured during Work processing.
        startDuration - The start delay duration (in milliseconds).
    • Method Detail

      • getType

        public int getType()
        Return the type of this event.
        Returns:
        the event type.
      • getWork

        public Work getWork()
        Return the Work instance which is the cause of the event.
        Returns:
        the Work instance.
      • getStartDuration

        public long getStartDuration()
        Return the start interval duration.
        Returns:
        the time elapsed (in milliseconds) since the Work was accepted, until the Work execution started. Note, this does not offer real-time guarantees. It is valid to return -1, if the actual start interval duration is unknown.
      • getException

        public WorkException getException()
        Return the WorkException. The actual WorkException subtype returned depends on the type of the event.
        Returns:
        a WorkRejectedException or a WorkCompletedException, if any.
      • readObject

        private void readObject​(java.io.ObjectInputStream ois)
                         throws java.lang.ClassNotFoundException,
                                java.io.IOException
        Read object
        Parameters:
        ois - The object input stream
        Throws:
        java.lang.ClassNotFoundException - If a class can not be found
        java.io.IOException - Thrown if an error occurs
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream oos)
                          throws java.io.IOException
        Write object
        Parameters:
        oos - The object output stream
        Throws:
        java.io.IOException - Thrown if an error occurs