Package org.axonframework.modelling.saga
Class SimpleResourceInjector
java.lang.Object
org.axonframework.modelling.saga.AbstractResourceInjector
org.axonframework.modelling.saga.SimpleResourceInjector
- All Implemented Interfaces:
ResourceInjector
- Direct Known Subclasses:
AutowiredResourceInjector
A resource injector that checks for @Inject annotated fields and setter methods to inject resources. If a field is
annotated with @Inject, a Resource of the type of that field is injected into it, if present. If
a method is annotated with @Inject, the method is invoked with a Resource of the type of the first parameter, if
present.
- Since:
- 1.1
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleResourceInjector(Object... resources) Initializes the resource injector to inject to givenresources.SimpleResourceInjector(Collection<?> resources) Initializes the resource injector to inject to givenresources. -
Method Summary
Modifier and TypeMethodDescriptionprotected <R> Optional<R> findResource(Class<R> requiredType) Returns a resource of givenrequiredTypeor an empty Optional if the resource is not registered with the injector.Methods inherited from class org.axonframework.modelling.saga.AbstractResourceInjector
injectorAnnotationNames, injectResources
-
Constructor Details
-
SimpleResourceInjector
Initializes the resource injector to inject to givenresources.- Parameters:
resources- The resources to inject
-
SimpleResourceInjector
Initializes the resource injector to inject to givenresources.Note that any changes to the given collection will not be reflected by this injector.
- Parameters:
resources- The resources to inject
-
-
Method Details
-
findResource
Description copied from class:AbstractResourceInjectorReturns a resource of givenrequiredTypeor an empty Optional if the resource is not registered with the injector.- Specified by:
findResourcein classAbstractResourceInjector- Type Parameters:
R- the resource type- Parameters:
requiredType- the class of the resource to find- Returns:
- an Optional that contains the resource if it was found
-