Package org.grails.spring.beans.factory
Class GenericBeanFactoryAccessor
- java.lang.Object
-
- org.grails.spring.beans.factory.GenericBeanFactoryAccessor
-
public class GenericBeanFactoryAccessor extends java.lang.ObjectA fork of the Spring 2.5.6 GenericBeanFactoryAccess class that was removed from Spring 3.0.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description GenericBeanFactoryAccessor(org.springframework.beans.factory.ListableBeanFactory beanFactory)Constructs aGenericBeanFactoryAccessorthat wraps the suppliedListableBeanFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends java.lang.annotation.Annotation>
AfindAnnotationOnBean(java.lang.String beanName, java.lang.Class<A> annotationType)Find aAnnotationofannotationTypeon the specified bean, traversing its interfaces and super classes if no annotation can be found on the given class itself, as well as checking its raw bean class if not found on the exposed bean reference (e.g.<T> TgetBean(java.lang.String name)<T> TgetBean(java.lang.String name, java.lang.Class<T> requiredType)org.springframework.beans.factory.ListableBeanFactorygetBeanFactory()Return the wrappedListableBeanFactory.<T> java.util.Map<java.lang.String,T>getBeansOfType(java.lang.Class<T> type)<T> java.util.Map<java.lang.String,T>getBeansOfType(java.lang.Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)java.util.Map<java.lang.String,java.lang.Object>getBeansWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Find all beans whoseClasshas the suppliedAnnotationtype.
-
-
-
Method Detail
-
getBeanFactory
public final org.springframework.beans.factory.ListableBeanFactory getBeanFactory()
Return the wrappedListableBeanFactory.
-
getBean
public <T> T getBean(java.lang.String name) throws org.springframework.beans.BeansException- Throws:
org.springframework.beans.BeansException- See Also:
BeanFactory.getBean(String)
-
getBean
public <T> T getBean(java.lang.String name, java.lang.Class<T> requiredType) throws org.springframework.beans.BeansException- Throws:
org.springframework.beans.BeansException- See Also:
BeanFactory.getBean(String, Class)
-
getBeansOfType
public <T> java.util.Map<java.lang.String,T> getBeansOfType(java.lang.Class<T> type) throws org.springframework.beans.BeansException- Throws:
org.springframework.beans.BeansException- See Also:
ListableBeanFactory.getBeansOfType(Class)
-
getBeansOfType
public <T> java.util.Map<java.lang.String,T> getBeansOfType(java.lang.Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException- Throws:
org.springframework.beans.BeansException- See Also:
ListableBeanFactory.getBeansOfType(Class, boolean, boolean)
-
getBeansWithAnnotation
public java.util.Map<java.lang.String,java.lang.Object> getBeansWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Find all beans whoseClasshas the suppliedAnnotationtype.- Parameters:
annotationType- the type of annotation to look for- Returns:
- a Map with the matching beans, containing the bean names as keys and the corresponding bean instances as values
-
findAnnotationOnBean
public <A extends java.lang.annotation.Annotation> A findAnnotationOnBean(java.lang.String beanName, java.lang.Class<A> annotationType)Find aAnnotationofannotationTypeon the specified bean, traversing its interfaces and super classes if no annotation can be found on the given class itself, as well as checking its raw bean class if not found on the exposed bean reference (e.g. in case of a proxy).- Parameters:
beanName- the name of the bean to look for annotations onannotationType- the annotation class to look for- Returns:
- the annotation of the given type found, or
null - See Also:
AnnotationUtils.findAnnotation(Class, Class)
-
-