Class BeanFactoryUtils
- java.lang.Object
-
- io.microsphere.util.BaseUtils
-
- io.microsphere.spring.beans.factory.BeanFactoryUtils
-
public abstract class BeanFactoryUtils extends io.microsphere.util.BaseUtils
BeanFactory
Utilities class- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description BeanFactoryUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.beans.factory.config.AutowireCapableBeanFactory
asAutowireCapableBeanFactory(java.lang.Object beanFactory)
static org.springframework.beans.factory.support.BeanDefinitionRegistry
asBeanDefinitionRegistry(java.lang.Object beanFactory)
static org.springframework.beans.factory.config.ConfigurableBeanFactory
asConfigurableBeanFactory(java.lang.Object beanFactory)
static org.springframework.beans.factory.config.ConfigurableListableBeanFactory
asConfigurableListableBeanFactory(java.lang.Object beanFactory)
static org.springframework.beans.factory.support.DefaultListableBeanFactory
asDefaultListableBeanFactory(java.lang.Object beanFactory)
static org.springframework.beans.factory.HierarchicalBeanFactory
asHierarchicalBeanFactory(java.lang.Object beanFactory)
static org.springframework.beans.factory.ListableBeanFactory
asListableBeanFactory(java.lang.Object beanFactory)
static java.util.List<org.springframework.beans.factory.config.BeanPostProcessor>
getBeanPostProcessors(org.springframework.beans.factory.BeanFactory beanFactory)
Get all instances ofBeanPostProcessor
in the specifiedBeanFactory
static <T> java.util.List<T>
getBeans(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String[] beanNames, java.lang.Class<T> beanType)
Gets name-matched Beans fromBeanFactory
static <T> T
getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanName, java.lang.Class<T> beanType)
Get optional Beanstatic java.util.Set<java.lang.Class<?>>
getResolvableDependencyTypes(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Get theregistered
Resolvable Dependency Typesstatic java.util.Set<java.lang.Class<?>>
getResolvableDependencyTypes(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Get theregistered
Resolvable Dependency Typesstatic boolean
isBeanDefinitionRegistry(java.lang.Object beanFactory)
static boolean
isDefaultListableBeanFactory(java.lang.Object beanFactory)
Is the given BeanFactoryDefaultListableBeanFactory
-
-
-
Method Detail
-
getOptionalBean
public static <T> T getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanName, java.lang.Class<T> beanType)
Get optional Bean- Type Parameters:
T
- thetype
of Bean- Parameters:
beanFactory
-ListableBeanFactory
beanName
- the name of BeanbeanType
- thetype
of Bean- Returns:
- A bean if present , or
null
-
getBeans
public static <T> java.util.List<T> getBeans(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String[] beanNames, java.lang.Class<T> beanType)
Gets name-matched Beans fromBeanFactory
- Type Parameters:
T
- thetype
of Bean- Parameters:
beanFactory
-BeanFactory
beanNames
- the names of BeanbeanType
- thetype
of Bean- Returns:
- the read-only and non-null
List
of Bean names
-
isDefaultListableBeanFactory
public static boolean isDefaultListableBeanFactory(java.lang.Object beanFactory)
Is the given BeanFactoryDefaultListableBeanFactory
- Parameters:
beanFactory
-BeanFactory
- Returns:
true
if it'sDefaultListableBeanFactory
,false
otherwise
-
isBeanDefinitionRegistry
public static boolean isBeanDefinitionRegistry(java.lang.Object beanFactory)
-
asBeanDefinitionRegistry
public static org.springframework.beans.factory.support.BeanDefinitionRegistry asBeanDefinitionRegistry(java.lang.Object beanFactory)
-
asListableBeanFactory
public static org.springframework.beans.factory.ListableBeanFactory asListableBeanFactory(java.lang.Object beanFactory)
-
asHierarchicalBeanFactory
public static org.springframework.beans.factory.HierarchicalBeanFactory asHierarchicalBeanFactory(java.lang.Object beanFactory)
-
asConfigurableBeanFactory
public static org.springframework.beans.factory.config.ConfigurableBeanFactory asConfigurableBeanFactory(java.lang.Object beanFactory)
-
asAutowireCapableBeanFactory
public static org.springframework.beans.factory.config.AutowireCapableBeanFactory asAutowireCapableBeanFactory(java.lang.Object beanFactory)
-
asConfigurableListableBeanFactory
public static org.springframework.beans.factory.config.ConfigurableListableBeanFactory asConfigurableListableBeanFactory(java.lang.Object beanFactory)
-
asDefaultListableBeanFactory
public static org.springframework.beans.factory.support.DefaultListableBeanFactory asDefaultListableBeanFactory(java.lang.Object beanFactory)
-
getResolvableDependencyTypes
public static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Get theregistered
Resolvable Dependency Types- Parameters:
beanFactory
-ConfigurableListableBeanFactory
- Returns:
- non-null read-only
Set
-
getResolvableDependencyTypes
public static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Get theregistered
Resolvable Dependency Types- Parameters:
beanFactory
-DefaultListableBeanFactory
- Returns:
- non-null read-only
Set
-
getBeanPostProcessors
public static java.util.List<org.springframework.beans.factory.config.BeanPostProcessor> getBeanPostProcessors(@Nullable org.springframework.beans.factory.BeanFactory beanFactory)
Get all instances ofBeanPostProcessor
in the specifiedBeanFactory
- Parameters:
beanFactory
-BeanFactory
- Returns:
- non-null
List
-
-