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