Class SimpleResourceInjector

java.lang.Object
org.axonframework.modelling.saga.AbstractResourceInjector
org.axonframework.modelling.saga.SimpleResourceInjector
All Implemented Interfaces:
ResourceInjector
Direct Known Subclasses:
AutowiredResourceInjector

public class SimpleResourceInjector extends AbstractResourceInjector
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 Details

    • SimpleResourceInjector

      public SimpleResourceInjector(Object... resources)
      Initializes the resource injector to inject to given resources.
      Parameters:
      resources - The resources to inject
    • SimpleResourceInjector

      public SimpleResourceInjector(Collection<?> resources)
      Initializes the resource injector to inject to given resources.

      Note that any changes to the given collection will not be reflected by this injector.

      Parameters:
      resources - The resources to inject
  • Method Details

    • findResource

      protected <R> Optional<R> findResource(Class<R> requiredType)
      Description copied from class: AbstractResourceInjector
      Returns a resource of given requiredType or an empty Optional if the resource is not registered with the injector.
      Specified by:
      findResource in class AbstractResourceInjector
      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