public final class BeanRegistryUtils extends Object implements Serializable
| Modifier and Type | Method and Description |
|---|---|
static String |
buildBeanName(String dataContextId,
String name)
Build Spring bean name using optional data context id.
|
static <T> T |
getAnnotationValue(Map<String,Object> attributes,
String key,
T defaultValue)
Get the value of an annotation attribute
|
static Class<?> |
getBeanClass(String beanName,
org.springframework.beans.factory.config.BeanDefinition beanDefinition,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
ClassLoader classLoader)
Try to obtain the actual bean class of the bean with given name.
|
static List<String> |
getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory,
Class<?> type)
Get all the bean names of given
type in given bean factory. |
static Set<String> |
getBeanNamesOfTypes(org.springframework.beans.factory.ListableBeanFactory beanFactory,
Class<?>... types)
Get the bean names from provided registry of given types.
|
static List<String[]> |
getBeanNamesWithDataContextId(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.beans.factory.ListableBeanFactory beanFactory,
Class<?>... types)
Get the [name,data context id] pairs of the bean definition of given types.
|
static Set<String> |
getDataContextBeanNames(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.beans.factory.ListableBeanFactory beanFactory,
String dataContextId,
Class<?>... types)
Get the bean names from provided registry of given types and associated to given data context id.
|
public static String buildBeanName(String dataContextId, String name)
For example, if default name is myname and the data context id is test, this method
will return myname_test.
dataContextId - Data context id. May be null.name - Default bean namenull. Simple bean name otherwise.public static List<String> getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory, Class<?> type)
type in given bean factory.beanFactory - Bean factory (not null)type - Bean type (not null)type in given bean factory, an empty list if none.public static Set<String> getBeanNamesOfTypes(org.springframework.beans.factory.ListableBeanFactory beanFactory, Class<?>... types)
beanFactory - Bean factorytypes - Bean types to take into accountpublic static Set<String> getDataContextBeanNames(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.beans.factory.ListableBeanFactory beanFactory, String dataContextId, Class<?>... types)
registry - Bean registrybeanFactory - Bean factorydataContextId - The data context id, if null the name of any bean with given types will be
returnedtypes - Bean types to take into accountpublic static List<String[]> getBeanNamesWithDataContextId(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.beans.factory.ListableBeanFactory beanFactory, Class<?>... types)
registry - Bean definitions registrybeanFactory - Bean factorytypes - Bean types to take into accountpublic static Class<?> getBeanClass(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, ClassLoader classLoader)
beanName - Bean namebeanDefinition - Optional bean definitionbeanFactory - Bean factory (not null)classLoader - ClassLoader to usenull if cannot be detectedpublic static <T> T getAnnotationValue(Map<String,Object> attributes, String key, T defaultValue)
T - Default value typeattributes - Annotation attributeskey - Attribute namedefaultValue - Default value to return when attribute has no valueCopyright © 2019 The Holon Platform. All rights reserved.