类org.springframework.beans.factory.xml.ParserContext源码实例Demo

下面列出了怎么用org.springframework.beans.factory.xml.ParserContext的API类实例代码及写法,或者点击链接到github查看源代码。

private BeanDefinition registerHandlerMapping(ParserContext context, @Nullable 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;
}
 
/**
 * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong>
 * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes.
 */
private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) {
	RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
	advisorDefinition.setSource(parserContext.extractSource(advisorElement));

	String adviceRef = advisorElement.getAttribute(ADVICE_REF);
	if (!StringUtils.hasText(adviceRef)) {
		parserContext.getReaderContext().error(
				"'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot());
	}
	else {
		advisorDefinition.getPropertyValues().add(
				ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef));
	}

	if (advisorElement.hasAttribute(ORDER_PROPERTY)) {
		advisorDefinition.getPropertyValues().add(
				ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY));
	}

	return advisorDefinition;
}
 
@Override
@Nullable
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;
}
 
@Override
public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) {
	String pathAttribute = element.getAttribute("path");
	String[] mappings = StringUtils.tokenizeToStringArray(pathAttribute, ",");
	RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler"));

	ConstructorArgumentValues cargs = new ConstructorArgumentValues();
	cargs.addIndexedArgumentValue(0, this.sockJsService, "SockJsService");
	cargs.addIndexedArgumentValue(1, handlerReference, "WebSocketHandler");

	RootBeanDefinition requestHandlerDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cargs, null);
	requestHandlerDef.setSource(context.extractSource(element));
	requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef);
	RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName);

	for (String mapping : mappings) {
		String pathPattern = (mapping.endsWith("/") ? mapping + "**" : mapping + "/**");
		urlMap.put(pathPattern, requestHandlerRef);
	}
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
	String contextPath = element.getAttribute("context-path");
	if (StringUtils.hasText(contextPath)) {
		beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
	}

	List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
	if (!classes.isEmpty()) {
		ManagedList<String> classesToBeBound = new ManagedList<>(classes.size());
		for (Element classToBeBound : classes) {
			String className = classToBeBound.getAttribute("name");
			classesToBeBound.add(className);
		}
		beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound);
	}
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	super.doParse(element, parserContext, builder);

	builder.addPropertyValue("ignoreUnresolvablePlaceholders",
			Boolean.valueOf(element.getAttribute("ignore-unresolvable")));

	String systemPropertiesModeName = element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIBUTE);
	if (StringUtils.hasLength(systemPropertiesModeName) &&
			!systemPropertiesModeName.equals(SYSTEM_PROPERTIES_MODE_DEFAULT)) {
		builder.addPropertyValue("systemPropertiesModeName", "SYSTEM_PROPERTIES_MODE_" + systemPropertiesModeName);
	}

	if (element.hasAttribute("value-separator")) {
		builder.addPropertyValue("valueSeparator", element.getAttribute("value-separator"));
	}
	if (element.hasAttribute("trim-values")) {
		builder.addPropertyValue("trimValues", element.getAttribute("trim-values"));
	}
	if (element.hasAttribute("null-value")) {
		builder.addPropertyValue("nullValue", element.getAttribute("null-value"));
	}
}
 
源代码7 项目: redisson   文件: RedissonDefinitionParser.java
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
    if (element.hasChildNodes()) {
        CompositeComponentDefinition compositeDef
                = new CompositeComponentDefinition(parentId,
                        parserContext.extractSource(element));
        parserContext.pushContainingComponent(compositeDef);
        List<Element> childElts = DomUtils.getChildElements(element);
        for (Element elt : childElts) {
            if (BeanDefinitionParserDelegate.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
                continue; //parsed elsewhere
            }
            String localName = parserContext.getDelegate().getLocalName(elt);
            localName = Conventions.attributeNameToPropertyName(localName);
            if (ConfigType.contains(localName)) {
                parseConfigTypes(elt, localName, redissonDef, parserContext);
            } else if (AddressType.contains(localName)) {
                parseAddressTypes(elt, localName, redissonDef, parserContext);
            } else if (helper.isRedissonNS(elt)) {
                elt.setAttribute(REDISSON_REF, redissonRef);
                parserContext.getDelegate().parseCustomElement(elt);
            }
        }
        parserContext.popContainingComponent();
    }
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element));

	List<Element> txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES_ELEMENT);
	if (txAttributes.size() > 1) {
		parserContext.getReaderContext().error(
				"Element <attributes> is allowed at most once inside element <advice>", element);
	}
	else if (txAttributes.size() == 1) {
		// Using attributes source.
		Element attributeSourceElement = txAttributes.get(0);
		RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext);
		builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition);
	}
	else {
		// Assume annotations source.
		builder.addPropertyValue("transactionAttributeSource",
				new RootBeanDefinition("org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"));
	}
}
 
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;
	}
}
 
private RuntimeBeanReference registerUserDestHandler(Element brokerElem,
		RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel,
		RuntimeBeanReference brokerChannel, ParserContext context, Object source) {

	Object userDestResolver = registerUserDestResolver(brokerElem, userRegistry, context, source);

	RootBeanDefinition beanDef = new RootBeanDefinition(UserDestinationMessageHandler.class);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, inChannel);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerChannel);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, userDestResolver);

	Element relayElement = DomUtils.getChildElementByTagName(brokerElem, "stomp-broker-relay");
	if (relayElement != null && relayElement.hasAttribute("user-destination-broadcast")) {
		String destination = relayElement.getAttribute("user-destination-broadcast");
		beanDef.getPropertyValues().add("broadcastDestination", destination);
	}

	String beanName = registerBeanDef(beanDef, context, source);
	return new RuntimeBeanReference(beanName);
}
 
/**
 * Parse a '{@code declare-parents}' element and register the appropriate
 * DeclareParentsAdvisor with the BeanDefinitionRegistry encapsulated in the
 * supplied ParserContext.
 */
private AbstractBeanDefinition parseDeclareParents(Element declareParentsElement, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DeclareParentsAdvisor.class);
	builder.addConstructorArgValue(declareParentsElement.getAttribute(IMPLEMENT_INTERFACE));
	builder.addConstructorArgValue(declareParentsElement.getAttribute(TYPE_PATTERN));

	String defaultImpl = declareParentsElement.getAttribute(DEFAULT_IMPL);
	String delegateRef = declareParentsElement.getAttribute(DELEGATE_REF);

	if (StringUtils.hasText(defaultImpl) && !StringUtils.hasText(delegateRef)) {
		builder.addConstructorArgValue(defaultImpl);
	}
	else if (StringUtils.hasText(delegateRef) && !StringUtils.hasText(defaultImpl)) {
		builder.addConstructorArgReference(delegateRef);
	}
	else {
		parserContext.getReaderContext().error(
				"Exactly one of the " + DEFAULT_IMPL + " or " + DELEGATE_REF + " attributes must be specified",
				declareParentsElement, this.parseState.snapshot());
	}

	AbstractBeanDefinition definition = builder.getBeanDefinition();
	definition.setSource(parserContext.extractSource(declareParentsElement));
	parserContext.getReaderContext().registerWithGeneratedName(definition);
	return definition;
}
 
源代码12 项目: dubbox-hystrix   文件: DubboBeanDefinitionParser.java
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
    NodeList nodeList = element.getChildNodes();
    if (nodeList != null && nodeList.getLength() > 0) {
        boolean first = true;
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if (tag.equals(node.getNodeName())
                        || tag.equals(node.getLocalName())) {
                    if (first) {
                        first = false;
                        String isDefault = element.getAttribute("default");
                        if (isDefault == null || isDefault.length() == 0) {
                            beanDefinition.getPropertyValues().addPropertyValue("default", "false");
                        }
                    }
                    BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
                    if (subDefinition != null && ref != null && ref.length() > 0) {
                        subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
                    }
                }
            }
        }
    }
}
 
源代码13 项目: redisson   文件: RedissonDefinitionParser.java
private void parseConfigTypes(Element element, String configType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
    BeanDefinitionBuilder builder
            = helper.createBeanDefinitionBuilder(element,
                    parserContext, null);
    //Use factory method on the Config bean
    AbstractBeanDefinition bd = builder.getRawBeanDefinition();
    bd.setFactoryMethodName("use" + StringUtils.capitalize(configType));
    bd.setFactoryBeanName(parserContext.getContainingComponent().getName());
    String id = parserContext.getReaderContext().generateBeanName(bd);
    helper.registerBeanDefinition(builder, id,
            helper.parseAliase(element), parserContext);
    helper.parseAttributes(element, parserContext, builder);
    redissonDef.addDependsOn(id);
    parseChildElements(element, id, null, redissonDef, parserContext);
    parserContext.getDelegate().parseQualifierElements(element, bd);
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	List<Element> childElements = DomUtils.getChildElementsByTagName(element, "definitions");
	if (!childElements.isEmpty()) {
		List<String> locations = new ArrayList<String>(childElements.size());
		for (Element childElement : childElements) {
			locations.add(childElement.getAttribute("location"));
		}
		builder.addPropertyValue("definitions", locations.toArray(new String[locations.size()]));
	}
	if (element.hasAttribute("check-refresh")) {
		builder.addPropertyValue("checkRefresh", element.getAttribute("check-refresh"));
	}
	if (element.hasAttribute("validate-definitions")) {
		builder.addPropertyValue("validateDefinitions", element.getAttribute("validate-definitions"));
	}
	if (element.hasAttribute("definitions-factory")) {
		builder.addPropertyValue("definitionsFactoryClass", element.getAttribute("definitions-factory"));
	}
	if (element.hasAttribute("preparer-factory")) {
		builder.addPropertyValue("preparerFactoryClass", element.getAttribute("preparer-factory"));
	}
}
 
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));
	}
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
	String contextPath = element.getAttribute("context-path");
	if (!StringUtils.hasText(contextPath)) {
		// Backwards compatibility with 3.x version of the xsd
		contextPath = element.getAttribute("contextPath");
	}
	if (StringUtils.hasText(contextPath)) {
		beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
	}

	List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
	if (!classes.isEmpty()) {
		ManagedList<String> classesToBeBound = new ManagedList<String>(classes.size());
		for (Element classToBeBound : classes) {
			String className = classToBeBound.getAttribute("name");
			classesToBeBound.add(className);
		}
		beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound);
	}
}
 
private ManagedList<?> getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) {
	ManagedList<? super Object> interceptors = new ManagedList<Object>();
	Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
	if (asyncElement != null) {
		Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors");
		if (interceptorsElement != null) {
			interceptors.setSource(source);
			for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
				BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
				beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
				interceptors.add(beanDef);
			}
		}
	}
	return interceptors;
}
 
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
	List<Element> childElements = DomUtils.getChildElementsByTagName(element, "definitions");
	if (!childElements.isEmpty()) {
		List<String> locations = new ArrayList<>(childElements.size());
		for (Element childElement : childElements) {
			locations.add(childElement.getAttribute("location"));
		}
		builder.addPropertyValue("definitions", StringUtils.toStringArray(locations));
	}
	if (element.hasAttribute("check-refresh")) {
		builder.addPropertyValue("checkRefresh", element.getAttribute("check-refresh"));
	}
	if (element.hasAttribute("validate-definitions")) {
		builder.addPropertyValue("validateDefinitions", element.getAttribute("validate-definitions"));
	}
	if (element.hasAttribute("definitions-factory")) {
		builder.addPropertyValue("definitionsFactoryClass", element.getAttribute("definitions-factory"));
	}
	if (element.hasAttribute("preparer-factory")) {
		builder.addPropertyValue("preparerFactoryClass", element.getAttribute("preparer-factory"));
	}
}
 
public static RuntimeBeanReference registerScheduler(
		String schedulerName, ParserContext context, @Nullable Object source) {

	if (!context.getRegistry().containsBeanDefinition(schedulerName)) {
		RootBeanDefinition taskSchedulerDef = new RootBeanDefinition(ThreadPoolTaskScheduler.class);
		taskSchedulerDef.setSource(source);
		taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
		taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
		taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
		context.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
		context.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));
	}
	return new RuntimeBeanReference(schedulerName);
}
 
源代码20 项目: cxf   文件: BusDefinitionParser.java
@Override
protected void mapElement(ParserContext ctx,
                          BeanDefinitionBuilder bean,
                          Element e,
                          String name) {
    if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name)
        || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)
        || "features".equals(name)) {
        List<?> list = ctx.getDelegate().parseListElement(e, bean.getBeanDefinition());
        bean.addPropertyValue(name, list);
    } else if ("properties".equals(name)) {
        Map<?, ?> map = ctx.getDelegate().parseMapElement(e, bean.getBeanDefinition());
        bean.addPropertyValue("properties", map);
    }
}
 
protected AbstractBeanDefinition parseInternal(Element element,
		ParserContext context) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
			"com.github.moonkev.spring.integration.zmq.ZmqContextManager");
	builder.addConstructorArgValue(element.getAttribute("io-threads"));
	return builder.getBeanDefinition();
}
 
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DataSourceInitializer.class);
	builder.addPropertyReference("dataSource", element.getAttribute("data-source"));
	builder.addPropertyValue("enabled", element.getAttribute("enabled"));
	DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder);
	builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
	return builder.getBeanDefinition();
}
 
源代码23 项目: conf4j   文件: AbstractClassBeanDefinitionParser.java
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionRegistry registry = parserContext.getRegistry();
    BeanDefinitionBuilder builder = getBeanDefinitionBuilder(element, parserContext);
    if (builder == null) {
        return null;
    }

    AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
    String beanName = resolveId(element, beanDefinition, parserContext);
    registry.registerBeanDefinition(beanName, beanDefinition);

    return beanDefinition;
}
 
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
    BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(beanClass);
    factory.addConstructorArgValue(element.getAttribute(ShardingSphereAlgorithmBeanDefinitionTag.TYPE_ATTRIBUTE));
    factory.addConstructorArgValue(parsePropsElement(element, parserContext));
    return factory.getBeanDefinition();
}
 
private void registerAnnotationMethodMessageHandler(Element messageBrokerElement,
		RuntimeBeanReference inChannel, RuntimeBeanReference outChannel,
		RuntimeBeanReference converter, RuntimeBeanReference messagingTemplate,
		ParserContext context, @Nullable Object source) {

	ConstructorArgumentValues cargs = new ConstructorArgumentValues();
	cargs.addIndexedArgumentValue(0, inChannel);
	cargs.addIndexedArgumentValue(1, outChannel);
	cargs.addIndexedArgumentValue(2, messagingTemplate);

	MutablePropertyValues values = new MutablePropertyValues();
	String prefixAttribute = messageBrokerElement.getAttribute("application-destination-prefix");
	values.add("destinationPrefixes", Arrays.asList(StringUtils.tokenizeToStringArray(prefixAttribute, ",")));
	values.add("messageConverter", converter);

	RootBeanDefinition beanDef = new RootBeanDefinition(WebSocketAnnotationMethodMessageHandler.class, cargs, values);
	if (messageBrokerElement.hasAttribute("path-matcher")) {
		String pathMatcherRef = messageBrokerElement.getAttribute("path-matcher");
		beanDef.getPropertyValues().add("pathMatcher", new RuntimeBeanReference(pathMatcherRef));
	}

	RuntimeBeanReference validatorRef = getValidator(messageBrokerElement, source, context);
	if (validatorRef != null) {
		beanDef.getPropertyValues().add("validator", validatorRef);
	}

	Element resolversElement = DomUtils.getChildElementByTagName(messageBrokerElement, "argument-resolvers");
	if (resolversElement != null) {
		values.add("customArgumentResolvers", extractBeanSubElements(resolversElement, context));
	}

	Element handlersElement = DomUtils.getChildElementByTagName(messageBrokerElement, "return-value-handlers");
	if (handlersElement != null) {
		values.add("customReturnValueHandlers", extractBeanSubElements(handlersElement, context));
	}

	registerBeanDef(beanDef, context, source);
}
 
@Override
@Nullable
public BeanDefinition parse(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element);
	extendBeanDefinition(element, parserContext);
	return null;
}
 
/**
 * Parses the {@code pointcut} or {@code pointcut-ref} attributes of the supplied
 * {@link Element} and add a {@code pointcut} property as appropriate. Generates a
 * {@link org.springframework.beans.factory.config.BeanDefinition} for the pointcut if  necessary
 * and returns its bean name, otherwise returns the bean name of the referred pointcut.
 */
@Nullable
private Object parsePointcutProperty(Element element, ParserContext parserContext) {
	if (element.hasAttribute(POINTCUT) && element.hasAttribute(POINTCUT_REF)) {
		parserContext.getReaderContext().error(
				"Cannot define both 'pointcut' and 'pointcut-ref' on <advisor> tag.",
				element, this.parseState.snapshot());
		return null;
	}
	else if (element.hasAttribute(POINTCUT)) {
		// Create a pointcut for the anonymous pc and register it.
		String expression = element.getAttribute(POINTCUT);
		AbstractBeanDefinition pointcutDefinition = createPointcutDefinition(expression);
		pointcutDefinition.setSource(parserContext.extractSource(element));
		return pointcutDefinition;
	}
	else if (element.hasAttribute(POINTCUT_REF)) {
		String pointcutRef = element.getAttribute(POINTCUT_REF);
		if (!StringUtils.hasText(pointcutRef)) {
			parserContext.getReaderContext().error(
					"'pointcut-ref' attribute contains empty value.", element, this.parseState.snapshot());
			return null;
		}
		return pointcutRef;
	}
	else {
		parserContext.getReaderContext().error(
				"Must define one of 'pointcut' or 'pointcut-ref' on <advisor> tag.",
				element, this.parseState.snapshot());
		return null;
	}
}
 
源代码28 项目: lams   文件: ScheduledTasksBeanDefinitionParser.java
private RuntimeBeanReference triggerTaskReference(String runnableBeanName,
		String triggerBeanName, Element taskElement, ParserContext parserContext) {
	BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
			"org.springframework.scheduling.config.TriggerTask");
	builder.addConstructorArgReference(runnableBeanName);
	builder.addConstructorArgReference(triggerBeanName);
	return beanReference(taskElement, parserContext, builder);
}
 
源代码29 项目: cxf   文件: HttpDestinationBeanDefinitionParser.java
@Override
public void doParse(Element element, ParserContext ctc, BeanDefinitionBuilder bean) {
    bean.setAbstract(true);
    mapElementToJaxbProperty(element, bean,
            new QName(HTTP_NS, "server"), "server");
    mapElementToJaxbProperty(element, bean,
            new QName(HTTP_NS, "fixedParameterOrder"),
                               "fixedParameterOrder");
    mapElementToJaxbProperty(element, bean,
            new QName(HTTP_NS, "contextMatchStrategy"),
                               "contextMatchStrategy");
}
 
private RuntimeBeanReference registerUserRegistryMessageHandler(
		RuntimeBeanReference userRegistry, RuntimeBeanReference brokerTemplate,
		String destination, ParserContext context, Object source) {

	Object scheduler = WebSocketNamespaceUtils.registerScheduler(SCHEDULER_BEAN_NAME, context, source);

	RootBeanDefinition beanDef = new RootBeanDefinition(UserRegistryMessageHandler.class);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, userRegistry);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerTemplate);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, destination);
	beanDef.getConstructorArgumentValues().addIndexedArgumentValue(3, scheduler);

	String beanName = registerBeanDef(beanDef, context, source);
	return new RuntimeBeanReference(beanName);
}
 
 同包方法