當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurableBeanFactory.containsBean方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.ConfigurableBeanFactory.containsBean方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurableBeanFactory.containsBean方法的具體用法?Java ConfigurableBeanFactory.containsBean怎麽用?Java ConfigurableBeanFactory.containsBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.config.ConfigurableBeanFactory的用法示例。


在下文中一共展示了ConfigurableBeanFactory.containsBean方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addBeanFactoryDependency

import org.springframework.beans.factory.config.ConfigurableBeanFactory; //導入方法依賴的package包/類
private void addBeanFactoryDependency() {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
		if (StringUtils.hasText(beanName) && cbf.containsBean(beanName)) {
			// no need to validate targetBeanName (already did)
			cbf.registerDependentBean(targetBeanName, BeanFactory.FACTORY_BEAN_PREFIX + beanName);
			cbf.registerDependentBean(targetBeanName, beanName);
		}
	} else {
		log.warn("The running bean factory cannot support dependencies between beans "
				+ "- importer/exporter dependency cannot be enforced");
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:14,代碼來源:OsgiServiceFactoryBean.java

示例2: autowireResource

import org.springframework.beans.factory.config.ConfigurableBeanFactory; //導入方法依賴的package包/類
/**
 * Obtain a resource object for the given name and type through autowiring
 * based on the given factory.
 * @param factory the factory to autowire against
 * @param element the descriptor for the annotated field/method
 * @param requestingBeanName the name of the requesting bean
 * @return the resource object (never {@code null})
 * @throws BeansException if we failed to obtain the target resource
 */
protected Object autowireResource(BeanFactory factory, LookupElement element, String requestingBeanName)
		throws BeansException {

	Object resource;
	Set<String> autowiredBeanNames;
	String name = element.name;

	if (this.fallbackToDefaultTypeMatch && element.isDefaultName &&
			factory instanceof AutowireCapableBeanFactory && !factory.containsBean(name)) {
		autowiredBeanNames = new LinkedHashSet<String>();
		resource = ((AutowireCapableBeanFactory) factory).resolveDependency(
				element.getDependencyDescriptor(), requestingBeanName, autowiredBeanNames, null);
	}
	else {
		resource = factory.getBean(name, element.lookupType);
		autowiredBeanNames = Collections.singleton(name);
	}

	if (factory instanceof ConfigurableBeanFactory) {
		ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) factory;
		for (String autowiredBeanName : autowiredBeanNames) {
			if (beanFactory.containsBean(autowiredBeanName)) {
				beanFactory.registerDependentBean(autowiredBeanName, requestingBeanName);
			}
		}
	}

	return resource;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:CommonAnnotationBeanPostProcessor.java

示例3: factoryContainsBean

import org.springframework.beans.factory.config.ConfigurableBeanFactory; //導入方法依賴的package包/類
/**
 * Check the BeanFactory to see whether the bean named <var>beanName</var> already
 * exists. Accounts for the fact that the requested bean may be "in creation", i.e.:
 * we're in the middle of servicing the initial request for this bean. From an enhanced
 * factory method's perspective, this means that the bean does not actually yet exist,
 * and that it is now our job to create it for the first time by executing the logic
 * in the corresponding factory method.
 * <p>Said another way, this check repurposes
 * {@link ConfigurableBeanFactory#isCurrentlyInCreation(String)} to determine whether
 * the container is calling this method or the user is calling this method.
 * @param beanName name of bean to check for
 * @return whether <var>beanName</var> already exists in the factory
 */
private boolean factoryContainsBean(ConfigurableBeanFactory beanFactory, String beanName) {
	return (beanFactory.containsBean(beanName) && !beanFactory.isCurrentlyInCreation(beanName));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ConfigurationClassEnhancer.java


注:本文中的org.springframework.beans.factory.config.ConfigurableBeanFactory.containsBean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。