org.axonframework.eventstore.supporting
Class SequenceEventStore

java.lang.Object
  extended by org.axonframework.eventstore.supporting.SequenceEventStore
All Implemented Interfaces:
EventStore, EventStoreManagement

public class SequenceEventStore
extends Object
implements EventStore, EventStoreManagement

Joins two EventStores together.

First EventStore is read-only, supposed to hold the oldest events. The second EventStore is both read and write. Appends are only directed to the second EventStore, supposed to hold newer events.

Reads are first made from the first EventStore, then from the second EventStore.

Author:
Knut-Olav Hoven

Constructor Summary
SequenceEventStore(EventStore second, EventStoreManagement secondManagement, EventStore first, EventStoreManagement firstManagement)
           
 
Method Summary
 void appendEvents(String type, DomainEventStream events)
          Append the events in the given stream to the event store.
 CriteriaBuilder newCriteriaBuilder()
          Returns a CriteriaBuilder that allows the construction of criteria for this EventStore implementation
 DomainEventStream readEvents(String type, Object identifier)
          Read the events of the aggregate identified by the given type and identifier that allow the current aggregate state to be rebuilt.
 void visitEvents(Criteria criteria, EventVisitor visitor)
          Loads all events available in the event store that match the given criteria and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found.
 void visitEvents(EventVisitor visitor)
          Loads all events available in the event store and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceEventStore

public SequenceEventStore(EventStore second,
                          EventStoreManagement secondManagement,
                          EventStore first,
                          EventStoreManagement firstManagement)
Method Detail

visitEvents

public void visitEvents(EventVisitor visitor)
Description copied from interface: EventStoreManagement
Loads all events available in the event store and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number.

Implementations are encouraged, though not required, to supply events in the absolute chronological order.

Processing stops when the visitor throws an exception.

Specified by:
visitEvents in interface EventStoreManagement
Parameters:
visitor - The visitor the receives each loaded event

visitEvents

public void visitEvents(Criteria criteria,
                        EventVisitor visitor)
Description copied from interface: EventStoreManagement
Loads all events available in the event store that match the given criteria and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number.

Implementations are encouraged, though not required, to supply events in the absolute chronological order.

Processing stops when the visitor throws an exception.

Specified by:
visitEvents in interface EventStoreManagement
Parameters:
criteria - The criteria describing the events to select
visitor - The visitor the receives each loaded event
See Also:
EventStoreManagement.newCriteriaBuilder()

newCriteriaBuilder

public CriteriaBuilder newCriteriaBuilder()
Description copied from interface: EventStoreManagement
Returns a CriteriaBuilder that allows the construction of criteria for this EventStore implementation

Specified by:
newCriteriaBuilder in interface EventStoreManagement
Returns:
a builder to create Criteria for this Event Store.
See Also:
EventStoreManagement.visitEvents(Criteria, org.axonframework.eventstore.EventVisitor)

appendEvents

public void appendEvents(String type,
                         DomainEventStream events)
Description copied from interface: EventStore
Append the events in the given stream to the event store.

Specified by:
appendEvents in interface EventStore
Parameters:
type - The type descriptor of the object to store
events - The event stream containing the events to store

readEvents

public DomainEventStream readEvents(String type,
                                    Object identifier)
Description copied from interface: EventStore
Read the events of the aggregate identified by the given type and identifier that allow the current aggregate state to be rebuilt. Implementations may omit or replace events (e.g. by using snapshot events) from the stream for performance purposes.

Specified by:
readEvents in interface EventStore
Parameters:
type - The type descriptor of the object to retrieve
identifier - The unique aggregate identifier of the events to load
Returns:
an event stream containing the events of the aggregate


Copyright © 2010-2016. All Rights Reserved.