Class CascadedStoreEvent<E extends CascadedStoreEvent<E>>

java.lang.Object
java.util.EventObject
org.apache.sis.storage.event.StoreEvent
org.apache.sis.storage.event.CascadedStoreEvent<E>
Type Parameters:
E - the type of the event subclass.
All Implemented Interfaces:
Serializable, Localized
Direct Known Subclasses:
CloseEvent

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 CloseEvent is automatically fired by all resources that are components of the aggregate. This is similar to "cascade delete" in SQL databases.

Difference between StoreEvent and CascadedStoreEvent

By default StoreEvents are propagated from children to parents. For example, when a WarningEvent 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 WarningEvent instance, i.e. the event source is always the resource where the warning occurred.

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

Since:
1.3
Version:
1.3
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      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:
      IllegalArgumentException - 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.