Class SpringBeanParameterResolverFactory

java.lang.Object
org.axonframework.extension.spring.config.annotation.SpringBeanParameterResolverFactory
All Implemented Interfaces:
ParameterResolverFactory, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class SpringBeanParameterResolverFactory extends Object implements ParameterResolverFactory, org.springframework.context.ApplicationContextAware
ParameterResolverFactory implementation that resolves parameters in the Spring Application Context. A parameter can be resolved as a Spring bean if there is exactly one bean assignable to the parameter type. If multiple beans are available the desired one can be designated with a Qualifier annotation on the parameter. By absence of a Qualifier annotation the bean marked as primary will be chosen. Note that when multiple beans are marked as primary, either one can be selected as parameter value.
Since:
2.1
Author:
Allard Buijze
  • Constructor Details

    • SpringBeanParameterResolverFactory

      public SpringBeanParameterResolverFactory()
      Default constructor, which relies on Spring to inject the application context.
    • SpringBeanParameterResolverFactory

      public SpringBeanParameterResolverFactory(org.springframework.context.ApplicationContext applicationContext)
      Convenience constructor to use when an instance is not managed by Spring, but an application context is available.
      Parameters:
      applicationContext - The application context providing access to beans that may be used as parameters
  • Method Details

    • createInstance

      @Nullable public ParameterResolver<?> createInstance(@Nonnull Executable executable, @Nonnull Parameter[] parameters, int parameterIndex)
      Description copied from interface: ParameterResolverFactory
      If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.

      If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns null.

      Specified by:
      createInstance in interface ParameterResolverFactory
      Parameters:
      executable - The executable (constructor or method) to inspect.
      parameters - The parameters on the executable to inspect.
      parameterIndex - The index of the parameter to return a ParameterResolver for.
      Returns:
      A suitable ParameterResolver, or null if none is found.
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException