Class Context.ResourceKey<T>

java.lang.Object
org.axonframework.messaging.core.Context.ResourceKey<T>
Type Parameters:
T - The type of resource registered under this key.
Enclosing interface:
Context

public static final class Context.ResourceKey<T> extends Object
Object that is used as a key to retrieve and register resources of a given type in a Context.

Instance of a ResourceKey can be created using the withLabel(String) method. Regardless of the given label, a unique key will be constructed at all times, ensuring user-defined keys do not clash with system keys. Thus, if a Context specific resource should be shared, the constructed ResourceKey should be shared.

Since:
5.0.0
Author:
Allard Buijze, Mitchell Herrijgers, Steven van Beelen
  • Method Details

    • withLabel

      public static <T> Context.ResourceKey<T> withLabel(@Nullable String label)
      Create a new ResourceKey for a resource of type T. The given label is part of the toString() (if not null or empty) of the created key instance and may be used for debugging purposes.
      Type Parameters:
      T - The type of resource of this key.
      Parameters:
      label - A String to recognize this key during debugging.
      Returns:
      A new ResourceKey used to register and retrieve resources.
    • label

      public String label()
    • toString

      public String toString()
      Overrides:
      toString in class Object