org.mule.routing
Class EventGroup

java.lang.Object
  extended by org.mule.routing.EventGroup
All Implemented Interfaces:
Serializable, Comparable<EventGroup>, DeserializationPostInitialisable

public class EventGroup
extends Object
implements Comparable<EventGroup>, Serializable, DeserializationPostInitialisable

EventGroup is a holder over events grouped by a common group Id. This can be used by components such as routers to managed related events.

See Also:
Serialized Form

Nested Class Summary
 class EventGroup.ArrivalOrderEventComparator
           
 class EventGroup.ArrivalOrderMessageComparator
           
 
Nested classes/interfaces inherited from interface org.mule.util.store.DeserializationPostInitialisable
DeserializationPostInitialisable.Implementation
 
Field Summary
static String DEFAULT_STORE_PREFIX
           
static MuleEvent[] EMPTY_EVENTS_ARRAY
           
static String MULE_ARRIVAL_ORDER_PROPERTY
           
 
Constructor Summary
EventGroup(Object groupId, MuleContext muleContext)
           
EventGroup(Object groupId, MuleContext muleContext, int expectedSize, boolean storeIsPersistent, String storePrefix)
           
 
Method Summary
 void addEvent(MuleEvent event)
          Add the given event to this group.
 void clear()
          Removes all events from this group.
 int compareTo(EventGroup other)
          Compare this EventGroup to another one.
 boolean equals(Object obj)
          Compares two EventGroups for equality.
 int expectedSize()
          Returns the number of events that this EventGroup is expecting before correlation can proceed.
 String getCommonRootId()
           
 long getCreated()
          Return the creation timestamp of the current group in milliseconds.
 Object getGroupId()
          Returns an identifier for this EventGroup.
protected  MuleSession getMergedSession()
           
 MuleEvent getMessageCollectionEvent()
           
 int hashCode()
          The hashCode of an EventGroup is derived from the object returned by getGroupId().
 void initAfterDeserialisation(MuleContext context)
           
 boolean isInitialised()
           
 Iterator<MuleEvent> iterator()
          Returns an iterator over a snapshot copy of this group's collected events sorted by their arrival time.
 Iterator<MuleEvent> iterator(boolean sortByArrival)
          Returns an iterator over a snapshot copy of this group's collected events., optionally sorted by arrival order.
 void removeEvent(MuleEvent event)
          Remove the given event from the group.
 int size()
          Returns the number of events collected so far.
 MuleEvent[] toArray()
          Returns a snapshot of collected events in this group sorted by their arrival time.
 MuleEvent[] toArray(boolean sortByArrival)
          Returns a snapshot of collected events in this group, optionally sorted by their arrival time.
 MuleMessageCollection toMessageCollection()
           
 MuleMessageCollection toMessageCollection(boolean sortByArrival)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_EVENTS_ARRAY

public static final MuleEvent[] EMPTY_EVENTS_ARRAY

MULE_ARRIVAL_ORDER_PROPERTY

public static final String MULE_ARRIVAL_ORDER_PROPERTY
See Also:
Constant Field Values

DEFAULT_STORE_PREFIX

public static final String DEFAULT_STORE_PREFIX
See Also:
Constant Field Values
Constructor Detail

EventGroup

public EventGroup(Object groupId,
                  MuleContext muleContext)

EventGroup

public EventGroup(Object groupId,
                  MuleContext muleContext,
                  int expectedSize,
                  boolean storeIsPersistent,
                  String storePrefix)
Method Detail

compareTo

public int compareTo(EventGroup other)
Compare this EventGroup to another one. If the receiver and the argument both have groupIds that are Comparable, they are used for the comparison; otherwise - since the id can be any object - the group creation time stamp is used as fallback. Older groups are considered "smaller".

Specified by:
compareTo in interface Comparable<EventGroup>
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object obj)
Compares two EventGroups for equality. EventGroups are considered equal if their groupIds (as returned by getGroupId()) are equal.

Overrides:
equals in class Object
See Also:
Object.equals(Object)

hashCode

public int hashCode()
The hashCode of an EventGroup is derived from the object returned by getGroupId().

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

getGroupId

public Object getGroupId()
Returns an identifier for this EventGroup. It is recommended that this id is unique and Comparable e.g. a UUID.

Returns:
the id of this event group

iterator

public Iterator<MuleEvent> iterator()
                             throws ObjectStoreException
Returns an iterator over a snapshot copy of this group's collected events sorted by their arrival time. If you need to iterate over the group and e.g. remove select events, do so via removeEvent(MuleEvent). If you need to do so atomically in order to prevent e.g. concurrent reception/aggregation of the group during iteration, wrap the iteration in a synchronized block on the group instance.

Returns:
an iterator over collected MuleEvents.
Throws:
ObjectStoreException

iterator

public Iterator<MuleEvent> iterator(boolean sortByArrival)
                             throws ObjectStoreException
Returns an iterator over a snapshot copy of this group's collected events., optionally sorted by arrival order. If you need to iterate over the group and e.g. remove select events, do so via removeEvent(MuleEvent). If you need to do so atomically in order to prevent e.g. concurrent reception/aggregation of the group during iteration, wrap the iteration in a synchronized block on the group instance.

Returns:
an iterator over collected MuleEvents.
Throws:
ObjectStoreException

toArray

public MuleEvent[] toArray()
                    throws ObjectStoreException
Returns a snapshot of collected events in this group sorted by their arrival time.

Returns:
an array of collected MuleEvents.
Throws:
ObjectStoreException

toArray

public MuleEvent[] toArray(boolean sortByArrival)
                    throws ObjectStoreException
Returns a snapshot of collected events in this group, optionally sorted by their arrival time.

Returns:
an array of collected MuleEvents.
Throws:
ObjectStoreException

addEvent

public void addEvent(MuleEvent event)
              throws ObjectStoreException
Add the given event to this group.

Parameters:
event - the event to add
Throws:
ObjectStoreException

removeEvent

public void removeEvent(MuleEvent event)
                 throws ObjectStoreException
Remove the given event from the group.

Parameters:
event - the evnt to remove
Throws:
ObjectStoreException

getCreated

public long getCreated()
Return the creation timestamp of the current group in milliseconds.

Returns:
the timestamp when this group was instantiated.

size

public int size()
Returns the number of events collected so far.

Returns:
number of events in this group or 0 if the group is empty.

expectedSize

public int expectedSize()
Returns the number of events that this EventGroup is expecting before correlation can proceed.

Returns:
expected number of events or -1 if no expected size was specified.

clear

public void clear()
           throws ObjectStoreException
Removes all events from this group.

Throws:
ObjectStoreException

toString

public String toString()
Overrides:
toString in class Object

toMessageCollection

public MuleMessageCollection toMessageCollection()
                                          throws ObjectStoreException
Throws:
ObjectStoreException

toMessageCollection

public MuleMessageCollection toMessageCollection(boolean sortByArrival)
                                          throws ObjectStoreException
Throws:
ObjectStoreException

getCommonRootId

public String getCommonRootId()

getMessageCollectionEvent

public MuleEvent getMessageCollectionEvent()

getMergedSession

protected MuleSession getMergedSession()
                                throws ObjectStoreException
Throws:
ObjectStoreException

initAfterDeserialisation

public void initAfterDeserialisation(MuleContext context)
                              throws MuleException
Throws:
MuleException

isInitialised

public boolean isInitialised()


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.