Class LockAwareAggregate<AR,A extends Aggregate<AR>>
java.lang.Object
org.axonframework.modelling.command.LockAwareAggregate<AR,A>
- Type Parameters:
AR- the aggregate root typeA- theAggregateimplementation type
- All Implemented Interfaces:
Aggregate<AR>
Aggregate implementation that provides access to the lock held by the aggregate while a command is handled.
- Since:
- 3.0
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionLockAwareAggregate(A wrappedAggregate, Supplier<Lock> lock) LockAwareAggregate(A wrappedAggregate, Lock lock) -
Method Summary
Modifier and TypeMethodDescriptionvoidExecute a method on the underlying aggregate or one of its instances.Get the delegate aggregate wrapped by this instance.Handle the givenmessageon the aggregate root or one of its child entities.Get the unique identifier of this aggregate<R> RInvoke a method on the underlying aggregate root or one of its instances.booleanCheck if this aggregate has been deleted.booleanCheck if the aggregate currently holds a lock.rootType()Get the class type of the wrapped aggregate root that the Aggregate defers to for command handling.type()Get the String representation of the aggregate's type.version()Get the aggregate's version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.modelling.command.Aggregate
identifierAsString
-
Constructor Details
-
LockAwareAggregate
- Parameters:
wrappedAggregate- the aggregate instance to which the LockAwareAggregate will delegatelock- the lock held by the aggregate
-
LockAwareAggregate
- Parameters:
wrappedAggregate- the aggregate instance to which the LockAwareAggregate will delegatelock- a supplier of the lock held by the aggregate
-
-
Method Details
-
getWrappedAggregate
Get the delegate aggregate wrapped by this instance.- Returns:
- the wrapped aggregate
-
isLockHeld
public boolean isLockHeld()Check if the aggregate currently holds a lock.- Returns:
trueif the lock is held,falseotherwise
-
type
Description copied from interface:AggregateGet the String representation of the aggregate's type. This defaults to the simple name of theAggregate.rootType()unless configured otherwise. -
identifier
Description copied from interface:AggregateGet the unique identifier of this aggregate- Specified by:
identifierin interfaceAggregate<AR>- Returns:
- The aggregate's identifier
-
version
Description copied from interface:AggregateGet the aggregate's version. For event sourced aggregates this is identical to the sequence number of the last applied event. -
handle
Description copied from interface:AggregateHandle the givenmessageon the aggregate root or one of its child entities.- Specified by:
handlein interfaceAggregate<AR>- Parameters:
message- The message to be handled by the aggregate- Returns:
- The result of message handling. Might returns
nullif for example handling aCommandMessageyields no results - Throws:
Exception- in case one is triggered during message processing
-
invoke
Description copied from interface:AggregateInvoke a method on the underlying aggregate root or one of its instances. Use this overAggregate.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.
-
execute
Description copied from interface:AggregateExecute a method on the underlying aggregate or one of its instances.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.
-
isDeleted
public boolean isDeleted()Description copied from interface:AggregateCheck if this aggregate has been deleted. This is checked by aggregate repositories when an aggregate is loaded. In case the repository is asked to load a deleted aggregate the repository will refuse by throwing anAggregateDeletedException. -
rootType
Description copied from interface:AggregateGet the class type of the wrapped aggregate root that the Aggregate defers to for command handling.
-