当前位置: 首页>>代码示例>>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;未经允许,请勿转载。