Interface EntityLifecycleHandler<I,E>
- Type Parameters:
I- the type of the entity identifierE- the type of the entity
- All Superinterfaces:
DescribableComponent,SourcingHandler<I,E>
- All Known Implementing Classes:
SimpleEntityLifecycleHandler,SnapshottingEntityLifecycleHandler
An EntityLifecycleHandler is responsible for managing how an entity is:
- initialized when no prior state exists
- reconstructed from an underlying event stream
- kept up to date through live event subscriptions
Implementations encapsulate the full lifecycle semantics of an entity, including how state is derived from events and how runtime updates are applied.
The lifecycle consists of three primary operations:
- initialize: creates a new entity instance
- source: reconstructs an entity from its event history
- subscribe: subscribes a managed entity to be updated with future events
Implementations may apply optimizations such as snapshotting or partial reconstruction strategies, but these concerns remain internal to the handler.
- Since:
- 5.1.0
- Author:
- John Hendrikx
-
Method Summary
Modifier and TypeMethodDescriptioninitialize(I identifier, ProcessingContext context) Creates a new instance of the entity for the given identifier.voidsubscribe(ManagedEntity<I, E> entity, ProcessingContext context) Subscribes the given managed entity to the event stream so it receives future state changes.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeToMethods inherited from interface org.axonframework.eventsourcing.handler.SourcingHandler
source
-
Method Details
-
initialize
Creates a new instance of the entity for the given identifier.This operation is used when no prior state exists for the entity. The resulting instance represents the initial state before any events have been applied.
- Parameters:
identifier- the entity identifier, cannot benullcontext- the processing context, cannot benull- Returns:
- a newly initialized entity instance
-
subscribe
Subscribes the given managed entity to the event stream so it receives future state changes.After subscription, any newly appended events relevant to the entity are applied to its current state, keeping it synchronized with the event store for the remainder of its lifecycle.
- Parameters:
entity- the managed entity to subscribecontext- the processing context
-