类 BeanUtils
- java.lang.Object
-
- io.microsphere.spring.util.BeanUtils
-
public abstract class BeanUtils extends java.lang.Object
Bean Utilities Class- 从以下版本开始:
- 2017.01.13
- 作者:
- Mercy
-
-
构造器概要
构造器 构造器 说明 BeanUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> T
getBeanIfAvailable(org.springframework.beans.factory.BeanFactory beanFactory, java.lang.String beanName, java.lang.Class<T> beanType)
Get the bean via the specified bean name and type if availablestatic java.lang.String[]
getBeanNames(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Get Bean Names fromListableBeanFactory
by type.static java.lang.String[]
getBeanNames(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Get Bean Names fromListableBeanFactory
by type.static java.lang.String[]
getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Get Bean Names fromListableBeanFactory
by type.static java.lang.String[]
getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Get Bean Names fromListableBeanFactory
by type.static <T> T
getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> beanClass)
Get Optional Bean byClass
.static <T> T
getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> beanClass, boolean includingAncestors)
Get Optional Bean byClass
including ancestors(BeanFactory).static <T> java.util.List<T>
getSortedBeans(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> type)
Get all sorted Beans ofListableBeanFactory
in specified bean type.static void
invokeAwareInterfaces(java.lang.Object bean, org.springframework.beans.factory.BeanFactory beanFactory)
Invoke theAware
interfaces in order :BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
static void
invokeAwareInterfaces(java.lang.Object bean, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)
Invoke theAware
interfaces in order :BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
static void
invokeAwareInterfaces(java.lang.Object bean, org.springframework.context.ConfigurableApplicationContext context)
InvokeAware
interfaces if the given bean implementsstatic void
invokeBeanInterfaces(java.lang.Object bean, org.springframework.context.ApplicationContext context)
Invoke Spring Bean interfaces in order:BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
InitializingBean
static void
invokeBeanInterfaces(java.lang.Object bean, org.springframework.context.ConfigurableApplicationContext context)
Invoke Spring Bean interfaces in order:BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
InitializingBean
static void
invokeBeanNameAware(java.lang.Object bean, java.lang.String beanName)
static void
invokeInitializingBean(java.lang.Object bean)
static boolean
isBeanPresent(org.springframework.beans.factory.BeanFactory beanFactory, java.lang.String beanName, java.lang.Class<?> beanClass)
Is Bean Present or not by the specified name and classstatic boolean
isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Is Bean Present or not?static boolean
isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Is Bean Present or not?static boolean
isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanClassName)
Is Bean Present or not?static boolean
isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanClassName, boolean includingAncestors)
Is Bean Present or not?static java.lang.Class<?>
resolveBeanType(java.lang.String beanClassName, java.lang.ClassLoader classLoader)
Resolve Bean Type
-
-
-
方法详细资料
-
isBeanPresent
public static boolean isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Is Bean Present or not?- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of Bean- 返回:
- If present , return
true
, orfalse
-
isBeanPresent
public static boolean isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Is Bean Present or not?- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of BeanincludingAncestors
- including ancestors or not- 返回:
- If present , return
true
, orfalse
-
isBeanPresent
public static boolean isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanClassName, boolean includingAncestors)
Is Bean Present or not?- 参数:
beanFactory
-ListableBeanFactory
beanClassName
- The name ofClass
of BeanincludingAncestors
- including ancestors or not- 返回:
- If present , return
true
, orfalse
-
isBeanPresent
public static boolean isBeanPresent(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanClassName)
Is Bean Present or not?- 参数:
beanFactory
-ListableBeanFactory
beanClassName
- The name ofClass
of Bean- 返回:
- If present , return
true
, orfalse
-
isBeanPresent
public static boolean isBeanPresent(org.springframework.beans.factory.BeanFactory beanFactory, java.lang.String beanName, java.lang.Class<?> beanClass) throws java.lang.NullPointerException
Is Bean Present or not by the specified name and class- 参数:
beanFactory
-BeanFactory
beanName
- The bean namebeanClass
- The bean class- 返回:
- If present , return
true
, orfalse
- 抛出:
java.lang.NullPointerException
- 从以下版本开始:
- 1.0.0
-
getBeanNames
public static java.lang.String[] getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Get Bean Names fromListableBeanFactory
by type.- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of Bean- 返回:
- If found , return the array of Bean Names , or empty array.
-
getBeanNames
public static java.lang.String[] getBeanNames(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Get Bean Names fromListableBeanFactory
by type.- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of BeanincludingAncestors
- including ancestors or not- 返回:
- If found , return the array of Bean Names , or empty array.
-
getBeanNames
public static java.lang.String[] getBeanNames(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, java.lang.Class<?> beanClass)
Get Bean Names fromListableBeanFactory
by type.- 参数:
beanFactory
-ConfigurableListableBeanFactory
beanClass
- TheClass
of Bean- 返回:
- If found , return the array of Bean Names , or empty array.
-
getBeanNames
public static java.lang.String[] getBeanNames(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, java.lang.Class<?> beanClass, boolean includingAncestors)
Get Bean Names fromListableBeanFactory
by type.- 参数:
beanFactory
-ConfigurableListableBeanFactory
beanClass
- TheClass
of BeanincludingAncestors
- including ancestors or not- 返回:
- If found , return the array of Bean Names , or empty array.
-
resolveBeanType
public static java.lang.Class<?> resolveBeanType(java.lang.String beanClassName, java.lang.ClassLoader classLoader)
Resolve Bean Type- 参数:
beanClassName
- the class name of BeanclassLoader
-ClassLoader
- 返回:
- Bean type if can be resolved , or return
null
.
-
getOptionalBean
public static <T> T getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> beanClass, boolean includingAncestors) throws org.springframework.beans.BeansException
Get Optional Bean byClass
including ancestors(BeanFactory).- 类型参数:
T
- TheClass
of Bean- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of BeanincludingAncestors
- including ancestors or not- 返回:
- Bean object if found , or return
null
. - 抛出:
org.springframework.beans.factory.NoUniqueBeanDefinitionException
- if more than one bean of the given type was foundorg.springframework.beans.BeansException
- 另请参阅:
BeanFactoryUtils.beanOfTypeIncludingAncestors(ListableBeanFactory, Class)
-
getOptionalBean
public static <T> T getOptionalBean(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> beanClass) throws org.springframework.beans.BeansException
Get Optional Bean byClass
.- 类型参数:
T
- TheClass
of Bean- 参数:
beanFactory
-ListableBeanFactory
beanClass
- TheClass
of Bean- 返回:
- Bean object if found , or return
null
. - 抛出:
org.springframework.beans.factory.NoUniqueBeanDefinitionException
- if more than one bean of the given type was foundorg.springframework.beans.BeansException
-
getBeanIfAvailable
public static <T> T getBeanIfAvailable(org.springframework.beans.factory.BeanFactory beanFactory, java.lang.String beanName, java.lang.Class<T> beanType) throws org.springframework.beans.BeansException
Get the bean via the specified bean name and type if available- 类型参数:
T
- the bean type- 参数:
beanFactory
-BeanFactory
beanName
- the bean namebeanType
- the class of bean- 返回:
- the bean if available, or
null
- 抛出:
org.springframework.beans.BeansException
- in case of creation errors- 从以下版本开始:
- 1.0.0
-
getSortedBeans
public static <T> java.util.List<T> getSortedBeans(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.Class<T> type)
Get all sorted Beans ofListableBeanFactory
in specified bean type.- 类型参数:
T
- bean type- 参数:
beanFactory
-ListableBeanFactory
type
- bean type- 返回:
- all sorted Beans
-
invokeBeanInterfaces
public static void invokeBeanInterfaces(java.lang.Object bean, org.springframework.context.ApplicationContext context)
Invoke Spring Bean interfaces in order:BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
InitializingBean
- 参数:
bean
- the beancontext
-ApplicationContext
-
invokeBeanInterfaces
public static void invokeBeanInterfaces(java.lang.Object bean, org.springframework.context.ConfigurableApplicationContext context)
Invoke Spring Bean interfaces in order:BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
InitializingBean
- 参数:
bean
- the beancontext
-ConfigurableApplicationContext
- 另请参阅:
invokeBeanInterfaces(Object, ApplicationContext)
,invokeAwareInterfaces(Object, ApplicationContext)
,invokeInitializingBean(Object)
-
invokeInitializingBean
public static void invokeInitializingBean(java.lang.Object bean) throws java.lang.Exception
- 抛出:
java.lang.Exception
-
invokeAwareInterfaces
public static void invokeAwareInterfaces(java.lang.Object bean, org.springframework.beans.factory.BeanFactory beanFactory)
Invoke theAware
interfaces in order :BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
if the argument
beanFactory is an instance ofApplicationContext
, the moreAware
interfaces will be involved :EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
- 参数:
bean
- the beanbeanFactory
-BeanFactory
-
invokeAwareInterfaces
public static void invokeAwareInterfaces(java.lang.Object bean, org.springframework.beans.factory.config.ConfigurableBeanFactory beanFactory)
Invoke theAware
interfaces in order :BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
if the argument
beanFactory is an instance ofApplicationContext
, the moreAware
interfaces will be involved :EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
- 参数:
bean
- the beanbeanFactory
-ConfigurableBeanFactory
-
invokeBeanNameAware
public static void invokeBeanNameAware(java.lang.Object bean, java.lang.String beanName)
-
invokeAwareInterfaces
public static void invokeAwareInterfaces(java.lang.Object bean, org.springframework.context.ConfigurableApplicationContext context)
InvokeAware
interfaces if the given bean implementsCurrent implementation keeps the order of invocation
Aware interfaces
:BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ResourceLoaderAware
ApplicationEventPublisherAware
MessageSourceAware
ApplicationStartupAware
(Spring Framework 5.3+)ApplicationContextAware
- 参数:
bean
- the beancontext
-ApplicationContext
- 另请参阅:
invokeAwareInterfaces(Object, BeanFactory)
,ApplicationContextAwareProcessor.invokeAwareInterfaces(Object)
,AbstractAutowireCapableBeanFactory.invokeAwareMethods(String, Object)
-
-