當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。