Package org.axonframework.messaging.core
Class SimpleContext
java.lang.Object
org.axonframework.messaging.core.SimpleContext
- All Implemented Interfaces:
Context
Implementation of the
Context providing a basic implementation for context-specific resource management.- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.core.Context
Context.ResourceKey<T> -
Constructor Summary
ConstructorsConstructorDescriptionSimpleContext(Context.ResourceKey<T> key, T value) Constructs a SimpleContext with a single resource. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsResource(Context.ResourceKey<?> key) Indicates whether a resource has been registered with the givenkeyin this Context.boolean<T> TgetResource(Context.ResourceKey<T> key) Returns the resource currently registered under the givenkey, ornullif no resource is present.inthashCode()Retrieves all resources contained within the currentContext.toString()<T> ContextwithResource(Context.ResourceKey<T> key, T resource) Constructs a copy ofthisContext with an additionalresourcefor givenkey.
-
Constructor Details
-
SimpleContext
Constructs a SimpleContext with a single resource.- Type Parameters:
T- The type of the initial resource- Parameters:
key- The key of the initial resourcevalue- The initial resource
-
-
Method Details
-
containsResource
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
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.
-
withResource
Description copied from interface:ContextConstructs a copy ofthisContext with an additionalresourcefor givenkey.- Specified by:
withResourcein interfaceContext- Type Parameters:
T- The type of resource registered under the givenkey.- Parameters:
key- The key under which to register theresource.resource- The resource to register.- Returns:
- A copy of
thisContext with the added givenresourcesunder the givenkeyto the copy.
-
resources
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. -
equals
-
hashCode
public int hashCode() -
toString
-