org.axonframework.eventsourcing
Class SpringAggregateSnapshotter

java.lang.Object
  extended by org.axonframework.eventsourcing.AbstractSnapshotter
      extended by org.axonframework.eventsourcing.AggregateSnapshotter
          extended by org.axonframework.eventsourcing.SpringAggregateSnapshotter
All Implemented Interfaces:
Snapshotter, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class SpringAggregateSnapshotter
extends AggregateSnapshotter
implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

Implementation of the AggregateSnapshotter that eases the configuration when used within a Spring Application Context. It will automatically detect a Transaction Manager and Aggregate Factories.

The only mandatory properties to set is AbstractSnapshotter.setEventStore(org.axonframework.eventstore.SnapshotEventStore). In most cases, you should also provide an executor, as the default will execute snapshotter tasks in the calling thread.

Since:
0.6
Author:
Allard Buijze

Constructor Summary
SpringAggregateSnapshotter()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  Runnable createSnapshotterTask(String typeIdentifier, AggregateIdentifier aggregateIdentifier)
          Creates an instance of a task that contains the actual snapshot creation logic.
 void setAggregateFactories(List<AggregateFactory<?>> aggregateFactories)
          Optionally sets the aggregate factories to use.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setTransactionDefinition(org.springframework.transaction.TransactionDefinition transactionDefinition)
          Optionally sets the transaction definition to use.
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
          Sets the transaction manager to manager underlying transaction with.
 
Methods inherited from class org.axonframework.eventsourcing.AggregateSnapshotter
createSnapshot
 
Methods inherited from class org.axonframework.eventsourcing.AbstractSnapshotter
getEventStore, getExecutor, scheduleSnapshot, setEventStore, setExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringAggregateSnapshotter

public SpringAggregateSnapshotter()
Method Detail

createSnapshotterTask

protected Runnable createSnapshotterTask(String typeIdentifier,
                                         AggregateIdentifier aggregateIdentifier)
Description copied from class: AbstractSnapshotter
Creates an instance of a task that contains the actual snapshot creation logic.

Overrides:
createSnapshotterTask in class AbstractSnapshotter
Parameters:
typeIdentifier - The type of the aggregate to create a snapshot for
aggregateIdentifier - The identifier of the aggregate to create a snapshot for
Returns:
the task containing snapshot creation logic

setTransactionManager

public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Sets the transaction manager to manager underlying transaction with. If none is provided, an attempt is made to auto detect is from the application context. If a single transaction manager is found, it is used to manage transactions. Of none or more than one is found, they are ignored.

Parameters:
transactionManager - the transaction manager managing underlying transactions

setTransactionDefinition

public void setTransactionDefinition(org.springframework.transaction.TransactionDefinition transactionDefinition)
Optionally sets the transaction definition to use. By default, uses the application context's default transaction semantics (see DefaultTransactionDefinition).

Parameters:
transactionDefinition - the transaction definition to use

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

setAggregateFactories

public void setAggregateFactories(List<AggregateFactory<?>> aggregateFactories)
Optionally sets the aggregate factories to use. By default, this implementation will auto detect available factories from the application context. Configuring them using this method will prevent auto detection.

Overrides:
setAggregateFactories in class AggregateSnapshotter
Parameters:
aggregateFactories - The list of aggregate factories creating the aggregates to store.

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException


Copyright © 2011. All Rights Reserved.