org.axonframework.eventsourcing
Class AggregateSnapshotter

java.lang.Object
  extended by org.axonframework.eventsourcing.AbstractSnapshotter
      extended by org.axonframework.eventsourcing.AggregateSnapshotter
All Implemented Interfaces:
Snapshotter
Direct Known Subclasses:
SpringAggregateSnapshotter

public class AggregateSnapshotter
extends AbstractSnapshotter

Implementation of a snapshotter that uses the actual aggregate and its state to create a snapshot event. The motivation is that an aggregate always contains all relevant state. Therefore, storing the aggregate itself inside an event should capture all necessary information.

Since:
0.6
Author:
Allard Buijze

Constructor Summary
AggregateSnapshotter()
           
 
Method Summary
protected  DomainEventMessage createSnapshot(String typeIdentifier, Object aggregateIdentifier, DomainEventStream eventStream)
          Creates a snapshot event for an aggregate of the given typeIdentifier of which passed events are available in the given eventStream.
 void setAggregateFactories(List<AggregateFactory<?>> aggregateFactories)
          Sets the aggregate factory to use.
 
Methods inherited from class org.axonframework.eventsourcing.AbstractSnapshotter
createSnapshotterTask, getEventStore, getExecutor, scheduleSnapshot, setEventStore, setExecutor, setTxManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregateSnapshotter

public AggregateSnapshotter()
Method Detail

createSnapshot

protected DomainEventMessage createSnapshot(String typeIdentifier,
                                            Object aggregateIdentifier,
                                            DomainEventStream eventStream)
Description copied from class: AbstractSnapshotter
Creates a snapshot event for an aggregate of the given typeIdentifier of which passed events are available in the given eventStream. May return null to indicate a snapshot event is not necessary or appropriate for the given event stream.

Specified by:
createSnapshot in class AbstractSnapshotter
Parameters:
typeIdentifier - The aggregate's type identifier
aggregateIdentifier - The identifier of the aggregate to create a snapshot for
eventStream - The event stream containing the aggregate's past events
Returns:
the snapshot event for the given events, or null if none should be stored.

setAggregateFactories

public void setAggregateFactories(List<AggregateFactory<?>> aggregateFactories)
Sets the aggregate factory to use. The aggregate factory is responsible for creating the aggregates stores inside the snapshot events.

Parameters:
aggregateFactories - The list of aggregate factories creating the aggregates to store. May not be null or contain any null values.
Throws:
NullPointerException - if aggregateFactories is null or if contains any null values.


Copyright © 2010-2016. All Rights Reserved.