org.axonframework.eventsourcing.annotation
Class AbstractAnnotatedAggregateRoot<I>

java.lang.Object
  extended by org.axonframework.domain.AbstractAggregateRoot<I>
      extended by org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot<I>
          extended by org.axonframework.eventsourcing.annotation.AbstractAnnotatedAggregateRoot<I>
Type Parameters:
I - The type of the identifier of this aggregate
All Implemented Interfaces:
Serializable, AggregateRoot<I>, EventSourcedAggregateRoot<I>
Direct Known Subclasses:
ToDoItem

@MappedSuperclass
public abstract class AbstractAnnotatedAggregateRoot<I>
extends AbstractEventSourcedAggregateRoot<I>

Convenience super type for aggregate roots that have their event handler methods annotated with the EventSourcingHandler annotation (and EventHandler for backwards compatibility).

Implementations can call the AbstractEventSourcedAggregateRoot.apply(Object) method to have an event applied.

Since:
0.1
Author:
Allard Buijze
See Also:
EventSourcingHandler, EventHandler, Serialized Form

Constructor Summary
AbstractAnnotatedAggregateRoot()
           
 
Method Summary
protected  ParameterResolverFactory createParameterResolverFactory()
          Creates (or returns) a ParameterResolverFactory which is used by this aggregate root to resolve the parameters for @EventSourcingHandler annotated methods.
protected  Collection<EventSourcedEntity> getChildEntities()
          Returns a collection of event sourced entities directly referenced by this entity.
 I getIdentifier()
          Returns the identifier of this aggregate.
protected  void handle(DomainEventMessage event)
          Calls the appropriate handler method with the provided event.
 void registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
          Registers the given parameterResolverFactory with this aggregate instance.
 
Methods inherited from class org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot
apply, apply, commitEvents, getVersion, initializeState, isLive
 
Methods inherited from class org.axonframework.domain.AbstractAggregateRoot
addEventRegistrationCallback, getLastCommittedEventSequenceNumber, getUncommittedEventCount, getUncommittedEvents, initializeEventStream, isDeleted, markDeleted, registerEvent, registerEvent, registerEventMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axonframework.domain.AggregateRoot
addEventRegistrationCallback, getUncommittedEventCount, getUncommittedEvents, isDeleted
 

Constructor Detail

AbstractAnnotatedAggregateRoot

public AbstractAnnotatedAggregateRoot()
Method Detail

handle

protected void handle(DomainEventMessage event)
Calls the appropriate handler method with the provided event.

Specified by:
handle in class AbstractEventSourcedAggregateRoot<I>
Parameters:
event - The event to handle
See Also:
EventSourcingHandler, EventHandler

getIdentifier

public I getIdentifier()
Description copied from interface: AggregateRoot
Returns the identifier of this aggregate.

Returns:
the identifier of this aggregate

getChildEntities

protected Collection<EventSourcedEntity> getChildEntities()
Description copied from class: AbstractEventSourcedAggregateRoot
Returns a collection of event sourced entities directly referenced by this entity. May return null or an empty list to indicate no child entities are available. The collection may also contain null values.

Events are propagated to the children in the order that the iterator of the return value provides.

Specified by:
getChildEntities in class AbstractEventSourcedAggregateRoot<I>
Returns:
a list of event sourced entities contained in this aggregate

createParameterResolverFactory

protected ParameterResolverFactory createParameterResolverFactory()
Creates (or returns) a ParameterResolverFactory which is used by this aggregate root to resolve the parameters for @EventSourcingHandler annotated methods.

Unless a specific ParameterResolverFactory has ben registered using registerParameterResolverFactory(org.axonframework.common.annotation.ParameterResolverFactory), this implementation uses the aggregate root's class loader to find parameter resolver factory implementations on the classpath.

Returns:
the parameter resolver with which to resolve parameters for event handler methods.
See Also:
ClasspathParameterResolverFactory

registerParameterResolverFactory

public void registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Registers the given parameterResolverFactory with this aggregate instance. This factory will provide the resolvers necessary for the @EventHandler and @EventSourcingHandler annoated metods in all members of this aggregate.

Parameters:
parameterResolverFactory - The factory to provide resolvers for parameters of annotated event handlers


Copyright © 2010-2016. All Rights Reserved.