org.axonframework.contextsupport.spring
Class AutowiredBean

java.lang.Object
  extended by org.axonframework.contextsupport.spring.AutowiredBean

public final class AutowiredBean
extends Object

Special type of BeanDefinition that references can be use to explicitly define a property as being autowired. Autowiring is only successful if exactly one bean is available of the given type.

Internally, this BeanDefinition creates a FactoryBean definition that loads the class from the application context.

Since:
1.0
Author:
Allard Buijze

Method Summary
static org.springframework.beans.factory.support.GenericBeanDefinition createAutowiredBean(Class<?>... autowiredTypes)
          Creates an autowired dependency on the given autowiredTypes.
static org.springframework.beans.factory.support.GenericBeanDefinition createAutowiredBeanWithFallback(Object fallback, Class<?>... autowiredTypes)
          Creates an autowired dependency on the given autowiredTypes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createAutowiredBean

public static org.springframework.beans.factory.support.GenericBeanDefinition createAutowiredBean(Class<?>... autowiredTypes)
Creates an autowired dependency on the given autowiredTypes. A lookup is done on the first type, if no beans of that type are found, the next is evaluated, and so on. If more than one bean of any type is found when it is evaluated, an exception is thrown.

Beans that are not eligible for autowiring (as defined in Spring configuration) are ignored altogether.

Parameters:
autowiredTypes - The types of bean to autowire.
Returns:
the bean definition that will inject a bean of the required type

createAutowiredBeanWithFallback

public static org.springframework.beans.factory.support.GenericBeanDefinition createAutowiredBeanWithFallback(Object fallback,
                                                                                                              Class<?>... autowiredTypes)
Creates an autowired dependency on the given autowiredTypes. A lookup is done on the first type, if no beans of that type are found, the next is evaluated, and so on. If more than one bean of any type is found when it is evaluated, an exception is thrown.

If there are no autowire candidates, the given fallback is used to take its place. If fallback is null, an exception will be thrown.

Beans that are not eligible for autowiring (as defined in Spring configuration) are ignored altogether.

Parameters:
fallback - The bean to select when no autowired dependencies can be found
autowiredTypes - The types of bean to autowire.
Returns:
the bean definition that will inject a bean of the required type


Copyright © 2010-2016. All Rights Reserved.