org.axonframework.domain
Interface AggregateRoot<I>

Type Parameters:
I - The type of the identifier of this aggregate
All Known Subinterfaces:
EventSourcedAggregateRoot<I>
All Known Implementing Classes:
AbstractAggregateRoot, AbstractAnnotatedAggregateRoot, AbstractEventSourcedAggregateRoot, ToDoItem, ToDoItem

public interface AggregateRoot<I>

Interface defining a contract for entities that represent the aggregate root.

Since:
0.1
Author:
Allard Buijze
See Also:
AbstractAggregateRoot

Method Summary
 void addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
          Adds an EventRegistrationCallback, which is notified when the aggregate registers an Event for publication.
 void commitEvents()
          Clears the events currently marked as "uncommitted" and clears any known EventRegistrationCallbacks (see addEventRegistrationCallback(EventRegistrationCallback)).
 I getIdentifier()
          Returns the identifier of this aggregate.
 int getUncommittedEventCount()
          Returns the number of uncommitted events currently available in the aggregate.
 DomainEventStream getUncommittedEvents()
          Returns a DomainEventStream to the events in the aggregate that have been raised since creation or the last commit.
 Long getVersion()
          Returns the current version number of the aggregate, or null if the aggregate is newly created.
 boolean isDeleted()
          Indicates whether this aggregate has been marked as deleted.
 

Method Detail

getIdentifier

I getIdentifier()
Returns the identifier of this aggregate.

Returns:
the identifier of this aggregate

commitEvents

void commitEvents()
Clears the events currently marked as "uncommitted" and clears any known EventRegistrationCallbacks (see addEventRegistrationCallback(EventRegistrationCallback)).

See Also:
EventContainer.commit()

getUncommittedEventCount

int getUncommittedEventCount()
Returns the number of uncommitted events currently available in the aggregate.

Returns:
the number of uncommitted events currently available in the aggregate.

getUncommittedEvents

DomainEventStream getUncommittedEvents()
Returns a DomainEventStream to the events in the aggregate that have been raised since creation or the last commit.

Returns:
the DomainEventStream to the uncommitted events.

getVersion

Long getVersion()
Returns the current version number of the aggregate, or null if the aggregate is newly created. This version must reflect the version number of the aggregate on which changes are applied.

Each time the aggregate is modified and stored in a repository, the version number must be increased by at least 1. This version number can be used by optimistic locking strategies and detection of conflicting concurrent modification.

Typically the sequence number of the last committed event on this aggregate is used as version number.

Returns:
the current version number of this aggregate, or null if no events were ever committed

isDeleted

boolean isDeleted()
Indicates whether this aggregate has been marked as deleted. When true, it is an instruction to the repository to remove this instance at an appropriate time.

Repositories should not return any instances of Aggregates that return true on isDeleted().

Returns:
true if this aggregate was marked as deleted, otherwise false.

addEventRegistrationCallback

void addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
Adds an EventRegistrationCallback, which is notified when the aggregate registers an Event for publication. These callbacks are cleared when the aggregate is committed.

If the aggregate contains uncommitted events, they are all passed to the given eventRegistrationCallback for processing.

Parameters:
eventRegistrationCallback - the callback to notify when an event is registered


Copyright © 2010-2016. All Rights Reserved.