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 Summary
ConstructorsConstructorDescriptionDefault constructor, which relies on Spring to inject the application context.SpringBeanParameterResolverFactory(org.springframework.context.ApplicationContext applicationContext) Convenience constructor to use when an instance is not managed by Spring, but an application context is available. -
Method Summary
Modifier and TypeMethodDescriptioncreateInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
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:ParameterResolverFactoryIf available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.If the
ParameterResolverFactorycannot provide a suitableParameterResolver, returnsnull.- Specified by:
createInstancein interfaceParameterResolverFactory- 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 aParameterResolverfor.- Returns:
- A suitable
ParameterResolver, ornullif none is found.
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-