Class LegacyMessageSupportingContext

java.lang.Object
org.axonframework.messaging.core.unitofwork.LegacyMessageSupportingContext
All Implemented Interfaces:
ApplicationContext, Context, ProcessingContext, ProcessingLifecycle

@Deprecated public class LegacyMessageSupportingContext extends Object implements ProcessingContext
Deprecated.
Only in use for legacy "sync" components.
Legacy implementation of the 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
  • Constructor Details

    • LegacyMessageSupportingContext

      public LegacyMessageSupportingContext(@Nonnull Message message)
      Deprecated.
      Initialize the ProcessingContext with the given message as 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
      Returns true when this ProcessingLifecycle is started, false otherwise.
      Specified by:
      isStarted in interface ProcessingLifecycle
      Returns:
      true when this ProcessingLifecycle is started, false otherwise.
    • isError

      public boolean isError()
      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Returns true when this ProcessingLifecycle is in error, false otherwise.

      When true, the registered ErrorHandlers will be invoked.

      Specified by:
      isError in interface ProcessingLifecycle
      Returns:
      true when this ProcessingLifecycle is in error, false otherwise.
    • isCommitted

      public boolean isCommitted()
      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Returns true when this ProcessingLifecycle is committed, false otherwise.
      Specified by:
      isCommitted in interface ProcessingLifecycle
      Returns:
      true when this ProcessingLifecycle is committed, false otherwise.
    • isCompleted

      public boolean isCompleted()
      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Returns true when this ProcessingLifecycle is completed, false otherwise.

      Note that this ProcessingLifecycle is marked as completed for a successful and failed completion.

      Specified by:
      isCompleted in interface ProcessingLifecycle
      Returns:
      true when this ProcessingLifecycle is completed, false otherwise.
    • on

      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Registers the provided action to be executed in the given phase. Uses the CompletableFuture returned by the action to compose actions and to carry the action's result.

      Use this operation when the return value of the action is important.

      Specified by:
      on in interface ProcessingLifecycle
      Parameters:
      phase - The ProcessingLifecycle.Phase to execute the given action in.
      action - The Function that's given the active ProcessingContext and returns a CompletableFuture for chaining purposes and to carry the action's result.
      Returns:
      This ProcessingLifecycle instance for fluent interfacing.
    • onError

      public ProcessingLifecycle onError(@Nonnull ProcessingLifecycle.ErrorHandler action)
      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Registers the provided action to be executed when this ProcessingLifecycle encounters an error during the action of any ProcessingLifecycle.Phase. This includes failures from actions registered through ProcessingLifecycle.whenComplete(Consumer).

      When the given ErrorHandlers are invoked ProcessingLifecycle.isError() and ProcessingLifecycle.isCompleted() will return true.

      Specified by:
      onError in interface ProcessingLifecycle
      Parameters:
      action - The error handler to execute when this ProcessingLifecycle encounters an error during phase execution.
      Returns:
      This ProcessingLifecycle instance for fluent interfacing.
    • whenComplete

      public ProcessingLifecycle whenComplete(@Nonnull Consumer<ProcessingContext> action)
      Deprecated.
      Description copied from interface: ProcessingLifecycle
      Registers the provided action to be executed when this ProcessingLifecycle completes all registered actions.
      Specified by:
      whenComplete in interface ProcessingLifecycle
      Parameters:
      action - A Consumer that's given the active ProcessingContext to perform its action.
      Returns:
      This ProcessingLifecycle instance for fluent interfacing.
    • containsResource

      public boolean containsResource(@Nonnull Context.ResourceKey<?> key)
      Deprecated.
      Description copied from interface: Context
      Indicates whether a resource has been registered with the given key in this Context.
      Specified by:
      containsResource in interface Context
      Parameters:
      key - The key of the resource to check.
      Returns:
      true if a resource is registered with this key, otherwise false.
    • getResource

      public <T> T getResource(@Nonnull Context.ResourceKey<T> key)
      Deprecated.
      Description copied from interface: Context
      Returns the resource currently registered under the given key, or null if no resource is present.
      Specified by:
      getResource in interface Context
      Type Parameters:
      T - The type of resource registered under the given key.
      Parameters:
      key - The key to retrieve the resource for.
      Returns:
      The resource currently registered under given key, or null if not present.
    • resources

      public Map<Context.ResourceKey<?>,Object> resources()
      Deprecated.
      Description copied from interface: Context
      Retrieves all resources contained within the current Context.

      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 Context instances, not for retrieval. For that, there's the Context.getResource(ResourceKey) method.

      Specified by:
      resources in interface Context
      Returns:
      A map containing all resources where each entry has a ResourceKey<?> as the key and the associated resource object as the value.
    • putResource

      public <T> T putResource(@Nonnull Context.ResourceKey<T> key, @Nonnull T resource)
      Deprecated.
      Description copied from interface: ProcessingContext
      Register the given resource under the given key.
      Specified by:
      putResource in interface ProcessingContext
      Type Parameters:
      T - The type of resource to register under given @code.
      Parameters:
      key - The key under which to register the resource.
      resource - The resource to register.
      Returns:
      The previously registered resource, or null if none was present.
    • updateResource

      public <T> T updateResource(@Nonnull Context.ResourceKey<T> key, @Nonnull UnaryOperator<T> resourceUpdater)
      Deprecated.
      Description copied from interface: ProcessingContext
      Update the resource with given key using the given resourceUpdater to describe the update. If no resource is registered with the given key, the resourceUpdater is invoked with null. 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:
      updateResource in interface ProcessingContext
      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, or null when removed.
    • putResourceIfAbsent

      public <T> T putResourceIfAbsent(@Nonnull Context.ResourceKey<T> key, @Nonnull T resource)
      Deprecated.
      Description copied from interface: ProcessingContext
      Register the given instance under the given key if no value is currently present.
      Specified by:
      putResourceIfAbsent in interface ProcessingContext
      Type Parameters:
      T - The type of resource to register under given key.
      Parameters:
      key - The key under which to register the resource.
      resource - The resource to register when nothing is present for the given key.
      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: ProcessingContext
      If no resource is present for the given key, the given resourceSupplier is used to supply the instance to register under this key.
      Specified by:
      computeResourceIfAbsent in interface ProcessingContext
      Type Parameters:
      T - The type of resource registered under given key.
      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

      public <T> T removeResource(@Nonnull Context.ResourceKey<T> key)
      Deprecated.
      Description copied from interface: ProcessingContext
      Removes the resource registered under given key.
      Specified by:
      removeResource in interface ProcessingContext
      Type Parameters:
      T - The type of resource associated with the key.
      Parameters:
      key - The key to remove the registered resource for.
      Returns:
      The value previously associated with the key.
    • removeResource

      public <T> boolean removeResource(@Nonnull Context.ResourceKey<T> key, @Nonnull T expectedResource)
      Deprecated.
      Description copied from interface: ProcessingContext
      Remove the resource associated with given key if the given expectedResource is the currently associated value.
      Specified by:
      removeResource in interface ProcessingContext
      Type Parameters:
      T - The type of resource associated with the key.
      Parameters:
      key - The key to remove the registered resource for.
      expectedResource - The expected resource to remove.
      Returns:
      true if the resource has been removed, otherwise false.
    • component

      @Nonnull public <C> C component(@Nonnull Class<C> type, @Nullable String name)
      Deprecated.
      Description copied from interface: ApplicationContext
      Returns the component declared under the given type and name or throws a ComponentNotFoundException if it does not exist.
      Specified by:
      component in interface ApplicationContext
      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. Use null when there is no name or use ApplicationContext.component(Class) instead.
      Returns:
      The component registered for the given type and name.