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


Java BeanComponentDefinition类代码示例

本文整理汇总了Java中org.springframework.beans.factory.parsing.BeanComponentDefinition的典型用法代码示例。如果您正苦于以下问题:Java BeanComponentDefinition类的具体用法?Java BeanComponentDefinition怎么用?Java BeanComponentDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanComponentDefinition类属于org.springframework.beans.factory.parsing包,在下文中一共展示了BeanComponentDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseRefOrBean

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private Optional<RuntimeBeanReference> parseRefOrBean(Element elem, ParserContext ctx) {
    if (elem != null) {
        String ref = elem.getAttribute("ref").trim();

        Element beanEl = getChildElementByTagName(elem, "bean");

        if (!ref.isEmpty() && beanEl != null) {
            String name = elem.getLocalName();

            ctx.getReaderContext().error('<' + name + ">'s 'ref' attribute can't be mixed with nested <bean> element.", elem);
        } else if (!ref.isEmpty()) {
            return Optional.of(new RuntimeBeanReference(ref));
        } else if (beanEl != null) {
            BeanDefinitionHolder holder = ctx.getDelegate().parseBeanDefinitionElement(beanEl);

            ctx.registerBeanComponent(new BeanComponentDefinition(holder.getBeanDefinition(), holder.getBeanName()));

            return Optional.of(new RuntimeBeanReference(holder.getBeanName()));
        }
    }

    return Optional.empty();
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:24,代码来源:HekateBeanDefinitionParser.java

示例2: register

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
public static BeanDefinitionHolder register(Element ele, BeanDefinitionHolder bdHolder, ParserContext parserContext) {
	if (bdHolder != null) {
		String name = bdHolder.getBeanName();
		checkReservedName(name, ele, parserContext);
		checkUniqueName(name, parserContext.getRegistry());
		try {
			// add non-lenient constructor resolution
			BeanDefinition beanDefinition = bdHolder.getBeanDefinition();
			if (beanDefinition instanceof AbstractBeanDefinition) {
				AbstractBeanDefinition abd = (AbstractBeanDefinition) beanDefinition;
				abd.setLenientConstructorResolution(false);
				abd.setNonPublicAccessAllowed(false);
			}

			// Register the final decorated instance.
			BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, parserContext.getRegistry());
		} catch (BeanDefinitionStoreException ex) {
			parserContext.getReaderContext().error(
					"Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex);
		}
		// register component (and send registration events)
		parserContext.registerComponent(new BeanComponentDefinition(bdHolder));
	}
	return bdHolder;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:ParsingUtils.java

示例3: parse

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
	Object source = parserContext.extractSource(element);

	// Obtain bean definitions for all relevant BeanPostProcessors.
	Set<BeanDefinitionHolder> processorDefinitions =
			AnnotationConfigUtils.registerAnnotationConfigProcessors(parserContext.getRegistry(), source);

	// Register component for the surrounding <context:annotation-config> element.
	CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
	parserContext.pushContainingComponent(compDefinition);

	// Nest the concrete beans in the surrounding component.
	for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
		parserContext.registerComponent(new BeanComponentDefinition(processorDefinition));
	}

	// Finally register the composite component.
	parserContext.popAndRegisterContainingComponent();

	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AnnotationConfigBeanDefinitionParser.java

示例4: registerComponents

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
protected void registerComponents(
		XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

	Object source = readerContext.extractSource(element);
	CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

	for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
		compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
	}

	// Register annotation config processors, if necessary.
	boolean annotationConfig = true;
	if (element.hasAttribute(ANNOTATION_CONFIG_ATTRIBUTE)) {
		annotationConfig = Boolean.valueOf(element.getAttribute(ANNOTATION_CONFIG_ATTRIBUTE));
	}
	if (annotationConfig) {
		Set<BeanDefinitionHolder> processorDefinitions =
				AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
		for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
			compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
		}
	}

	readerContext.fireComponentRegistered(compositeDef);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ComponentScanBeanDefinitionParser.java

示例5: processBeanDefinition

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
/**
 * Process the given bean element, parsing the bean definition
 * and registering it with the registry.
 */
protected void processBeanDefinition(Element ele, BeanDefinitionParserDelegate delegate) {
	BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele);
	if (bdHolder != null) {
		bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder);
		try {
			// Register the final decorated instance.
			BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, getReaderContext().getRegistry());
		}
		catch (BeanDefinitionStoreException ex) {
			getReaderContext().error("Failed to register bean definition with name '" +
					bdHolder.getBeanName() + "'", ele, ex);
		}
		// Send registration event.
		getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:DefaultBeanDefinitionDocumentReader.java

示例6: decorate

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
	boolean proxyTargetClass = true;
	if (node instanceof Element) {
		Element ele = (Element) node;
		if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
			proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
		}
	}

	// Register the original bean definition as it will be referenced by the scoped proxy
	// and is relevant for tooling (validation, navigation).
	BeanDefinitionHolder holder =
			ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);
	String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());
	parserContext.getReaderContext().fireComponentRegistered(
			new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
	return holder;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ScopedProxyBeanDefinitionDecorator.java

示例7: doParse

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private synchronized void doParse(Element element, ParserContext parserContext) {
    String[] basePackages = StringUtils.tokenizeToStringArray(element.getAttribute("base-package"), ",; \t\n");
    AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);
    if (!parserContext.getRegistry().containsBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME)) {
        Object eleSource = parserContext.extractSource(element);

        RootBeanDefinition configMapDef = new RootBeanDefinition(ConcurrentHashMap.class);
        configMapDef.setSource(eleSource);
        configMapDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        String configMapName = parserContext.getReaderContext().registerWithGeneratedName(configMapDef);

        RootBeanDefinition interceptorDef = new RootBeanDefinition(JetCacheInterceptor.class);
        interceptorDef.setSource(eleSource);
        interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        interceptorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

        RootBeanDefinition advisorDef = new RootBeanDefinition(CacheAdvisor.class);
        advisorDef.setSource(eleSource);
        advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("adviceBeanName", interceptorName));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("cacheConfigMap", new RuntimeBeanReference(configMapName)));
        advisorDef.getPropertyValues().addPropertyValue(new PropertyValue("basePackages", basePackages));
        parserContext.getRegistry().registerBeanDefinition(CacheAdvisor.CACHE_ADVISOR_BEAN_NAME, advisorDef);

        CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(),
                eleSource);
        compositeDef.addNestedComponent(new BeanComponentDefinition(configMapDef, configMapName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
        compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, CacheAdvisor.CACHE_ADVISOR_BEAN_NAME));
        parserContext.registerComponent(compositeDef);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:34,代码来源:CacheAnnotationParser.java

示例8: registerAsyncExecutionAspect

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) {
	if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) {
		BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME);
		builder.setFactoryMethod("aspectOf");
		String executor = element.getAttribute("executor");
		if (StringUtils.hasText(executor)) {
			builder.addPropertyReference("executor", executor);
		}
		String exceptionHandler = element.getAttribute("exception-handler");
		if (StringUtils.hasText(exceptionHandler)) {
			builder.addPropertyReference("exceptionHandler", exceptionHandler);
		}
		parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(),
				TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:AnnotationDrivenBeanDefinitionParser.java

示例9: registerUrlPathHelper

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
/**
 * Adds an alias to an existing well-known name or registers a new instance of a {@link UrlPathHelper}
 * under that well-known name, unless already registered.
 * @return a RuntimeBeanReference to this {@link UrlPathHelper} instance
 */
public static RuntimeBeanReference registerUrlPathHelper(RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) {
	if (urlPathHelperRef != null) {
		if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
			parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME);
		}
		parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
	}
	else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)
			&& !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
		RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class);
		urlPathHelperDef.setSource(source);
		urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(URL_PATH_HELPER_BEAN_NAME, urlPathHelperDef);
		parserContext.registerComponent(new BeanComponentDefinition(urlPathHelperDef, URL_PATH_HELPER_BEAN_NAME));
	}
	return new RuntimeBeanReference(URL_PATH_HELPER_BEAN_NAME);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:MvcNamespaceUtils.java

示例10: registerPathMatcher

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
/**
 * Adds an alias to an existing well-known name or registers a new instance of a {@link PathMatcher}
 * under that well-known name, unless already registered.
 * @return a RuntimeBeanReference to this {@link PathMatcher} instance
 */
public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
	if (pathMatcherRef != null) {
		if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
			parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
		}
		parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
	}
	else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
			&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
		RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
		pathMatcherDef.setSource(source);
		pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(PATH_MATCHER_BEAN_NAME, pathMatcherDef);
		parserContext.registerComponent(new BeanComponentDefinition(pathMatcherDef, PATH_MATCHER_BEAN_NAME));
	}
	return new RuntimeBeanReference(PATH_MATCHER_BEAN_NAME);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:MvcNamespaceUtils.java

示例11: registerHandlerMapping

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private BeanDefinition registerHandlerMapping(ParserContext context, Object source) {
	if (context.getRegistry().containsBeanDefinition(HANDLER_MAPPING_BEAN_NAME)) {
		return context.getRegistry().getBeanDefinition(HANDLER_MAPPING_BEAN_NAME);
	}
	RootBeanDefinition beanDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
	beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	context.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME, beanDef);
	context.registerComponent(new BeanComponentDefinition(beanDef, HANDLER_MAPPING_BEAN_NAME));

	beanDef.setSource(source);
	beanDef.getPropertyValues().add("order", "1");
	beanDef.getPropertyValues().add("pathMatcher", MvcNamespaceUtils.registerPathMatcher(null, context, source));
	beanDef.getPropertyValues().add("urlPathHelper", MvcNamespaceUtils.registerUrlPathHelper(null, context, source));
	RuntimeBeanReference corsConfigurationsRef = MvcNamespaceUtils.registerCorsConfigurations(null, context, source);
	beanDef.getPropertyValues().add("corsConfigurations", corsConfigurationsRef);

	return beanDef;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:ViewControllerBeanDefinitionParser.java

示例12: registerUrlProvider

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private void registerUrlProvider(ParserContext parserContext, Object source) {
	if (!parserContext.getRegistry().containsBeanDefinition(RESOURCE_URL_PROVIDER)) {
		RootBeanDefinition urlProvider = new RootBeanDefinition(ResourceUrlProvider.class);
		urlProvider.setSource(source);
		urlProvider.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		parserContext.getRegistry().registerBeanDefinition(RESOURCE_URL_PROVIDER, urlProvider);
		parserContext.registerComponent(new BeanComponentDefinition(urlProvider, RESOURCE_URL_PROVIDER));

		RootBeanDefinition interceptor = new RootBeanDefinition(ResourceUrlProviderExposingInterceptor.class);
		interceptor.setSource(source);
		interceptor.getConstructorArgumentValues().addIndexedArgumentValue(0, urlProvider);

		RootBeanDefinition mappedInterceptor = new RootBeanDefinition(MappedInterceptor.class);
		mappedInterceptor.setSource(source);
		mappedInterceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		mappedInterceptor.getConstructorArgumentValues().addIndexedArgumentValue(0, (Object) null);
		mappedInterceptor.getConstructorArgumentValues().addIndexedArgumentValue(1, interceptor);
		String mappedInterceptorName = parserContext.getReaderContext().registerWithGeneratedName(mappedInterceptor);
		parserContext.registerComponent(new BeanComponentDefinition(mappedInterceptor, mappedInterceptorName));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:ResourcesBeanDefinitionParser.java

示例13: getValidator

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private RuntimeBeanReference getValidator(Element element, Object source, ParserContext parserContext) {
	if (element.hasAttribute("validator")) {
		return new RuntimeBeanReference(element.getAttribute("validator"));
	}
	else if (javaxValidationPresent) {
		RootBeanDefinition validatorDef = new RootBeanDefinition(
				"org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean");
		validatorDef.setSource(source);
		validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String validatorName = parserContext.getReaderContext().registerWithGeneratedName(validatorDef);
		parserContext.registerComponent(new BeanComponentDefinition(validatorDef, validatorName));
		return new RuntimeBeanReference(validatorName);
	}
	else {
		return null;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AnnotationDrivenBeanDefinitionParser.java

示例14: registerComponents

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
protected void registerComponents(
        XmlReaderContext readerContext, Set<BeanDefinitionHolder> beanDefinitions, Element element) {

    Object source = readerContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);

    for (BeanDefinitionHolder beanDefHolder : beanDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(beanDefHolder));
    }

    // Register annotation config processors, if necessary.
    Set<BeanDefinitionHolder> processorDefinitions =
            AnnotationConfigUtils.registerAnnotationConfigProcessors(readerContext.getRegistry(), source);
    for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
        compositeDef.addNestedComponent(new BeanComponentDefinition(processorDefinition));
    }

    readerContext.fireComponentRegistered(compositeDef);
}
 
开发者ID:xyp260466,项目名称:dubbo-lite,代码行数:20,代码来源:AutoBeanDefinitionParser.java

示例15: autoRegisterBeanDefinition

import org.springframework.beans.factory.parsing.BeanComponentDefinition; //导入依赖的package包/类
private void autoRegisterBeanDefinition(String id, BeanDefinition definition, ParserContext parserContext, String contextId) {
    // it is a bit cumbersome to work with the spring bean definition parser
    // as we kinda need to eagerly register the bean definition on the parser context
    // and then later we might find out that we should not have done that in case we have multiple camel contexts
    // that would have a id clash by auto registering the same bean definition with the same id such as a producer template

    // see if we have already auto registered this id
    BeanDefinition existing = autoRegisterMap.get(id);
    if (existing == null) {
        // no then add it to the map and register it
        autoRegisterMap.put(id, definition);
        parserContext.registerComponent(new BeanComponentDefinition(definition, id));
        if (LOG.isDebugEnabled()) {
            LOG.debug("Registered default: {} with id: {} on camel context: {}", new Object[]{definition.getBeanClassName(), id, contextId});
        }
    } else {
        // ups we have already registered it before with same id, but on another camel context
        // this is not good so we need to remove all traces of this auto registering.
        // end user must manually add the needed XML elements and provide unique ids access all camel context himself.
        LOG.debug("Unregistered default: {} with id: {} as we have multiple camel contexts and they must use unique ids."
                + " You must define the definition in the XML file manually to avoid id clashes when using multiple camel contexts",
                definition.getBeanClassName(), id);

        parserContext.getRegistry().removeBeanDefinition(id);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:CamelNamespaceHandler.java


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