INT-1677 removed requirement for anID, polished schema, added more tests, tested with server

This commit is contained in:
Oleg Zhurakousky
2011-09-02 09:56:44 -04:00
committed by Mark Fisher
parent a6c85c1dd9
commit c07d62dadb
5 changed files with 84 additions and 12 deletions

View File

@@ -16,13 +16,12 @@
package org.springframework.integration.http.config;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
@@ -32,7 +31,6 @@ import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
@@ -69,8 +67,9 @@ public class HttpInboundEndpointParser extends AbstractSingleBeanDefinitionParse
id = element.getAttribute("name");
}
if (!StringUtils.hasText(id)) {
parserContext.getReaderContext().error("The 'id' or 'name' is required.", element);
id = BeanDefinitionReaderUtils.generateBeanName(definition, parserContext.getRegistry());
}
return id;
}
@@ -96,8 +95,8 @@ public class HttpInboundEndpointParser extends AbstractSingleBeanDefinitionParse
}
List<Element> headerElements = DomUtils.getChildElementsByTagName(element, "header");
if (!CollectionUtils.isEmpty(headerElements)) {
ManagedMap<String, Object> headerElementsMap = new ManagedMap<String, Object>();
for (Element headerElement : headerElements) {
String name = headerElement.getAttribute("name");

View File

@@ -285,7 +285,7 @@ abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewaySuppor
}
Map uriVariableMappings = null;
//
StandardEvaluationContext evaluationContext = this.getEvaluationContext();
StandardEvaluationContext evaluationContext = this.prepareAndGetEvaluationContext();
if (StringUtils.hasText(this.path)){
UriTemplate template = new UriTemplate(this.path);
@@ -295,8 +295,7 @@ abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewaySuppor
logger.debug("Mapped URI variables: " + uriVariableMappings);
}
// set the whole map
// set the whole map
evaluationContext.setVariable("uriVariables", uriVariableMappings);
for (Object key : uriVariableMappings.keySet()) {
// add individual elements
@@ -454,7 +453,7 @@ abstract class HttpRequestHandlingEndpointSupport extends MessagingGatewaySuppor
return httpStatus;
}
private StandardEvaluationContext getEvaluationContext(){
private StandardEvaluationContext prepareAndGetEvaluationContext(){
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
evaluationContext.addPropertyAccessor(new MapAccessor());
BeanFactory beanFactory = this.getBeanFactory();

View File

@@ -24,7 +24,14 @@
<xsd:element name="header" type="headerType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
[DEPRECATED since v2.1] Use 'path' attribute if you want to specify the path or
'id' attribute if you simply want to identify this component
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="channel" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>