org.springframework.integration.config.xml
Class IntegrationNamespaceUtils

java.lang.Object
  extended by org.springframework.integration.config.xml.IntegrationNamespaceUtils

public abstract class IntegrationNamespaceUtils
extends java.lang.Object

Shared utility methods for integration namespace parsers.


Constructor Summary
IntegrationNamespaceUtils()
           
 
Method Summary
static void configurePollerMetadata(org.w3c.dom.Element pollerElement, BeanDefinitionBuilder targetBuilder, ParserContext parserContext)
          Parse a "poller" element to provide a reference for the target BeanDefinitionBuilder.
static java.lang.String createElementDescription(org.w3c.dom.Element element)
          Provides a user friendly description of an element based on its node name and, if available, its "id" attribute value.
static java.lang.String getTextFromAttributeOrNestedElement(org.w3c.dom.Element element, java.lang.String name, ParserContext parserContext)
          Get a text value from a named attribute if it exists, otherwise check for a nested element of the same name.
static BeanComponentDefinition parseInnerHandlerDefinition(org.w3c.dom.Element element, ParserContext parserContext)
           
static void setReferenceIfAttributeDefined(BeanDefinitionBuilder builder, org.w3c.dom.Element element, java.lang.String attributeName)
          Configures the provided bean definition builder with a property reference to a bean.
static void setReferenceIfAttributeDefined(BeanDefinitionBuilder builder, org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String propertyName)
          Configures the provided bean definition builder with a property reference to a bean.
static void setValueIfAttributeDefined(BeanDefinitionBuilder builder, org.w3c.dom.Element element, java.lang.String attributeName)
          Configures the provided bean definition builder with a property value corresponding to the attribute whose name is provided if that attribute is defined in the given element.
static void setValueIfAttributeDefined(BeanDefinitionBuilder builder, org.w3c.dom.Element element, java.lang.String attributeName, java.lang.String propertyName)
          Configures the provided bean definition builder with a property value corresponding to the attribute whose name is provided if that attribute is defined in the given element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegrationNamespaceUtils

public IntegrationNamespaceUtils()
Method Detail

setValueIfAttributeDefined

public static void setValueIfAttributeDefined(BeanDefinitionBuilder builder,
                                              org.w3c.dom.Element element,
                                              java.lang.String attributeName,
                                              java.lang.String propertyName)
Configures the provided bean definition builder with a property value corresponding to the attribute whose name is provided if that attribute is defined in the given element.

Parameters:
builder - the bean definition builder to be configured
element - the XML element where the attribute should be defined
attributeName - the name of the attribute whose value will be used to populate the property
propertyName - the name of the property to be populated

setValueIfAttributeDefined

public static void setValueIfAttributeDefined(BeanDefinitionBuilder builder,
                                              org.w3c.dom.Element element,
                                              java.lang.String attributeName)
Configures the provided bean definition builder with a property value corresponding to the attribute whose name is provided if that attribute is defined in the given element.

The property name will be the camel-case equivalent of the lower case hyphen separated attribute (e.g. the "foo-bar" attribute would match the "fooBar" property).

Parameters:
builder - the bean definition builder to be configured
element - - the XML element where the attribute should be defined
attributeName - - the name of the attribute whose value will be set on the property
See Also:
Conventions.attributeNameToPropertyName(String)

setReferenceIfAttributeDefined

public static void setReferenceIfAttributeDefined(BeanDefinitionBuilder builder,
                                                  org.w3c.dom.Element element,
                                                  java.lang.String attributeName,
                                                  java.lang.String propertyName)
Configures the provided bean definition builder with a property reference to a bean. The bean reference is identified by the value from the attribute whose name is provided if that attribute is defined in the given element.

Parameters:
builder - the bean definition builder to be configured
element - the XML element where the attribute should be defined
attributeName - the name of the attribute whose value will be used as a bean reference to populate the property
propertyName - the name of the property to be populated

setReferenceIfAttributeDefined

public static void setReferenceIfAttributeDefined(BeanDefinitionBuilder builder,
                                                  org.w3c.dom.Element element,
                                                  java.lang.String attributeName)
Configures the provided bean definition builder with a property reference to a bean. The bean reference is identified by the value from the attribute whose name is provided if that attribute is defined in the given element.

The property name will be the camel-case equivalent of the lower case hyphen separated attribute (e.g. the "foo-bar" attribute would match the "fooBar" property).

Parameters:
builder - the bean definition builder to be configured
element - - the XML element where the attribute should be defined
attributeName - - the name of the attribute whose value will be used as a bean reference to populate the property
See Also:
Conventions.attributeNameToPropertyName(String), Conventions.attributeNameToPropertyName(String)

createElementDescription

public static java.lang.String createElementDescription(org.w3c.dom.Element element)
Provides a user friendly description of an element based on its node name and, if available, its "id" attribute value. This is useful for creating error messages from within bean definition parsers.


configurePollerMetadata

public static void configurePollerMetadata(org.w3c.dom.Element pollerElement,
                                           BeanDefinitionBuilder targetBuilder,
                                           ParserContext parserContext)
Parse a "poller" element to provide a reference for the target BeanDefinitionBuilder. If the poller element does not contain a "ref" attribute, this will create and register a PollerMetadata instance and then add it as a property reference of the target builder.

Parameters:
pollerElement - the "poller" element to parse
targetBuilder - the builder that expects the "trigger" property
parserContext - the parserContext for the target builder

getTextFromAttributeOrNestedElement

public static java.lang.String getTextFromAttributeOrNestedElement(org.w3c.dom.Element element,
                                                                   java.lang.String name,
                                                                   ParserContext parserContext)
Get a text value from a named attribute if it exists, otherwise check for a nested element of the same name. If both are specified it is an error, but if neither is specified, just returns null.

Parameters:
element - a DOM node
name - the name of the property (attribute or child element)
parserContext - the current context
Returns:
the text from the attribite or element or null

parseInnerHandlerDefinition

public static BeanComponentDefinition parseInnerHandlerDefinition(org.w3c.dom.Element element,
                                                                  ParserContext parserContext)