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


Java BeanDefinition.setAttribute方法代码示例

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


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

示例1: 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

示例2: parseAsHolder

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
public BeanDefinitionHolder parseAsHolder(Element componentElement, ParserContext parserContext) {
	// save parser context
	this.parserContext = parserContext;
	this.defaults = new BlueprintDefaultsDefinition(componentElement.getOwnerDocument(), parserContext);

	// let Spring do its standard parsing
	BeanDefinitionHolder bdHolder = parseComponentDefinitionElement(componentElement, null);

	BeanDefinition bd = bdHolder.getBeanDefinition();
	if (bd != null) {
		bd.setAttribute(ParsingUtils.BLUEPRINT_MARKER_NAME, Boolean.TRUE);
	}

	return bdHolder;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:16,代码来源:BlueprintParser.java

示例3: createScopedProxy

import org.springframework.beans.factory.config.BeanDefinition; //导入方法依赖的package包/类
/**
 * Generate a scoped proxy for the supplied target bean, registering the target
 * bean with an internal name and setting 'targetBeanName' on the scoped proxy.
 * @param definition the original bean definition
 * @param registry the bean definition registry
 * @param proxyTargetClass whether to create a target class proxy
 * @return the scoped proxy definition
 */
public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder definition,
		BeanDefinitionRegistry registry, boolean proxyTargetClass) {

	String originalBeanName = definition.getBeanName();
	BeanDefinition targetDefinition = definition.getBeanDefinition();
	String targetBeanName = getTargetBeanName(originalBeanName);

	// Create a scoped proxy definition for the original bean name,
	// "hiding" the target bean in an internal target definition.
	RootBeanDefinition proxyDefinition = new RootBeanDefinition(ScopedProxyFactoryBean.class);
	proxyDefinition.setDecoratedDefinition(new BeanDefinitionHolder(targetDefinition, targetBeanName));
	proxyDefinition.setOriginatingBeanDefinition(targetDefinition);
	proxyDefinition.setSource(definition.getSource());
	proxyDefinition.setRole(targetDefinition.getRole());

	proxyDefinition.getPropertyValues().add("targetBeanName", targetBeanName);
	if (proxyTargetClass) {
		targetDefinition.setAttribute(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE, Boolean.TRUE);
		// ScopedProxyFactoryBean's "proxyTargetClass" default is TRUE, so we don't need to set it explicitly here.
	}
	else {
		proxyDefinition.getPropertyValues().add("proxyTargetClass", Boolean.FALSE);
	}

	// Copy autowire settings from original bean definition.
	proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
	proxyDefinition.setPrimary(targetDefinition.isPrimary());
	if (targetDefinition instanceof AbstractBeanDefinition) {
		proxyDefinition.copyQualifiersFrom((AbstractBeanDefinition) targetDefinition);
	}

	// The target bean should be ignored in favor of the scoped proxy.
	targetDefinition.setAutowireCandidate(false);
	targetDefinition.setPrimary(false);

	// Register the target bean as separate bean in the factory.
	registry.registerBeanDefinition(targetBeanName, targetDefinition);

	// Return the scoped proxy definition as primary bean definition
	// (potentially an inner bean).
	return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:ScopedProxyUtils.java


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