Class CascadedStoreEvent<E extends CascadedStoreEvent<E>>

Object
EventObject
StoreEvent
CascadedStoreEvent<E>
Type Parameters:
E - the type of the event subclass.
All Implemented Interfaces:
Serializable, Localized
Direct Known Subclasses:
Close­Event

public abstract class CascadedStoreEvent<E extends CascadedStoreEvent<E>> extends StoreEvent
An event which, when occurring on a parent resource, is also fired by all children resources. For example, when an Aggregate (typically a data store) is closed, a Close­Event is automatically fired by all resources that are components of the aggregate. This is similar to "cascade delete" in SQL databases.

Difference between Store­Event and Cascaded­Store­Event

By default Store­Events are propagated from children to parents. For example, when a Warning­Event occurs in a child resource, all listeners registered on that resource are notified, then all listeners registered on the parent resource, and so forth until the root resource. All those listeners receive the same Warning­Event instance, i.e. the event source is always the resource where the warning occurred.

By contrast Cascaded­Store­Event are fired in the opposite direction, from parent to children. Furthermore, each child creates its own Cascaded­Store­Event. For example if a Close­Event is fired in a Data­Store, then it causes all resources of that data store to fire their own Close­Event declaring themselves as the event source.

Since:
1.3
See Also:
  • Constructor Details

    • CascadedStoreEvent

      protected CascadedStoreEvent(Resource source)
      Constructs an event that occurred in the given resource.
      Parameters:
      source - the resource where the event occurred.
      Throws:
      Illegal­Argument­Exception - if the given source is null.
  • Method Details

    • forSource

      protected abstract E forSource(Resource child)
      Creates a new event of the same type than this event but with a different source. This method is invoked for creating the event to be fired by the children of the resource where the original event occurred.
      Parameters:
      child - the child resource for which to create the event to cascade.
      Returns:
      an event of the same type than this event but with the given resource.