当前位置: 首页>>代码示例>>Java>>正文


Java BeanDefinition.getRole方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.BeanDefinition.getRole方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinition.getRole方法的具体用法?Java BeanDefinition.getRole怎么用?Java BeanDefinition.getRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.config.BeanDefinition的用法示例。


在下文中一共展示了BeanDefinition.getRole方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isOverriddenByExistingDefinition

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
protected boolean isOverriddenByExistingDefinition(BeanMethod beanMethod, String beanName) {
	if (!this.registry.containsBeanDefinition(beanName)) {
		return false;
	}
	BeanDefinition existingBeanDef = this.registry.getBeanDefinition(beanName);

	// Is the existing bean definition one that was created from a configuration class?
	// -> allow the current bean method to override, since both are at second-pass level.
	// However, if the bean method is an overloaded case on the same configuration class,
	// preserve the existing bean definition.
	if (existingBeanDef instanceof ConfigurationClassBeanDefinition) {
		ConfigurationClassBeanDefinition ccbd = (ConfigurationClassBeanDefinition) existingBeanDef;
		return (ccbd.getMetadata().getClassName().equals(beanMethod.getConfigurationClass().getMetadata().getClassName()));
	}

	// Has the existing bean definition bean marked as a framework-generated bean?
	// -> allow the current bean method to override it, since it is application-level
	if (existingBeanDef.getRole() > BeanDefinition.ROLE_APPLICATION) {
		return false;
	}

	// At this point, it's a top-level override (probably XML), just having been parsed
	// before configuration class processing kicks in...
	if (logger.isInfoEnabled()) {
		logger.info(String.format("Skipping bean definition for %s: a definition for bean '%s' " +
				"already exists. This top-level bean definition is considered as an override.",
				beanMethod, beanName));
	}
	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:ConfigurationClassBeanDefinitionReader.java

示例2: registerBeanDefinition

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
		throws BeanDefinitionStoreException {

	Assert.hasText(beanName, "Bean name must not be empty");
	Assert.notNull(beanDefinition, "BeanDefinition must not be null");

	if (beanDefinition instanceof AbstractBeanDefinition) {
		try {
			((AbstractBeanDefinition) beanDefinition).validate();
		}
		catch (BeanDefinitionValidationException ex) {
			throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName,
					"Validation of bean definition failed", ex);
		}
	}

	synchronized (this.beanDefinitionMap) {
		BeanDefinition oldBeanDefinition = this.beanDefinitionMap.get(beanName);
		if (oldBeanDefinition != null) {
			if (!this.allowBeanDefinitionOverriding) {
				throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName,
						"Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName +
						"': There is already [" + oldBeanDefinition + "] bound.");
			}
			else if (oldBeanDefinition.getRole() < beanDefinition.getRole()) {
				// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE
				if (this.logger.isWarnEnabled()) {
					this.logger.warn("Overriding user-defined bean definition for bean '" + beanName +
							" with a framework-generated bean definition ': replacing [" +
							oldBeanDefinition + "] with [" + beanDefinition + "]");
				}
			}
			else {
				if (this.logger.isInfoEnabled()) {
					this.logger.info("Overriding bean definition for bean '" + beanName +
							"': replacing [" + oldBeanDefinition + "] with [" + beanDefinition + "]");
				}
			}
		}
		else {
			this.beanDefinitionNames.add(beanName);
			this.frozenBeanDefinitionNames = null;
		}
		this.beanDefinitionMap.put(beanName, beanDefinition);
	}

	resetBeanDefinition(beanName);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:DefaultListableBeanFactory.java

示例3: isBeanEligible

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Determine whether the specified bean  is eligible for inclusion in the
 * LiveBeansView JSON snapshot.
 * @param beanName the name of the bean
 * @param bd the corresponding bean definition
 * @param bf the containing bean factory
 * @return {@code true} if the bean is to be included; {@code false} otherwise
 */
protected boolean isBeanEligible(String beanName, BeanDefinition bd, ConfigurableBeanFactory bf) {
	return (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
			(!bd.isLazyInit() || bf.containsSingleton(beanName)));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:LiveBeansView.java


注:本文中的org.springframework.beans.factory.config.BeanDefinition.getRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。