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


Java BeanDefinition.getAttribute方法代碼示例

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


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

示例1: validateServiceReferences

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
protected void validateServiceReferences(Element element, String serviceId, ParserContext parserContext) {
	BeanDefinitionRegistry registry = parserContext.getRegistry();
	String[] names = registry.getBeanDefinitionNames();

	for (String name : names) {
		BeanDefinition definition = registry.getBeanDefinition(name);
		Collection<String> exporters =
				(Collection<String>) definition.getAttribute(ParserUtils.REFERENCE_LISTENER_REF_ATTR);

		if (exporters != null && exporters.contains(serviceId)) {
			parserContext.getReaderContext()
					.error(
							"Service exporter '" + serviceId + "' cannot be used as a reference listener by '"
									+ name + "'", element);
		}
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:18,代碼來源:ServiceBeanDefinitionParser.java

示例2: addSyntheticDependsOn

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
private void addSyntheticDependsOn(BeanDefinition definition, String beanName) {
	if (StringUtils.hasText(beanName)) {
		String[] dependsOn = definition.getDependsOn();
		if (dependsOn != null && dependsOn.length > 0) {
			for (String dependOn : dependsOn) {
				if (beanName.equals(dependOn)) {
					return;
				}
			}
		}

		// add depends on
		dependsOn = (String[]) ObjectUtils.addObjectToArray(dependsOn, beanName);
		definition.setDependsOn(dependsOn);
		Collection<String> markers = (Collection<String>) definition.getAttribute(SYNTHETIC_DEPENDS_ON);
		if (markers == null) {
			markers = new ArrayList<String>(2);
			definition.setAttribute(SYNTHETIC_DEPENDS_ON, markers);
		}
		markers.add(beanName);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:23,代碼來源:CycleOrderingProcessor.java

示例3: resolveRefreshCheckDelay

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
/**
 * Get the refresh check delay for the given {@link ScriptFactory} {@link BeanDefinition}.
 * If the {@link BeanDefinition} has a
 * {@link org.springframework.core.AttributeAccessor metadata attribute}
 * under the key {@link #REFRESH_CHECK_DELAY_ATTRIBUTE} which is a valid {@link Number}
 * type, then this value is used. Otherwise, the the {@link #defaultRefreshCheckDelay}
 * value is used.
 * @param beanDefinition the BeanDefinition to check
 * @return the refresh check delay
 */
protected long resolveRefreshCheckDelay(BeanDefinition beanDefinition) {
	long refreshCheckDelay = this.defaultRefreshCheckDelay;
	Object attributeValue = beanDefinition.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
	if (attributeValue instanceof Number) {
		refreshCheckDelay = ((Number) attributeValue).longValue();
	}
	else if (attributeValue instanceof String) {
		refreshCheckDelay = Long.parseLong((String) attributeValue);
	}
	else if (attributeValue != null) {
		throw new BeanDefinitionStoreException("Invalid refresh check delay attribute [" +
				REFRESH_CHECK_DELAY_ATTRIBUTE + "] with value '" + attributeValue +
				"': needs to be of type Number or String");
	}
	return refreshCheckDelay;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:ScriptFactoryPostProcessor.java

示例4: resolveProxyTargetClass

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
protected boolean resolveProxyTargetClass(BeanDefinition beanDefinition) {
	boolean proxyTargetClass = this.defaultProxyTargetClass;
	Object attributeValue = beanDefinition.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
	if (attributeValue instanceof Boolean) {
		proxyTargetClass = (Boolean) attributeValue;
	}
	else if (attributeValue instanceof String) {
		proxyTargetClass = Boolean.valueOf((String) attributeValue);
	}
	else if (attributeValue != null) {
		throw new BeanDefinitionStoreException("Invalid proxy target class attribute [" +
				PROXY_TARGET_CLASS_ATTRIBUTE + "] with value '" + attributeValue +
				"': needs to be of type Boolean or String");
	}
	return proxyTargetClass;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ScriptFactoryPostProcessor.java

示例5: buildMetadata

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
/**
 * Builds a component metadata from the given bean definition.
 * 
 * @param name bean name
 * @param beanDefinition
 * @return
 */
static ComponentMetadata buildMetadata(String name, BeanDefinition beanDefinition) {
	// shortcut (to avoid re-re-wrapping)
	Object metadata = beanDefinition.getAttribute(COMPONENT_METADATA_ATTRIBUTE);
	if (metadata instanceof ComponentMetadata)
		return (ComponentMetadata) metadata;

	// if no name has been given, look for one
	if (name == null) {
		name = (String) beanDefinition.getAttribute(COMPONENT_NAME);
	}

	if (isServiceExporter(beanDefinition)) {
		return new SimpleServiceExportComponentMetadata(name, beanDefinition);
	}

	if (isSingleServiceImporter(beanDefinition)) {
		return new SimpleReferenceMetadata(name, beanDefinition);
	}
	if (isCollectionImporter(beanDefinition)) {
		return new SimpleReferenceListMetadata(name, beanDefinition);
	}

	BeanDefinition original = unwrapImporterReference(beanDefinition);
	if (original != null) {
		return buildMetadata(null, original);
	}

	if (isEnvironmentManager(beanDefinition)) {
		return new EnvironmentManagerMetadata(name);
	}

	return new SimpleBeanMetadata(name, beanDefinition);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:41,代碼來源:ComponentMetadataFactory.java

示例6: shouldSkip

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
/**
 * Check whether the given bean definition is not subject to the annotation-based
 * required property check as performed by this post-processor.
 * <p>The default implementations check for the presence of the
 * {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any.
 * It also suggests skipping in case of a bean definition with a "factory-bean"
 * reference set, assuming that instance-based factories pre-populate the bean.
 * @param beanFactory the BeanFactory to check against
 * @param beanName the name of the bean to check against
 * @return {@code true} to skip the bean; {@code false} to process it
 */
protected boolean shouldSkip(ConfigurableListableBeanFactory beanFactory, String beanName) {
	if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) {
		return false;
	}
	BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
	if (beanDefinition.getFactoryBeanName() != null) {
		return true;
	}
	Object value = beanDefinition.getAttribute(SKIP_REQUIRED_CHECK_ATTRIBUTE);
	return (value != null && (Boolean.TRUE.equals(value) || Boolean.valueOf(value.toString())));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:RequiredAnnotationBeanPostProcessor.java

示例7: postProcessBeforeInstantiation

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
@Override
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) {
	// We only apply special treatment to ScriptFactory implementations here.
	if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
		return null;
	}

	BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
	String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
	String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
	prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);

	ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
	ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
	boolean isFactoryBean = false;
	try {
		Class<?> scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
		// Returned type may be null if the factory is unable to determine the type.
		if (scriptedObjectType != null) {
			isFactoryBean = FactoryBean.class.isAssignableFrom(scriptedObjectType);
		}
	}
	catch (Exception ex) {
		throw new BeanCreationException(beanName,
				"Could not determine scripted object type for " + scriptFactory, ex);
	}

	long refreshCheckDelay = resolveRefreshCheckDelay(bd);
	if (refreshCheckDelay >= 0) {
		Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
		RefreshableScriptTargetSource ts = new RefreshableScriptTargetSource(this.scriptBeanFactory,
				scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
		boolean proxyTargetClass = resolveProxyTargetClass(bd);
		String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
		if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
			throw new BeanDefinitionValidationException(
					"Cannot use proxyTargetClass=true with script beans where language is not 'groovy': '" +
					language + "'");
		}
		ts.setRefreshCheckDelay(refreshCheckDelay);
		return createRefreshableProxy(ts, interfaces, proxyTargetClass);
	}

	if (isFactoryBean) {
		scriptedObjectBeanName = BeanFactory.FACTORY_BEAN_PREFIX + scriptedObjectBeanName;
	}
	return this.scriptBeanFactory.getBean(scriptedObjectBeanName);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:49,代碼來源:ScriptFactoryPostProcessor.java


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