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) |
static <T> SpringPrototypeAggregateFactory<T> |
withSubtypeSupport(String prototypeBeanName,
Map<Class<? extends T>,String> subtypes)
Initializes the factory to create bean instances for the bean with given
prototypeBeanName and its
subtypes . |
public SpringPrototypeAggregateFactory(String prototypeBeanName)
prototypeBeanName
.
Note that 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 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 static <T> SpringPrototypeAggregateFactory<T> withSubtypeSupport(String prototypeBeanName, Map<Class<? extends T>,String> subtypes)
prototypeBeanName
and its
subtypes
.
Note that the bean should have the prototype scope.
This static factory method is provided as an alternative to avoid warnings and errors on ambiguous constructor resolution when using Spring AOT.
prototypeBeanName
- The name of the prototype bean this repository serves.subtypes
- The map of subtype of this aggregate to its spring prototype name.public 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(@Nonnull org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public void setBeanName(@Nonnull String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Copyright © 2010–2023. All rights reserved.