Class Event

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    Location

    public abstract class Event
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    Abstract base class for a Java object that will be treated as an Apama event inside the Correlator, with a public Java field for each field of the event.

    For example, for an Apama event type definition:
    MyEvent {
    integer i1;
    sequence<float> seq1;
    dictionary<string, MyEvent2> dict1;
    OtherEvent other;
    }
    the corresponding Event subclass in Java would have fields:
    public long i1;
    public double[] seq1;
    public Map<String, MyEvent2> dict1;
    public OtherEvent other;

    Note that in the current release of Apama, the Event's constructor will automatically assign the EPL default value (0, "", empty array, new event objects) to every public field not already assigned a value by an initializer to ensure that everything is initialized to a non-null value by the time the subclass constructor is invoked. (EPL does not support null values and event instances containing them cannot be sent out of a Java application)

    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      void emit()
      Emit this Event from the Engine on the default channel.
      void emit​(java.lang.String channel)
      Emit this Event from the Engine on a specific channel.
      void enqueue()
      Enqueue this Event internally within the Correlator.
      void enqueueTo​(Context ctx)
      Enqueue this event to a correlator context.
      void enqueueTo​(Context[] ctxArray)
      Enqueue this event to an array of correlator contexts.
      void enqueueTo​(java.util.List<Context> ctxList)
      Enqueue this event to a list of correlator contexts.
      boolean equals​(java.lang.Object other)
      Override Object.equals() to check equality based upon the field values of the instance.
      int[] getFieldAttributes​(java.lang.String fieldName)
      Deprecated.
      This method has been deprecated and may be removed in a future release - Please use the new JMon annotations instead.
      java.lang.Class[] getMapFieldTypes​(java.lang.String fieldName)
      This method should be overridden in any subclass that has fields of type Map.
      java.lang.String getName()
      Get the Correlator name for this Event subclass instance.
      static java.lang.String getName​(java.lang.Class eventSubClass)
      Get the Correlator name for the specified Event subclass.
      double getTime()
      Get the time that the event arrived at the correlator.
      int hashCode()
      Override Object.hashCode() to provide a hash code that is based upon the field values of the instance.
      boolean isExternal()
      Determine if this is an "external" event - if it originated outside the correlator.
      void route()
      Route this Event internally within the Correlator.
      java.lang.String toString()
      Override Object.toString() to provide output compatible with the Apama standard representation of Event data types.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • clone

        public java.lang.Object clone()
      • emit

        public void emit()
        Emit this Event from the Engine on the default channel.
      • emit

        public void emit​(java.lang.String channel)
        Emit this Event from the Engine on a specific channel.
        Parameters:
        channel - the Channel on which the Event is to be emitted from the Engine.
      • route

        public void route()
        Route this Event internally within the Correlator.
      • enqueue

        public void enqueue()
        Enqueue this Event internally within the Correlator.
      • enqueueTo

        public void enqueueTo​(Context ctx)
        Enqueue this event to a correlator context. This method provides the functionality of "enqueue ... to" statement in MonitorScript. When this method is called from an application thread that is created from the main JMon application and the destination context input queue is full, then the method will block until the queue is able to accept the event.
        Parameters:
        ctx - the destination context where the event will be enqueued to.
      • enqueueTo

        public void enqueueTo​(Context[] ctxArray)
        Enqueue this event to an array of correlator contexts. See the notes about Event.enqueue(Context ctx).
        Parameters:
        ctxArray - the array of destination contexts where the event will be enqueued to.
      • enqueueTo

        public void enqueueTo​(java.util.List<Context> ctxList)
        Enqueue this event to a list of correlator contexts. See the notes about Event.enqueue(Context ctx).
        Parameters:
        ctxList - the list of destination contexts where the event will be enqueued to.
      • getFieldAttributes

        @Deprecated
        public int[] getFieldAttributes​(java.lang.String fieldName)
        Deprecated.
        This method has been deprecated and may be removed in a future release - Please use the new JMon annotations instead.
        [Deprecated] This method should be overridden in any subclass that requires fields to be tagged with extra attributes. e.g. If a subclass has a member field with the name "payload" and that field should be treated by the correlator as a Wildcard, then the method body should be implemented as follows:
                public static int[] getFieldAttributes(String fieldName) {
                        int[] attributes = null;
                        if (fieldName.equals("payload"))
                                attributes = new int[]{EventFieldAttributes.WILDCARD};
                        return attributes;
                }
          
        Parameters:
        fieldName - the name of the member field whose attributes are to be checked.
        Returns:
        An int array of EventFieldAttribute items to specify the attributes of a single field.
        See Also:
        Wildcard
      • getMapFieldTypes

        public java.lang.Class[] getMapFieldTypes​(java.lang.String fieldName)
        This method should be overridden in any subclass that has fields of type Map.

        This method is required because the key and value are typed in MonitorScript dictionary container type. In MonitorScript, the key and value types are declared in syntax resembling generic or template programming. However, the standard Java language and container libraries do not yet support generics and so this light-weight mechanism has been chosen in the interim.

        e.g. If a subclass has a member field with the name "myDictionary" and that field should be treated as the correlator type "dictionary < integer, string >", then the field should be declared as a java.util.Map, and the getMapFieldTypes method should be overriden as shown below:

                public Class[] getMapFieldTypes(String fieldName) {
                        Class[] types = null;
                        if (fieldName.equals("myDictionary"))
                                types = new Class[]{Long.TYPE, String.class};
                        return types;
                }
          
        Parameters:
        fieldName - the name of the member field whose attributes are to be checked.
        Returns:
        A two element Class array, where the first element identifies the key type, and the second element identifies the value type.
      • toString

        public java.lang.String toString()
        Override Object.toString() to provide output compatible with the Apama standard representation of Event data types. If you are using objects that contain cycles in the object graph, you must override toString.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation of the Event. e.g. "mynamespace.MyEvent(\"MyString\",1,2.0,true)"
      • hashCode

        public int hashCode()
        Override Object.hashCode() to provide a hash code that is based upon the field values of the instance.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        Hash code for the Event instance.
      • equals

        public boolean equals​(java.lang.Object other)
        Override Object.equals() to check equality based upon the field values of the instance.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other - The object to be compared for equality.
        Returns:
        True if the instances are equal.
      • getName

        public static java.lang.String getName​(java.lang.Class eventSubClass)
        Get the Correlator name for the specified Event subclass. This will supply the name that was specified in the deployment descriptor. If the Class is not an event, then null will be returned.
        Parameters:
        eventSubClass - This is the class for the event type for which the name is required.
        Returns:
        The Correlator name for the specified Event subclass, or null in case of error.
      • getName

        public java.lang.String getName()
        Get the Correlator name for this Event subclass instance. This will supply the name that was specified in the deployment descriptor.
        Returns:
        The Correlator name for this Event subclass instance, or null in case of error.
      • getTime

        public double getTime()
        Get the time that the event arrived at the correlator.
        Returns:
        The time since the epoch that the event arrived at the correlator
      • isExternal

        public boolean isExternal()
        Determine if this is an "external" event - if it originated outside the correlator. This method will only return true if the even was sent into the correlator by some external process and that event was then passed into the JMon application.
        Returns:
        true if the event is external, false otherwise.