INT-878 The sub-elements of <header-enricher/> now support a "type" attribute.
This commit is contained in:
@@ -85,24 +85,27 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
|
||||
Class<?> headerType = null;
|
||||
if ("header".equals(elementName)) {
|
||||
headerName = headerElement.getAttribute("name");
|
||||
String headerTypeName = headerElement.getAttribute("type");
|
||||
if (StringUtils.hasText(headerTypeName)) {
|
||||
ClassLoader classLoader = parserContext.getReaderContext().getBeanClassLoader();
|
||||
if (classLoader != null) {
|
||||
try {
|
||||
headerType = ClassUtils.forName(headerTypeName, classLoader);
|
||||
}
|
||||
catch (Exception e) {
|
||||
parserContext.getReaderContext().error("unable to resolve type [" +
|
||||
headerTypeName + "] for header '" + headerName + "'", element, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
headerName = elementToNameMap.get(elementName);
|
||||
headerType = elementToTypeMap.get(elementName);
|
||||
}
|
||||
if (headerType == null) {
|
||||
String headerTypeName = headerElement.getAttribute("type");
|
||||
if (StringUtils.hasText(headerTypeName)) {
|
||||
ClassLoader classLoader = parserContext.getReaderContext().getBeanClassLoader();
|
||||
if (classLoader == null) {
|
||||
classLoader = getClass().getClassLoader();
|
||||
}
|
||||
try {
|
||||
headerType = ClassUtils.forName(headerTypeName, classLoader);
|
||||
}
|
||||
catch (Exception e) {
|
||||
parserContext.getReaderContext().error("unable to resolve type [" +
|
||||
headerTypeName + "] for header '" + headerName + "'", element, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (headerName != null) {
|
||||
String value = headerElement.getAttribute("value");
|
||||
String ref = headerElement.getAttribute("ref");
|
||||
|
||||
@@ -937,6 +937,14 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="referenceOrValueHeaderType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Provides a header value for the given header name. Requires
|
||||
exactly one of the 'ref', 'value', or 'expression' attributes.
|
||||
The 'type' attribute allows for the specification of the expected
|
||||
type when using a 'value' or 'expression', but it is optional.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="referenceHeaderType">
|
||||
<xsd:attribute name="value" type="xsd:string">
|
||||
@@ -954,6 +962,13 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="type" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:java.lang.Class"><![CDATA[
|
||||
The fully qualified class name of the header value's expected type.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
Reference in New Issue
Block a user