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.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class SpringAggregateSnapshotter
extends AggregateSnapshotter
implements org.springframework.context.ApplicationContextAware, org.springframework.context.SmartLifecycle

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
 int getPhase()
           
 boolean isAutoStartup()
           
 boolean isRunning()
           
 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.
 void start()
           
 void stop()
           
 void stop(Runnable runnable)
           
 
Methods inherited from class org.axonframework.eventsourcing.AggregateSnapshotter
createSnapshot
 
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

SpringAggregateSnapshotter

public SpringAggregateSnapshotter()
Method Detail

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

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

isAutoStartup

public boolean isAutoStartup()
Specified by:
isAutoStartup in interface org.springframework.context.SmartLifecycle

stop

public void stop(Runnable runnable)
Specified by:
stop in interface org.springframework.context.SmartLifecycle

start

public void start()
Specified by:
start in interface org.springframework.context.Lifecycle

stop

public void stop()
Specified by:
stop in interface org.springframework.context.Lifecycle

isRunning

public boolean isRunning()
Specified by:
isRunning in interface org.springframework.context.Lifecycle

getPhase

public int getPhase()
Specified by:
getPhase in interface org.springframework.context.Phased


Copyright © 2010-2016. All Rights Reserved.