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


Java BeanDefinitionBuilder.setRole方法代码示例

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


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

示例1: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	BundleActionCallback callback = new BundleActionCallback();

	ParserUtils.parseCustomAttributes(element, builder, new AttributeCallback[] { callback });

	// parse nested definition (in case there is any)

	if (element.hasChildNodes()) {
		NodeList nodes = element.getChildNodes();
		boolean foundElement = false;
		for (int i = 0; i < nodes.getLength() && !foundElement; i++) {
			Node nd = nodes.item(i);
			if (nd instanceof Element) {
				foundElement = true;
				Object obj =
						parserContext.getDelegate().parsePropertySubElement((Element) nd,
								builder.getBeanDefinition());
				builder.addPropertyValue(BUNDLE_PROP, obj);
			}
		}
	}
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:BundleBeanDefinitionParser.java

示例2: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();

	Class<?> beanClass = getBeanClass(element);
	Assert.notNull(beanClass);

	if (beanClass != null) {
		builder.getRawBeanDefinition().setBeanClass(beanClass);
	}

	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));

	OsgiDefaultsDefinition defaults = resolveDefaults(element.getOwnerDocument(), parserContext);
	applyDefaults(parserContext, defaults, builder);

	doParse(element, parserContext, builder);

	AbstractBeanDefinition def = builder.getBeanDefinition();

	// check whether the bean is mandatory (and if it is, make it top-level
	// bean)
	if (parserContext.isNested()) {
		String value = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
		value = (StringUtils.hasText(value) ? value + BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR : "");
		String generatedName = generateBeanName(value, def, parserContext);
		// make the bean lazy (since it is an inner bean initiallly)
		def.setLazyInit(true);
		// disable autowiring for promoted bean
		def.setAutowireCandidate(false);
		def.setAttribute(PROMOTED_REF, Boolean.TRUE);

		BeanDefinitionHolder holder = new BeanDefinitionHolder(def, generatedName);
		BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
		return createBeanReferenceDefinition(generatedName, def);
	}

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

示例3: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {

		BeanDefinitionBuilder registrarDefinitionBuilder =
				BeanDefinitionBuilder.genericBeanDefinition(BlueprintConverterConfigurer.class);

		List<Element> components = DomUtils.getChildElementsByTagName(element, BlueprintParser.BEAN);
		List<Element> componentRefs =
				DomUtils.getChildElementsByTagName(element, BeanDefinitionParserDelegate.REF_ELEMENT);

		ManagedList<Object> converterList = new ManagedList<Object>(componentRefs.size() + components.size());

		// add components
		for (Element component : components) {
			converterList.add(BlueprintParser.parsePropertySubElement(parserContext, component,
					registrarDefinitionBuilder.getBeanDefinition()));
		}
		// followed by bean references
		for (Element componentRef : componentRefs) {
			converterList.add(BlueprintParser.parsePropertySubElement(parserContext, componentRef,
					registrarDefinitionBuilder.getBeanDefinition()));
		}
		// add the list to the registrar definition
		registrarDefinitionBuilder.addConstructorArgValue(converterList);
		registrarDefinitionBuilder.setRole(BeanDefinition.ROLE_SUPPORT);
		registrarDefinitionBuilder.getRawBeanDefinition().setSynthetic(true);

		// build the CustomEditorConfigurer
		return registrarDefinitionBuilder.getBeanDefinition();
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:30,代码来源:TypeConverterBeanDefinitionParser.java

示例4: registerPostProcessor

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private static void registerPostProcessor(
		ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) {

	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition());
	BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName);
	parserContext.registerComponent(new BeanComponentDefinition(holder));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AnnotationDrivenBeanDefinitionParser.java

示例5: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
	String location = element.getAttribute("location");
	if (StringUtils.hasLength(location)) {
		String[] locations = StringUtils.commaDelimitedListToStringArray(location);
		builder.addPropertyValue("locations", locations);
	}

	String propertiesRef = element.getAttribute("properties-ref");
	if (StringUtils.hasLength(propertiesRef)) {
		builder.addPropertyReference("properties", propertiesRef);
	}

	String fileEncoding = element.getAttribute("file-encoding");
	if (StringUtils.hasLength(fileEncoding)) {
		builder.addPropertyValue("fileEncoding", fileEncoding);
	}

	String order = element.getAttribute("order");
	if (StringUtils.hasLength(order)) {
		builder.addPropertyValue("order", Integer.valueOf(order));
	}

	builder.addPropertyValue("ignoreResourceNotFound",
			Boolean.valueOf(element.getAttribute("ignore-resource-not-found")));

	builder.addPropertyValue("localOverride",
			Boolean.valueOf(element.getAttribute("local-override")));

	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AbstractPropertyLoadingBeanDefinitionParser.java

示例6: doParse

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

	if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) {
		RootBeanDefinition weavingEnablerDef = new RootBeanDefinition();
		weavingEnablerDef.setBeanClassName(ASPECTJ_WEAVING_ENABLER_CLASS_NAME);
		parserContext.getReaderContext().registerWithGeneratedName(weavingEnablerDef);

		if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) {
			new SpringConfiguredBeanDefinitionParser().parse(element, parserContext);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:LoadTimeWeaverBeanDefinitionParser.java

示例7: parseInternal

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);

	// Mark as infrastructure bean and attach source location.
	builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));

	String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE);
	if (StringUtils.hasText(defaultDomain)) {
		builder.addPropertyValue("defaultDomain", defaultDomain);
	}

	String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
	if (StringUtils.hasText(serverBeanName)) {
		builder.addPropertyReference("server", serverBeanName);
	}
	else {
		AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
		if (specialServer != null) {
			builder.addPropertyValue("server", specialServer);
		}
	}

	String registration = element.getAttribute(REGISTRATION_ATTRIBUTE);
	RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING;
	if (REGISTRATION_IGNORE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.IGNORE_EXISTING;
	}
	else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) {
		registrationPolicy = RegistrationPolicy.REPLACE_EXISTING;
	}
	builder.addPropertyValue("registrationPolicy", registrationPolicy);

	return builder.getBeanDefinition();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:MBeanExportBeanDefinitionParser.java

示例8: parseListener

import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
public static BeanDefinition parseListener(ParserContext context, Element element, BeanDefinitionBuilder builder) {

		// filter elements
		NodeList nl = element.getChildNodes();

		// wrapped object
		Object target = null;
		// target bean name (used for cycles)
		String targetName = null;

		// discover if we have listener with ref and nested bean declaration
		for (int i = 0; i < nl.getLength(); i++) {
			Node node = nl.item(i);
			if (node instanceof Element) {
				Element nestedDefinition = (Element) node;
				// check shortcut on the parent
				if (element.hasAttribute(REF))
					context.getReaderContext().error(
						"nested bean declaration is not allowed if 'ref' attribute has been specified",
						nestedDefinition);

				target = context.getDelegate().parsePropertySubElement(nestedDefinition, builder.getBeanDefinition());
				// if this is a bean reference (nested <ref>), extract the name
				if (target instanceof RuntimeBeanReference) {
					targetName = ((RuntimeBeanReference) target).getBeanName();
				}
			}
		}

		// extract registration/unregistration attributes from
		// <osgi:registration-listener>
		BeanDefinitionBuilder localBuilder = BeanDefinitionBuilder.rootBeanDefinition(OsgiServiceRegistrationListenerAdapter.class);
		localBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		
		NamedNodeMap attrs = element.getAttributes();
		for (int x = 0; x < attrs.getLength(); x++) {
			Attr attribute = (Attr) attrs.item(x);
			String name = attribute.getLocalName();

			if (REF.equals(name))
				targetName = attribute.getValue();
			else
				localBuilder.addPropertyValue(Conventions.attributeNameToPropertyName(name), attribute.getValue());
		}

		// set the target name (if we have one)
		if (targetName != null)
			localBuilder.addPropertyValue(TARGET_BEAN_NAME_PROP, targetName);
		// else set the actual target
		else
			localBuilder.addPropertyValue(TARGET_PROP, target);

		return localBuilder.getBeanDefinition();
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:55,代码来源:ServiceParsingUtils.java


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