public class SpringContextHolder extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor
| 构造器和说明 |
|---|
SpringContextHolder() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
autowireBean(Object bean)
Autowire annotated from spring container for object
|
static boolean |
containsBean(String beanName)
Returns spring container contains specified bean name.
|
static void |
destroySingleton(String beanName) |
static String[] |
getAliases(String beanName)
Returns spring bean name other alias name.
|
static org.springframework.context.ApplicationContext |
getApplicationContext() |
static <T> T |
getBean(Class<T> beanType)
Gets spring bean by bean type.
|
static <T> T |
getBean(String beanName)
Gets spring bean by bean name.
|
static <T> T |
getBean(String beanName,
Class<T> beanType)
Gets spring bean by bean name and type.
|
static org.springframework.beans.factory.config.ConfigurableListableBeanFactory |
getConfigurableListableBeanFactory() |
static org.springframework.beans.factory.ListableBeanFactory |
getListableBeanFactory() |
static String |
getProperty(String key) |
static <T> T |
getPrototypeBean(Class<T> beanType)
Gets spring bean by bean type, if not defined bean then return null
|
static <T> T |
getPrototypeBean(String beanName) |
static <T> T |
getPrototypeBean(String beanName,
Class<T> beanType)
Gets spring bean by bean name and type, if not defined bean then return null
|
static <T> T |
getSingletonBean(Class<T> beanType)
Gets spring bean by bean type, if not defined bean then return null
|
static <T> T |
getSingletonBean(String beanName) |
static <T> T |
getSingletonBean(String beanName,
Class<T> beanType)
Gets spring bean by bean name and type, if not defined bean then return null
|
static Class<?> |
getType(String beanName)
Returns spring bean name type.
|
static boolean |
isNotNull() |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory bf) |
static void |
publishEvent(Object event) |
static <T> T |
registerBeanDefinition(String beanName,
Class<T> beanType,
Object... args)
Registers bean definition to spring container.
|
static void |
registerSingleton(String beanName,
Object bean) |
static void |
removeBeanDefinition(String beanName)
Removes bean definition from spring container.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext ctx) |
public void setApplicationContext(org.springframework.context.ApplicationContext ctx)
setApplicationContext 在接口中 org.springframework.context.ApplicationContextAwarepublic void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory bf)
throws org.springframework.beans.BeansException
postProcessBeanFactory 在接口中 org.springframework.beans.factory.config.BeanFactoryPostProcessororg.springframework.beans.BeansExceptionpublic static org.springframework.context.ApplicationContext getApplicationContext()
public static org.springframework.beans.factory.ListableBeanFactory getListableBeanFactory()
public static org.springframework.beans.factory.config.ConfigurableListableBeanFactory getConfigurableListableBeanFactory()
public static boolean isNotNull()
public static void publishEvent(Object event)
public static <T> T getBean(String beanName)
beanName - then bean namepublic static <T> T getBean(Class<T> beanType)
beanType - the bean typepublic static <T> T getBean(String beanName, Class<T> beanType)
beanName - the bean namebeanType - the bean typepublic static <T> T getPrototypeBean(String beanName) throws IllegalStateException
public static <T> T getPrototypeBean(Class<T> beanType) throws IllegalStateException
beanType - the bean typeIllegalStateException - if not prototype beanpublic static <T> T getPrototypeBean(String beanName, Class<T> beanType) throws IllegalStateException
beanName - the bean namebeanType - the bean typeIllegalStateException - if not prototype beanpublic static <T> T getSingletonBean(String beanName) throws IllegalStateException
public static <T> T getSingletonBean(Class<T> beanType) throws IllegalStateException
beanType - the bean typeIllegalStateException - if not singleton beanpublic static <T> T getSingletonBean(String beanName, Class<T> beanType) throws IllegalStateException
beanName - the bean namebeanType - the bean typeIllegalStateException - if not singleton beanpublic static boolean containsBean(String beanName)
beanName - the bean nametrue if contains beanpublic static Class<?> getType(String beanName)
beanName - then bean namepublic static String[] getAliases(String beanName)
beanName - then bean namepublic static void destroySingleton(String beanName)
public static <T> T registerBeanDefinition(String beanName, Class<T> beanType, Object... args)
T - bean typebeanName - the bean namebeanType - the bean typeargs - the bean type constructor argumentspublic static void removeBeanDefinition(String beanName)
beanName - the bean namepublic static void autowireBean(Object bean)
bean - the spring beanCopyright © 2025. All rights reserved.