AR
- the aggregate root typeA
- the Aggregate
implementation typepublic class LockAwareAggregate<AR,A extends Aggregate<AR>> extends Object implements Aggregate<AR>
Constructor and Description |
---|
LockAwareAggregate(A wrappedAggregate,
Lock lock)
|
LockAwareAggregate(A wrappedAggregate,
Supplier<Lock> lock)
|
Modifier and Type | Method and Description |
---|---|
void |
execute(Consumer<AR> invocation)
Execute a method on the underlying aggregate or one of its instances.
|
A |
getWrappedAggregate()
Get the delegate aggregate wrapped by this instance.
|
Object |
handle(Message<?> message)
Handle the given
message on the aggregate root or one of its child entities. |
Object |
identifier()
Get the unique identifier of this aggregate
|
<R> R |
invoke(Function<AR,R> invocation)
Invoke a method on the underlying aggregate root or one of its instances.
|
boolean |
isDeleted()
Check if this aggregate has been deleted.
|
boolean |
isLockHeld()
Check if the aggregate currently holds a lock.
|
Class<? extends AR> |
rootType()
Get the class type of the wrapped aggregate root that the Aggregate defers to for command handling.
|
String |
type()
Get the String representation of the aggregate's type.
|
Long |
version()
Get the aggregate's version.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
identifierAsString
public LockAwareAggregate(A wrappedAggregate, Lock lock)
wrappedAggregate
- the aggregate instance to which the LockAwareAggregate will delegatelock
- the lock held by the aggregatepublic A getWrappedAggregate()
public boolean isLockHeld()
true
if the lock is held, false
otherwisepublic String type()
Aggregate
Aggregate.rootType()
unless configured otherwise.public Object identifier()
Aggregate
identifier
in interface Aggregate<AR>
public Long version()
Aggregate
public Object handle(Message<?> message) throws Exception
Aggregate
message
on the aggregate root or one of its child entities.handle
in interface Aggregate<AR>
message
- The message to be handled by the aggregatenull
if for example handling a
CommandMessage
yields no resultsException
- in case one is triggered during message processingpublic <R> R invoke(Function<AR,R> invocation)
Aggregate
Aggregate.execute(Consumer)
to obtain an invocation result, for instance in order to query the aggregate.
Note that the use of this method is not recommended as aggregates are not meant to be queried. Relying on this method is commonly a sign of design smell.
public void execute(Consumer<AR> invocation)
Aggregate
Note that the use of this method is not recommended as the wrapped aggregate instance is not meant to be exposed. Relying on this method is commonly a sign of design smell.
public boolean isDeleted()
Aggregate
AggregateDeletedException
.Copyright © 2010–2024. All rights reserved.