T
- The type of aggregate generated by this aggregate factorypublic class SpringPrototypeAggregateFactory<T> extends Object implements AggregateFactory<T>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware
Constructor and Description |
---|
SpringPrototypeAggregateFactory(String prototypeBeanName)
Initializes the factory to create beans instances for the bean with given
prototypeBeanName . |
SpringPrototypeAggregateFactory(String prototypeBeanName,
Map<Class<? extends T>,String> subtypes)
Initializes the factory to create beans instances for the bean with given
prototypeBeanName and its
subtypes . |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
T |
createAggregateRoot(String aggregateIdentifier,
DomainEventMessage<?> firstEvent)
Instantiate the aggregate root using the given aggregate identifier and first event.
|
Class<T> |
getAggregateType()
Returns the type of aggregate this factory creates.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setBeanName(String beanName) |
public SpringPrototypeAggregateFactory(String prototypeBeanName)
prototypeBeanName
.
Note that the the bean should have the prototype scope.
prototypeBeanName
- the name of the prototype bean this repository serves.public SpringPrototypeAggregateFactory(String prototypeBeanName, Map<Class<? extends T>,String> subtypes)
prototypeBeanName
and its
subtypes
.
Note that the the bean should have the prototype scope.
prototypeBeanName
- the name of the prototype bean this repository serves.subtypes
- the map of subtype of this aggregate to its spring prototype namepublic T createAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent)
AggregateFactory
createAggregateRoot
in interface AggregateFactory<T>
aggregateIdentifier
- the aggregate identifier of the aggregate to instantiatefirstEvent
- The first event in the event stream. This is either the event generated during
creation of the aggregate, or a snapshot eventpublic Class<T> getAggregateType()
AggregateFactory
instanceOf
this type.getAggregateType
in interface AggregateFactory<T>
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public void setBeanName(String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Copyright © 2010–2020. All rights reserved.