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)
|
| 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, waitidentifierAsStringpublic A getWrappedAggregate()
public boolean isLockHeld()
true if the lock is held, false otherwisepublic String type()
AggregateAggregate.rootType() unless configured otherwise.public Object identifier()
Aggregateidentifier in interface Aggregate<AR>public Long version()
Aggregatepublic Object handle(Message<?> message) throws Exception
Aggregatemessage 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)
AggregateAggregate.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)
AggregateNote 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()
AggregateAggregateDeletedException.Copyright © 2010–2018. All rights reserved.