public class BeanUtils extends Object implements org.springframework.context.ApplicationContextAware
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
BeanUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> void |
assertAutowiring(T instance)
Check that all fields that are marked with @Autowired are not null.
|
static <T> T |
getBean(org.springframework.beans.factory.access.BeanFactoryReference beanFactory,
String beanId,
Class<T> clazz)
Get a Spring bean by name.
|
static <T> T |
getBean(String contextId,
String beanId,
Class<T> clazz)
Helper method that combines getBeanFactory and getBean.
|
static org.springframework.beans.factory.access.BeanFactoryReference |
getBeanFactory(String contextId)
Get a Spring BeanFactory by context ID.
|
static <T> T |
getFactory(String contextId,
Class<T> clazz)
Helper method that calls getBeanFactory(contextId).getFactory()
and casts the result.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext context) |
static void |
setStaticApplicationContext(org.springframework.context.ApplicationContext context) |
public void setApplicationContext(org.springframework.context.ApplicationContext context)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public static void setStaticApplicationContext(org.springframework.context.ApplicationContext context)
public static org.springframework.beans.factory.access.BeanFactoryReference getBeanFactory(String contextId)
contextId
- the context ID of the BeanFactory to fetchpublic static <T> T getBean(org.springframework.beans.factory.access.BeanFactoryReference beanFactory, String beanId, Class<T> clazz)
T
- class for the returned beanbeanFactory
- bean factory to use to fetch this beanbeanId
- ID of the bean to fetchclazz
- class representing the type for the returned beanpublic static <T> T getBean(String contextId, String beanId, Class<T> clazz)
T
- class for the returned beancontextId
- the context ID of the BeanFactory from which to fetch
this beanbeanId
- ID of the bean to fetchclazz
- class representing the type for the returned beanpublic static <T> T getFactory(String contextId, Class<T> clazz)
T
- class for the returned factorycontextId
- the context ID of the BeanFactory to fetchclazz
- class representing the type for the returned factorypublic static <T> void assertAutowiring(T instance)
<context:annotation-config />
.Copyright © 2021. All rights reserved.