本文整理匯總了Java中org.springframework.context.ApplicationContext.containsBean方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationContext.containsBean方法的具體用法?Java ApplicationContext.containsBean怎麽用?Java ApplicationContext.containsBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.ApplicationContext
的用法示例。
在下文中一共展示了ApplicationContext.containsBean方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
if (StringUtils.isEmpty(userCacheBean)) {
if (applicationContext.containsBean(userServiceBean)) {
userDetailsService = (UserDetailsService) applicationContext
.getBean(userServiceBean);
} else {
throw new RuntimeException("Can not found spring bean["
+ userServiceBean + "] implements "
+ UserDetailsService.class.getName() + " interface!");
}
} else {
if (applicationContext.containsBean(userCacheBean)) {
userCache = (UserCache) applicationContext
.getBean(userServiceBean);
} else {
throw new RuntimeException("Can not found spring bean["
+ userCacheBean + "] implements "
+ UserCache.class.getName() + " interface!");
}
}
}
示例2: getExtension
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T> T getExtension(Class<T> type, String name) {
for (ApplicationContext context : contexts) {
if (context.containsBean(name)) {
Object bean = context.getBean(name);
if (type.isInstance(bean)) {
return (T) bean;
}
}
}
return null;
}
示例3: setApplicationContext
import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
boolean hasBean=applicationContext.containsBean(KnowledgePackageService.BEAN_ID);
if(hasBean){
knowledgePackageService=(KnowledgePackageService)applicationContext.getBean(KnowledgePackageService.BEAN_ID);
}
}