Java Code Examples for org.springframework.beans.factory.support.ManagedList#setSource()

The following examples show how to use org.springframework.beans.factory.support.ManagedList#setSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourcesBeanDefinitionParser.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void parseResourceChain(
		RootBeanDefinition resourceHandlerDef, ParserContext context, Element element, @Nullable Object source) {

	String autoRegistration = element.getAttribute("auto-registration");
	boolean isAutoRegistration = !(StringUtils.hasText(autoRegistration) && "false".equals(autoRegistration));

	ManagedList<Object> resourceResolvers = new ManagedList<>();
	resourceResolvers.setSource(source);
	ManagedList<Object> resourceTransformers = new ManagedList<>();
	resourceTransformers.setSource(source);

	parseResourceCache(resourceResolvers, resourceTransformers, element, source);
	parseResourceResolversTransformers(
			isAutoRegistration, resourceResolvers, resourceTransformers, context, element, source);

	if (!resourceResolvers.isEmpty()) {
		resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
	}
	if (!resourceTransformers.isEmpty()) {
		resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers);
	}
}
 
Example 2
Source File: AnnotationDrivenBeanDefinitionParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private ManagedList<?> getCallableInterceptors(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, "callable-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;
}
 
Example 3
Source File: AnnotationDrivenBeanDefinitionParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: AspectJAutoProxyBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
	ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node node = childNodes.item(i);
		if (node instanceof Element) {
			Element includeElement = (Element) node;
			TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
			valueHolder.setSource(parserContext.extractSource(includeElement));
			includePatterns.add(valueHolder);
		}
	}
	if (!includePatterns.isEmpty()) {
		includePatterns.setSource(parserContext.extractSource(element));
		beanDef.getPropertyValues().add("includePatterns", includePatterns);
	}
}
 
Example 5
Source File: AspectJAutoProxyBeanDefinitionParser.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
	ManagedList<TypedStringValue> includePatterns = new ManagedList<>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node node = childNodes.item(i);
		if (node instanceof Element) {
			Element includeElement = (Element) node;
			TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
			valueHolder.setSource(parserContext.extractSource(includeElement));
			includePatterns.add(valueHolder);
		}
	}
	if (!includePatterns.isEmpty()) {
		includePatterns.setSource(parserContext.extractSource(element));
		beanDef.getPropertyValues().add("includePatterns", includePatterns);
	}
}
 
Example 6
Source File: ResourcesBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private void parseResourceChain(RootBeanDefinition resourceHandlerDef, ParserContext parserContext,
		Element element, Object source) {

	String autoRegistration = element.getAttribute("auto-registration");
	boolean isAutoRegistration = !(StringUtils.hasText(autoRegistration) && "false".equals(autoRegistration));

	ManagedList<? super Object> resourceResolvers = new ManagedList<Object>();
	resourceResolvers.setSource(source);
	ManagedList<? super Object> resourceTransformers = new ManagedList<Object>();
	resourceTransformers.setSource(source);

	parseResourceCache(resourceResolvers, resourceTransformers, element, source);
	parseResourceResolversTransformers(isAutoRegistration, resourceResolvers, resourceTransformers,
			parserContext, element, source);

	if (!resourceResolvers.isEmpty()) {
		resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
	}
	if (!resourceTransformers.isEmpty()) {
		resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers);
	}
}
 
Example 7
Source File: AnnotationDrivenBeanDefinitionParser.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private ManagedList<?> getDeferredResultInterceptors(
		Element element, @Nullable Object source, ParserContext context) {

	ManagedList<Object> interceptors = new ManagedList<>();
	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 = context.getDelegate().parseBeanDefinitionElement(converter);
				if (beanDef != null) {
					beanDef = context.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
					interceptors.add(beanDef);
				}
			}
		}
	}
	return interceptors;
}
 
Example 8
Source File: AspectJAutoProxyBeanDefinitionParser.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
	ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node node = childNodes.item(i);
		if (node instanceof Element) {
			Element includeElement = (Element) node;
			TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
			valueHolder.setSource(parserContext.extractSource(includeElement));
			includePatterns.add(valueHolder);
		}
	}
	if (!includePatterns.isEmpty()) {
		includePatterns.setSource(parserContext.extractSource(element));
		beanDef.getPropertyValues().add("includePatterns", includePatterns);
	}
}
 
Example 9
Source File: MessageBrokerBeanDefinitionParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private RuntimeBeanReference registerMessageConverter(
		Element element, ParserContext context, @Nullable Object source) {

	Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
	ManagedList<Object> converters = new ManagedList<>();
	if (convertersElement != null) {
		converters.setSource(source);
		for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
			Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
			converters.add(object);
		}
	}
	if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
		converters.setSource(source);
		converters.add(new RootBeanDefinition(StringMessageConverter.class));
		converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class));
		if (jackson2Present) {
			RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class);
			RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class);
			resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON);
			jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef);
			// Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically
			GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition();
			jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class);
			jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
			jacksonFactoryDef.setSource(source);
			jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef);
			converters.add(jacksonConverterDef);
		}
	}
	ConstructorArgumentValues cargs = new ConstructorArgumentValues();
	cargs.addIndexedArgumentValue(0, converters);
	RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cargs, null);
	String name = MESSAGE_CONVERTER_BEAN_NAME;
	registerBeanDefByName(name, messageConverterDef, context, source);
	return new RuntimeBeanReference(name);
}
 
Example 10
Source File: MessageBrokerBeanDefinitionParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private ManagedList<Object> extractBeanSubElements(Element parentElement, ParserContext context) {
	ManagedList<Object> list = new ManagedList<>();
	list.setSource(context.extractSource(parentElement));
	for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
		Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
		list.add(object);
	}
	return list;
}
 
Example 11
Source File: WebSocketNamespaceUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public static ManagedList<Object> parseBeanSubElements(@Nullable Element parentElement, ParserContext context) {
	ManagedList<Object> beans = new ManagedList<>();
	if (parentElement != null) {
		beans.setSource(context.extractSource(parentElement));
		for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
			beans.add(context.getDelegate().parsePropertySubElement(beanElement, null));
		}
	}
	return beans;
}
 
Example 12
Source File: BeanDefinitionParserDelegate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Parse a list element.
 */
public List<Object> parseListElement(Element collectionEle, @Nullable BeanDefinition bd) {
	String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = collectionEle.getChildNodes();
	ManagedList<Object> target = new ManagedList<>(nl.getLength());
	target.setSource(extractSource(collectionEle));
	target.setElementTypeName(defaultElementType);
	target.setMergeEnabled(parseMergeAttribute(collectionEle));
	parseCollectionElements(nl, target, bd, defaultElementType);
	return target;
}
 
Example 13
Source File: NettyHttpServerEngineFactoryBeanDefinitionParser.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<Object> getRequiredElementsList(Element parent, ParserContext ctx, QName name,
                                     BeanDefinitionBuilder bean) {

    List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(parent,
                                                                 name.getNamespaceURI(),
                                                                 name.getLocalPart());
    ManagedList<Object> list = new ManagedList<>(elemList.size());
    list.setSource(ctx.extractSource(parent));

    for (Element elem : elemList) {
        list.add(ctx.getDelegate().parsePropertySubElement(elem, bean.getBeanDefinition()));
    }
    return list;
}
 
Example 14
Source File: BeanDefinitionParserDelegate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Parse a list element.
 */
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) {
	String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = collectionEle.getChildNodes();
	ManagedList<Object> target = new ManagedList<Object>(nl.getLength());
	target.setSource(extractSource(collectionEle));
	target.setElementTypeName(defaultElementType);
	target.setMergeEnabled(parseMergeAttribute(collectionEle));
	parseCollectionElements(nl, target, bd, defaultElementType);
	return target;
}
 
Example 15
Source File: MessageBrokerBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) {
	Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters");
	ManagedList<? super Object> converters = new ManagedList<Object>();
	if (convertersElement != null) {
		converters.setSource(source);
		for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) {
			Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
			converters.add(object);
		}
	}
	if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) {
		converters.setSource(source);
		converters.add(new RootBeanDefinition(StringMessageConverter.class));
		converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class));
		if (jackson2Present) {
			RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class);
			RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class);
			resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON);
			jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef);
			// Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically
			GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition();
			jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class);
			jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
			jacksonFactoryDef.setSource(source);
			jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef);
			converters.add(jacksonConverterDef);
		}
	}
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addIndexedArgumentValue(0, converters);
	RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cavs, null);
	return new RuntimeBeanReference(registerBeanDef(messageConverterDef, context, source));
}
 
Example 16
Source File: JettyHTTPServerEngineFactoryBeanDefinitionParser.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<Object> getRequiredElementsList(Element parent, ParserContext ctx, QName name,
                                     BeanDefinitionBuilder bean) {

    List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(parent,
                                                                 name.getNamespaceURI(),
                                                                 name.getLocalPart());
    ManagedList<Object> list = new ManagedList<>(elemList.size());
    list.setSource(ctx.extractSource(parent));

    for (Element elem : elemList) {
        list.add(ctx.getDelegate().parsePropertySubElement(elem, bean.getBeanDefinition()));
    }
    return list;
}
 
Example 17
Source File: MessageBrokerBeanDefinitionParser.java    From java-technology-stack with MIT License 5 votes vote down vote up
private ManagedList<Object> extractBeanSubElements(Element parentElement, ParserContext context) {
	ManagedList<Object> list = new ManagedList<>();
	list.setSource(context.extractSource(parentElement));
	for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
		Object object = context.getDelegate().parsePropertySubElement(beanElement, null);
		list.add(object);
	}
	return list;
}
 
Example 18
Source File: WebSocketNamespaceUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
public static ManagedList<Object> parseBeanSubElements(@Nullable Element parentElement, ParserContext context) {
	ManagedList<Object> beans = new ManagedList<>();
	if (parentElement != null) {
		beans.setSource(context.extractSource(parentElement));
		for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
			beans.add(context.getDelegate().parsePropertySubElement(beanElement, null));
		}
	}
	return beans;
}
 
Example 19
Source File: BeanDefinitionParserDelegate.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Parse a list element.
 */
public List<Object> parseListElement(Element collectionEle, @Nullable BeanDefinition bd) {
	String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = collectionEle.getChildNodes();
	ManagedList<Object> target = new ManagedList<>(nl.getLength());
	target.setSource(extractSource(collectionEle));
	target.setElementTypeName(defaultElementType);
	target.setMergeEnabled(parseMergeAttribute(collectionEle));
	parseCollectionElements(nl, target, bd, defaultElementType);
	return target;
}
 
Example 20
Source File: WebSocketNamespaceUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public static ManagedList<? super Object> parseBeanSubElements(Element parentElement, ParserContext context) {
	ManagedList<? super Object> beans = new ManagedList<Object>();
	if (parentElement != null) {
		beans.setSource(context.extractSource(parentElement));
		for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) {
			beans.add(context.getDelegate().parsePropertySubElement(beanElement, null));
		}
	}
	return beans;
}