org.axonframework.eventsourcing
Class AbstractEventSourcedEntity

java.lang.Object
  extended by org.axonframework.eventsourcing.AbstractEventSourcedEntity
Direct Known Subclasses:
AbstractAnnotatedEntity

public abstract class AbstractEventSourcedEntity
extends Object

Base class for Event Sourced entities that are not at the root of the aggregate. Instead of keeping track of uncommitted events themselves, these entities refer to their aggregate root to do that for them. A DomainEvent published in any of the entities in an Aggregate is published to all entities in the entire aggregate.

Since:
0.7
Author:
Allard Buijze

Constructor Summary
AbstractEventSourcedEntity()
           
 
Method Summary
protected  void apply(DomainEvent event)
          Apply the provided event.
protected  Collection<AbstractEventSourcedEntity> getChildEntities()
          Returns a list of event sourced entities directly referenced by this entity.
protected abstract  void handle(DomainEvent event)
          Apply state changes based on the given event.
protected  void registerAggregateRoot(AbstractEventSourcedAggregateRoot aggregateRootToRegister)
          Register the aggregate root with this entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEventSourcedEntity

public AbstractEventSourcedEntity()
Method Detail

getChildEntities

protected Collection<AbstractEventSourcedEntity> getChildEntities()
Returns a list of event sourced entities directly referenced by this entity.

The default implementation uses reflection to find references to AbstractEventSourcedEntity implementations.

It will look for them in the following locations:

Returns:
a list of event sourced entities contained in this aggregate

registerAggregateRoot

protected void registerAggregateRoot(AbstractEventSourcedAggregateRoot aggregateRootToRegister)
Register the aggregate root with this entity. The entity uses this aggregate root to report applied Domain Events. The aggregate root is responsible for tracking all applied events.

A parent entity is responsible for invoking this method on its child entities prior to propagating events to it. Typically, this means all entities have their aggregate root set before any actions are taken on it.

Parameters:
aggregateRootToRegister - the root of the aggregate this entity is part of.

handle

protected abstract void handle(DomainEvent event)
Apply state changes based on the given event.

Note: Implementations of this method should *not* perform validation.

Parameters:
event - The event to handle

apply

protected void apply(DomainEvent event)
Apply the provided event. Applying events means they are added to the uncommitted event queue and forwarded to the handle(DomainEvent) event handler method} for processing.

Note that all entities part of the aggregate that this entity is part of are notified of the event.

Parameters:
event - The event to apply


Copyright © 2011. All Rights Reserved.