@Component public class SpringContextsUtil extends Object implements org.springframework.context.ApplicationContextAware
| 构造器和说明 |
|---|
SpringContextsUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
containsBean(String name)
如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
|
static String[] |
getAliases(String name)
如果给定的bean名字在bean定义中有别名,则返回这些别名
|
static org.springframework.context.ApplicationContext |
getApplicationContext() |
static Object |
getBean(String name)
获取对象
|
static Object |
getBean(String name,
Class requiredType)
获取类型为requiredType的对象
如果bean不能被类型转换,相应的异常将会被抛出(BeanNotOfRequiredTypeException)
|
static Class |
getType(String name) |
static boolean |
isSingleton(String name)
判断以给定名字注册的bean定义是一个singleton还是一个prototype。
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
实现ApplicationContextAware接口的回调方法,设置上下文环境
|
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext 在接口中 org.springframework.context.ApplicationContextAwareapplicationContext - org.springframework.beans.BeansExceptionpublic static org.springframework.context.ApplicationContext getApplicationContext()
public static Object getBean(String name) throws org.springframework.beans.BeansException
name - org.springframework.beans.BeansExceptionpublic static Object getBean(String name, Class requiredType) throws org.springframework.beans.BeansException
name - bean注册名requiredType - 返回对象类型org.springframework.beans.BeansExceptionpublic static boolean containsBean(String name)
name - public static boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
name - org.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic static Class getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
name - org.springframework.beans.factory.NoSuchBeanDefinitionExceptionCopyright © 2013–2014 Shark Xu. All rights reserved.