@Component @Lazy(value=false) public class SpringContextHolder extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.DisposableBean
| 构造器和说明 |
|---|
SpringContextHolder() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
clearHolder()
清除SpringContextHolder中的ApplicationContext为Null.
|
void |
destroy()
实现DisposableBean接口, 在Context关闭时清理静态变量.
|
static org.springframework.context.ApplicationContext |
getApplicationContext()
取得存储在静态变量中的ApplicationContext.
|
static <T> T |
getBean(Class<T> requiredType)
从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
static <T> T |
getBean(String name)
从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
实现ApplicationContextAware接口, 注入Context到静态变量中.
|
public static org.springframework.context.ApplicationContext getApplicationContext()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext 在接口中 org.springframework.context.ApplicationContextAwarepublic static <T> T getBean(String name)
public static <T> T getBean(Class<T> requiredType)
public static void clearHolder()
public void destroy()
destroy 在接口中 org.springframework.beans.factory.DisposableBeanCopyright © 2021. All rights reserved.