Class ApplicationContextBeanLookupUtils
java.lang.Object
org.springframework.grpc.internal.ApplicationContextBeanLookupUtils
Convenience methods performing bean lookups that are not currently provided by the
standard Spring facilities.
NOTE: This is considered an internal non-public API despite its public method accessors.
- Author:
- Chris Bono
-
Method Summary
Modifier and TypeMethodDescriptionstatic <B, A extends Annotation>
List<B> getBeansWithAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<B> beanType, Class<A> annotationType) Find all beans which are annotated with the suppliedAnnotationtype.static <B, A extends Annotation>
LinkedHashMap<B, A> getOrderedBeansWithAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<B> beanType, Class<A> annotationType) Find all beans of the given type which may be annotated with the suppliedAnnotationtype and returns a map of matching bean instances with the annotation instance (or null if the bean is not annotated with the specified annotation type).static voidsortBeansIncludingOrderAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<?> beanType, List<?> beans) Sorts the supplied list in place using anOrderComparatorthat takes the@Orderannotation on bean factory methods in configuration classes into account.
-
Method Details
-
getOrderedBeansWithAnnotation
public static <B, A extends Annotation> LinkedHashMap<B,A> getOrderedBeansWithAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<B> beanType, Class<A> annotationType) Find all beans of the given type which may be annotated with the suppliedAnnotationtype and returns a map of matching bean instances with the annotation instance (or null if the bean is not annotated with the specified annotation type).Note that the map is ordered according to the matching beans
Orderannotation.Note that this method considers objects created by FactoryBeans, which means that FactoryBeans will get initialized in order to determine their object type.
- Type Parameters:
B- type of beanA- type of annotation- Parameters:
applicationContext- the application contextbeanType- the type of beanannotationType- the type of annotation- Returns:
- a map of matching bean instances with the annotation instance (or null)
ordered according to their
Orderwith annotation
-
getBeansWithAnnotation
public static <B, A extends Annotation> List<B> getBeansWithAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<B> beanType, Class<A> annotationType) Find all beans which are annotated with the suppliedAnnotationtype.Note that this method considers objects created by FactoryBeans, which means that FactoryBeans will get initialized in order to determine their object type.
- Type Parameters:
B- type of beanA- type of annotation- Parameters:
applicationContext- the application contextbeanType- the type of beanannotationType- the type of annotation- Returns:
- a list of the matching beans ordered according to their
Orderannotation
-
sortBeansIncludingOrderAnnotation
public static void sortBeansIncludingOrderAnnotation(org.springframework.context.ApplicationContext applicationContext, Class<?> beanType, List<?> beans) Sorts the supplied list in place using anOrderComparatorthat takes the@Orderannotation on bean factory methods in configuration classes into account.- Parameters:
applicationContext- the application contextbeanType- the type of beans in the listbeans- the list of beans to sort
-