Class LegacyMessageSupportingContext
- All Implemented Interfaces:
ApplicationContext,Context,ProcessingContext,ProcessingLifecycle
ProcessingContext that should only be used for legacy components. Can only be
constructed with a Message as parameter that is added to the resources. Any
lifecycle operation will fail.- Since:
- 5.0.0
- Author:
- Mitchell Herrijgers
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.core.Context
Context.ResourceKey<T>Nested classes/interfaces inherited from interface org.axonframework.messaging.core.unitofwork.ProcessingLifecycle
ProcessingLifecycle.DefaultPhases, ProcessingLifecycle.ErrorHandler, ProcessingLifecycle.Phase -
Constructor Summary
ConstructorsConstructorDescriptionLegacyMessageSupportingContext(Message message) Deprecated.Initialize theProcessingContextwith the givenmessageas the only resource. -
Method Summary
Modifier and TypeMethodDescription<C> CDeprecated.Returns the component declared under the giventypeandnameor throws aComponentNotFoundExceptionif it does not exist.<T> TcomputeResourceIfAbsent(Context.ResourceKey<T> key, Supplier<T> resourceSupplier) Deprecated.If no resource is present for the givenkey, the givenresourceSupplieris used to supply the instance to register under thiskey.booleancontainsResource(Context.ResourceKey<?> key) Deprecated.Indicates whether a resource has been registered with the givenkeyin this Context.<T> TgetResource(Context.ResourceKey<T> key) Deprecated.Returns the resource currently registered under the givenkey, ornullif no resource is present.booleanDeprecated.booleanDeprecated.booleanisError()Deprecated.booleanDeprecated.on(ProcessingLifecycle.Phase phase, Function<ProcessingContext, CompletableFuture<?>> action) Deprecated.Registers the providedactionto be executed in the givenphase.Deprecated.Registers the providedactionto be executed when thisProcessingLifecycleencounters an error during the action of anyProcessingLifecycle.Phase.<T> TputResource(Context.ResourceKey<T> key, T resource) Deprecated.Register the givenresourceunder the givenkey.<T> TputResourceIfAbsent(Context.ResourceKey<T> key, T resource) Deprecated.Register the giveninstanceunder the givenkeyif no value is currently present.<T> TremoveResource(Context.ResourceKey<T> key) Deprecated.Removes the resource registered under givenkey.<T> booleanremoveResource(Context.ResourceKey<T> key, T expectedResource) Deprecated.Remove the resource associated with givenkeyif the givenexpectedResourceis the currently associated value.Deprecated.Retrieves all resources contained within the currentContext.<T> TupdateResource(Context.ResourceKey<T> key, UnaryOperator<T> resourceUpdater) Deprecated.Update the resource with givenkeyusing the givenresourceUpdaterto describe the update.whenComplete(Consumer<ProcessingContext> action) Deprecated.Registers the providedactionto be executed when thisProcessingLifecyclecompletes all registered actions.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.ApplicationContext
componentMethods inherited from interface org.axonframework.messaging.core.unitofwork.ProcessingContext
withResourceMethods inherited from interface org.axonframework.messaging.core.unitofwork.ProcessingLifecycle
doFinally, onAfterCommit, onCommit, onInvocation, onPostInvocation, onPreInvocation, onPrepareCommit, runOn, runOnAfterCommit, runOnCommit, runOnInvocation, runOnPostInvocation, runOnPreInvocation, runOnPrepareCommit
-
Constructor Details
-
LegacyMessageSupportingContext
Deprecated.Initialize theProcessingContextwith the givenmessageas the only resource.- Parameters:
message- The message to be used as the only resource in this context.
-
-
Method Details
-
isStarted
public boolean isStarted()Deprecated.Description copied from interface:ProcessingLifecycle- Specified by:
isStartedin interfaceProcessingLifecycle- Returns:
truewhen thisProcessingLifecycleis started,falseotherwise.
-
isError
public boolean isError()Deprecated.Description copied from interface:ProcessingLifecycleReturnstruewhen thisProcessingLifecycleis in error,falseotherwise.When
true, theregistered ErrorHandlerswill be invoked.- Specified by:
isErrorin interfaceProcessingLifecycle- Returns:
truewhen thisProcessingLifecycleis in error,falseotherwise.
-
isCommitted
public boolean isCommitted()Deprecated.Description copied from interface:ProcessingLifecycle- Specified by:
isCommittedin interfaceProcessingLifecycle- Returns:
truewhen thisProcessingLifecycleis committed,falseotherwise.
-
isCompleted
public boolean isCompleted()Deprecated.Description copied from interface:ProcessingLifecycleReturnstruewhen thisProcessingLifecycleis completed,falseotherwise.Note that this
ProcessingLifecycleis marked as completed for a successful and failed completion.- Specified by:
isCompletedin interfaceProcessingLifecycle- Returns:
truewhen thisProcessingLifecycleis completed,falseotherwise.
-
on
public ProcessingLifecycle on(@Nonnull ProcessingLifecycle.Phase phase, @Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Deprecated.Description copied from interface:ProcessingLifecycleRegisters the providedactionto be executed in the givenphase. Uses theCompletableFuturereturned by theactionto compose actions and to carry the action's result.Use this operation when the return value of the
actionis important.- Specified by:
onin interfaceProcessingLifecycle- Parameters:
phase- TheProcessingLifecycle.Phaseto execute the givenactionin.action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onError
Deprecated.Description copied from interface:ProcessingLifecycleRegisters the providedactionto be executed when thisProcessingLifecycleencounters an error during the action of anyProcessingLifecycle.Phase. This includes failures from actions registered throughProcessingLifecycle.whenComplete(Consumer).When the given
ErrorHandlersare invokedProcessingLifecycle.isError()andProcessingLifecycle.isCompleted()will returntrue.- Specified by:
onErrorin interfaceProcessingLifecycle- Parameters:
action- The error handler to execute when thisProcessingLifecycleencounters an error during phase execution.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
whenComplete
Deprecated.Description copied from interface:ProcessingLifecycleRegisters the providedactionto be executed when thisProcessingLifecyclecompletes all registered actions.- Specified by:
whenCompletein interfaceProcessingLifecycle- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
containsResource
Deprecated.Description copied from interface:ContextIndicates whether a resource has been registered with the givenkeyin this Context.- Specified by:
containsResourcein interfaceContext- Parameters:
key- The key of the resource to check.- Returns:
trueif a resource is registered with thiskey, otherwisefalse.
-
getResource
Deprecated.Description copied from interface:ContextReturns the resource currently registered under the givenkey, ornullif no resource is present.- Specified by:
getResourcein interfaceContext- Type Parameters:
T- The type of resource registered under the givenkey.- Parameters:
key- The key to retrieve the resource for.- Returns:
- The resource currently registered under given
key, ornullif not present.
-
resources
Deprecated.Description copied from interface:ContextRetrieves all resources contained within the currentContext.Most of the time, none of the keys make any sense to the component that would retrieve them. Thus, this method is purely here for copying resources between
Contextinstances, not for retrieval. For that, there's theContext.getResource(ResourceKey)method. -
putResource
Deprecated.Description copied from interface:ProcessingContextRegister the givenresourceunder the givenkey.- Specified by:
putResourcein interfaceProcessingContext- Type Parameters:
T- The type ofresourceto register under given @code.- Parameters:
key- The key under which to register theresource.resource- The resource to register.- Returns:
- The previously registered
resource, ornullif none was present.
-
updateResource
public <T> T updateResource(@Nonnull Context.ResourceKey<T> key, @Nonnull UnaryOperator<T> resourceUpdater) Deprecated.Description copied from interface:ProcessingContextUpdate the resource with givenkeyusing the givenresourceUpdaterto describe the update. If no resource is registered with the givenkey, theresourceUpdateris invoked withnull. Otherwise, the function is called with the currently registered resource under that key.The resource is replaced with the return value of the function, or removed when the function returns
null.If the function throws an exception, the exception is rethrown to the caller.
- Specified by:
updateResourcein interfaceProcessingContext- Type Parameters:
T- The type of resource to update.- Parameters:
key- The key to update the resource for.resourceUpdater- The function performing the update itself.- Returns:
- The new value associated with the
key, ornullwhen removed.
-
putResourceIfAbsent
Deprecated.Description copied from interface:ProcessingContextRegister the giveninstanceunder the givenkeyif no value is currently present.- Specified by:
putResourceIfAbsentin interfaceProcessingContext- Type Parameters:
T- The type ofresourceto register under givenkey.- Parameters:
key- The key under which to register the resource.resource- The resource to register when nothing is present for the givenkey.- Returns:
- The resource previously associated with given
key.
-
computeResourceIfAbsent
public <T> T computeResourceIfAbsent(@Nonnull Context.ResourceKey<T> key, @Nonnull Supplier<T> resourceSupplier) Deprecated.Description copied from interface:ProcessingContextIf no resource is present for the givenkey, the givenresourceSupplieris used to supply the instance to register under thiskey.- Specified by:
computeResourceIfAbsentin interfaceProcessingContext- Type Parameters:
T- The type of resource registered under givenkey.- Parameters:
key- The key to register the resource for.resourceSupplier- The function to supply the resource to register.- Returns:
- The resource associated with the
key.
-
removeResource
Deprecated.Description copied from interface:ProcessingContextRemoves the resource registered under givenkey.- Specified by:
removeResourcein interfaceProcessingContext- Type Parameters:
T- The type of resource associated with thekey.- Parameters:
key- The key to remove the registered resource for.- Returns:
- The value previously associated with the
key.
-
removeResource
Deprecated.Description copied from interface:ProcessingContextRemove the resource associated with givenkeyif the givenexpectedResourceis the currently associated value.- Specified by:
removeResourcein interfaceProcessingContext- Type Parameters:
T- The type of resource associated with thekey.- Parameters:
key- The key to remove the registered resource for.expectedResource- The expected resource to remove.- Returns:
trueif the resource has been removed, otherwisefalse.
-
component
Deprecated.Description copied from interface:ApplicationContextReturns the component declared under the giventypeandnameor throws aComponentNotFoundExceptionif it does not exist.- Specified by:
componentin interfaceApplicationContext- Type Parameters:
C- The type of component.- Parameters:
type- The type of component, typically the interface the component implements.name- The name of the component to retrieve. Usenullwhen there is no name or useApplicationContext.component(Class)instead.- Returns:
- The component registered for the given
typeandname.
-