org.axonframework.eventsourcing.annotation
Class AggregateAnnotationInspector

java.lang.Object
  extended by org.axonframework.eventsourcing.annotation.AggregateAnnotationInspector

public final class AggregateAnnotationInspector
extends Object

Inspects objects to find aggregate specific annotations, such as AggregateIdentifier and EventSourcedMember. The inspector can also create MessageHandlerInvoker instances to invoke EventSourcingHandler annotated methods.

Since:
2.0
Author:
Allard Buijze
See Also:
EventSourcingHandler, EventHandler

Method Summary
 MessageHandlerInvoker createEventHandlerInvoker(Object instance)
          Creates a new MessageHandlerInvoker that invokes methods on the given instance.
 Collection<EventSourcedEntity> getChildEntities(Object instance)
          Returns the child entities of given instance.
<I> I
getIdentifier(AbstractAnnotatedAggregateRoot<I> aggregateRoot)
          Returns the identifier of the given aggregateRoot.
static AggregateAnnotationInspector getInspector(Class<?> entityType, ParameterResolverFactory parameterResolverFactory)
          Returns (or creates) an inspector for the given entityType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInspector

public static AggregateAnnotationInspector getInspector(Class<?> entityType,
                                                        ParameterResolverFactory parameterResolverFactory)
Returns (or creates) an inspector for the given entityType. If an instance is already created for that type, that instance may be returned. Otherwise, a new inspector is created.

Parameters:
entityType - The type of entity (aggregate root or simple member) to get an inspector for
parameterResolverFactory - The factory providing access to the parameter resolvers
Returns:
an inspector for the given entity type

createEventHandlerInvoker

public MessageHandlerInvoker createEventHandlerInvoker(Object instance)
Creates a new MessageHandlerInvoker that invokes methods on the given instance.

Parameters:
instance - The object (typically an entity) to create the MessageHandlerInvoker for
Returns:
a MessageHandlerInvoker that invokes handler methods on given instance

getChildEntities

public Collection<EventSourcedEntity> getChildEntities(Object instance)
Returns the child entities of given instance. Entities are detected if they are contained in fields annotated with EventSourcedMember. If the annotated field is a collection, map or array, each member of that collection, the map's key set, the map's value set or the array that implements the EventSourcedEntity interface is returned.

Parameters:
instance - The instance to find child entities in
Returns:
a collection of child entities found in the given instance.

getIdentifier

public <I> I getIdentifier(AbstractAnnotatedAggregateRoot<I> aggregateRoot)
Returns the identifier of the given aggregateRoot. Since only the aggregate root carries the aggregate's identifier, this method cannot be invoked with any other entity than the aggregate's root.

The field carrying the aggregate identifier must be annotated with AggregateIdentifier.

Type Parameters:
I - The type of identifier declared on the aggregate root
Parameters:
aggregateRoot - The aggregate root to find the aggregate on
Returns:
the value contained in the field annotated with AggregateIdentifier


Copyright © 2010-2016. All Rights Reserved.