org.osesb.msgrouting.configuration
Class XMLMessageTypeXPathExpressionListConfiguration

java.lang.Object
  extended by org.osesb.configuration.XMLConfiguration
      extended by org.osesb.msgrouting.configuration.XMLMessageTypeXPathExpressionListConfiguration

public class XMLMessageTypeXPathExpressionListConfiguration
extends XMLConfiguration

Encapsulates a <xmlmessage-messagetype-xpathexpression-list> configuration element, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.

A message entering osESB through one of the transport handlers (see the org.osesb.transporthandlers package) must have a message type. Since osESB is configured mostly to handle XML messages (possibly with attachments) the message type is a QName where the namespaceURI is the namespace of the XML message and the local part is given by an element or attribute in the message.

Transport handlers use a MessageRouter to route messages to a org.osesb.messagepipeline.MessagePipeline for processing. The MessageRouter selects the MessagePipeline based on the message's messageType. The MessageRouter uses the <messagetype-to-messagepipeline-map> configuration element of a MessageRouterConfiguration to map message types to MessagePipelines.

See the org.osesb.messagepipeline package. See the org.osesb.transporthandlers package in the transport-handlers module.

There are two ways that the message type for an incoming message is determined:

  1. A transport handler can be configured with a static messageType. In this case all messages arriving at that transport handler will be assigned the same message type.
  2. If a transport handler is not configured with a static message type, then the configured MessageRouter uses a XMLMessageTypeHelper to extract a message type from the incoming XML message.

DefaultXMLMessageTypeHelper is the default XMLMessageTypeHelper class and is constructed with a XMLMessageTypeXPathExpressionListConfiguration. DefaultXMLMessageTypeHelper applies the configured XPath expressions to a XML message until a messageType is determined. DefaultXMLMessageTypeHelper#getMessagetype() returns the messageType as a QName, where the namespaceURI is the XML document namespace (if any) and the localPart is the value for the element or attribute that is given by a XPath expression.

XPath expressions can be namespace-qualified or not. DefaultXMLMessageTypeHelper uses org.osesb.utilities.xml.DocumentNamespaceHelper to extract namespaces from the root element of the incoming XML message. The following namespaces are considered, in order, when searching the <xmlmessage-messagetype-xpathexpression-list> configuration element for a namespace-qualified XPath expression:

  1. Namespaces declared using the 'xmlns' attribute of the root element.
  2. The 'targetNamespace' attribute of the root element.
  3. The namespaceURI portion of the 'schemaLocation' attribute of the root element.

If the incoming XML message is associated with a namespace, then DefaultXMLMessageTypeHelper applies all matching namespace-qualified XPath expressions in the order that they are configured by XMLMessageTypeXPathExpressionListConfiguration until a message type is extracted from the XML message. If the namespace-qualified XPath expressions do not yield a message type, DefaultXMLMessageTypeHelper applies all unqualified XPath expressions in the order that they are configured until a message type is extracted from the XML message.

A <xmlmessage-messagetype-xpathexpression-list> content model looks like:

<xmlmessage-messagetype-xpathexpression-list>
          <!--
              namespace-qualified XPath expressions.

              the configured xpath expressions are applied to
              xml messages that include a namespace declaration
              that is equal to the namespaceURI attribute.

              Declared namespaces are searched for in the following order:

              1. Namespaces declared using a 'xmlns' attribute of the root element.
              2. The 'targetNamespace' attribute of the root element.
              3. The namespaceURI portion of the 'schemaLocation' attribute of the root element.

              All xpathExpressions are applied until a messageType is found.
          -->
          <xmlmessage namespaceURI="http://osesb.test.com">
              <!-- SiebelToGetBasicInfoByAcctNumResponseBroker.xml -->
              <xpathExpression>SiebelMessage/@MessageId</xpathExpression>
              <!-- IVRToGetBasicInfoByAcctNumRequestBroker.xml -->
              <xpathExpression>IVRMessage/@messageType</xpathExpression>
              <!-- WebSiteAddressChangeMessage.xml -->
              <xpathExpression>WebSiteMessage/@MessageType</xpathExpression>
          </xmlmessage>
          <!-- ipo.xml -->
          <xmlmessage namespaceURI="http://www.altova.com/IPO">
              <xpathExpression>//@msgType</xpathExpression>
          </xmlmessage>
          <!--
              unqualified XPath expressions are applied to XML
              after namespace-qualified XPath expressions.

              All xpathExpressions are applied until a messageType is found.
          -->
          <xmlmessage>
              <!-- reservation.xml -->
              <xpathExpression>/Reservation/MessageType</xpathExpression>
              <!-- RewardsGetPoints.xml-->
              <xpathExpression>/getPoints</xpathExpression>
              <!-- RewardsUpdatePoints.xml -->
              <xpathExpression>/updatePoints</xpathExpression>
          </xmlmessage>
      </xmlmessage-messagetype-xpathexpression-list>
 

To configure a MessageRouter with a different XMLMessageTypeHelper, create a class that extends AbstractXMLMessageTypeHelper and use the <xmlMessagetypeHelperConfiguration> content model element of the MessageRouterConfiguration.

Since:
Version .9

Field Summary
protected  java.util.Map qualifiedXPathExpressionMap
          A Map of namespace-qualified XPath expressions, keyed by the value of the namespaceURI attribute of the XMLMESSAGE_TAGNAME element where each Map entry is a List of XPath expressions that are associated with the namespaceURI.
protected  java.util.ArrayList unqualifiedXPathExpressionList
          ArrayList of the configured unqualified XPath expressions.
static java.lang.String XMLMESSAGE_TAGNAME
          Repeating tag name within a <xmlmessage-messagetype-xpathexpression-list> configuration element.
static java.lang.String XMLMESSAGETYPEXPATHEXPRESSIONLIST_CONTENTMODEL
          The default XMLMessageTypeXPathExpressionListConfiguration content model tag name.
static java.lang.String XPATHEXPRESSION_TAGNAME
          Tag name of XPath expressions within a XMLMESSAGE_TAGNAME.
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
XMLMessageTypeXPathExpressionListConfiguration()
          Creates a new empty instance of XMLMessageTypeXPathExpressionListConfiguration.
XMLMessageTypeXPathExpressionListConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given the content model Element that encloses the XMLMESSAGE_TAGNAME Elements.
XMLMessageTypeXPathExpressionListConfiguration(java.lang.String configFile)
          Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given a XML configuration file.
XMLMessageTypeXPathExpressionListConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 java.util.List getNamespaceQualifiedMessageTypeXPathExpressions(java.lang.String namespaceURI)
          Return the List of configured namespace-qualified message type XPath expressions for a namespaceURI.
 java.util.List getUnqualifiedMessageTypeXPathExpressions()
          Return the List of configured unqualified message type XPath expressions.
protected  void loadXPathExpressions()
          Loads the <xmlmessage-messagetype-xpathexpression-list> element and populates the:

unqualifiedXPathExpressionList, which is a List of XPath expressions that are not associated with any namespace. qualifiedXPathExpressionMap, which is a Map of namespace-qualified XPath expressions, keyed by the value of the namespaceURI attribute of the XMLMESSAGE_TAGNAME element where each Map entry is a List of XPath expressions that are associated with the namespaceURI.

Example configuration:

static void main(java.lang.String[] args)
          main() For testing and sandboxing.
 java.lang.String toString()
          Returns the String representation of this XMLMessageTypeXPathExpressionListConfiguration.
 
Methods inherited from class org.osesb.configuration.XMLConfiguration
checkXMLConfigurationClass, clear, doEncryptionInstructions, getBooleanConfigurationProperty, getBooleanRootConfigurationAttribute, getConfigFilePath, getConfigurationAttribute, getConfigurationAttributes, getConfigurationElement, getConfigurationElements, getConfigurationProperties, getConfigurationProperty, getConfigurationProperty, getContentModelElement, getDebugFlag, getDocument, getEncryptionInstructions, getFTPClientConfiguration, getIntConfigurationProperty, getIntRootConfigurationAttribute, getJAXRPCClientConfiguration, getJDBCConfiguration, getJMSClientConfiguration, getLongConfigurationProperty, getLongRootConfigurationAttribute, getName, getRootConfigurationAttribute, getRootConfigurationAttributes, getSMTPClientConfiguration, getSystemProperties, getSystemProperty, isConfigurationElementEmpty, loadConfiguration, loadExternalConfiguration, loadFTPClientConfiguration, loadJAXRPCClientConfiguration, loadJDBCConfiguration, loadJMSClientConfiguration, loadPropertiesFromContentModel, loadSMTPClientConfiguration, loadSystemProperties, mergeConfigurationProperties, setConfigFilePath, setConfigurationProperty, setDebugFlag, setFTPClientConfiguration, setJAXRPCClientConfiguration, setJDBCConfiguration, setJMSClientConfiguration, setName, setRootConfigurationAttribute, setSMTPClientConfiguration, setSystemProperties, setSystemProperty, writeConfigurationFile, writeConfigurationFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XMLMESSAGETYPEXPATHEXPRESSIONLIST_CONTENTMODEL

public static final java.lang.String XMLMESSAGETYPEXPATHEXPRESSIONLIST_CONTENTMODEL
The default XMLMessageTypeXPathExpressionListConfiguration content model tag name.

See Also:
Constant Field Values

XMLMESSAGE_TAGNAME

public static java.lang.String XMLMESSAGE_TAGNAME
Repeating tag name within a <xmlmessage-messagetype-xpathexpression-list> configuration element. Tags can be namespace-qualified or not and enclose one or more XPath expressions.


XPATHEXPRESSION_TAGNAME

public static java.lang.String XPATHEXPRESSION_TAGNAME
Tag name of XPath expressions within a XMLMESSAGE_TAGNAME.


unqualifiedXPathExpressionList

protected java.util.ArrayList unqualifiedXPathExpressionList
ArrayList of the configured unqualified XPath expressions.


qualifiedXPathExpressionMap

protected java.util.Map qualifiedXPathExpressionMap
A Map of namespace-qualified XPath expressions, keyed by the value of the namespaceURI attribute of the XMLMESSAGE_TAGNAME element where each Map entry is a List of XPath expressions that are associated with the namespaceURI.

TreeMap maintains the order of addition to the Map.

Constructor Detail

XMLMessageTypeXPathExpressionListConfiguration

public XMLMessageTypeXPathExpressionListConfiguration()
Creates a new empty instance of XMLMessageTypeXPathExpressionListConfiguration.


XMLMessageTypeXPathExpressionListConfiguration

public XMLMessageTypeXPathExpressionListConfiguration(java.lang.String configFile)
                                               throws java.lang.Exception
Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given a XML configuration file. The root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

XMLMessageTypeXPathExpressionListConfiguration

public XMLMessageTypeXPathExpressionListConfiguration(java.lang.String configFile,
                                                      java.lang.String xpathExpression)
                                               throws java.lang.Exception
Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.

An empty xpathExpression implies that the root element of the XML configuration file is the starting element for the configuration.

Parameters:
configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
xpathExpression - A XPath expression that evaluates to the element that marks the beginning of the configuration.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

XMLMessageTypeXPathExpressionListConfiguration

public XMLMessageTypeXPathExpressionListConfiguration(org.w3c.dom.Element contentModelElement)
                                               throws java.lang.Exception
Creates a new instance of XMLMessageTypeXPathExpressionListConfiguration given the content model Element that encloses the XMLMESSAGE_TAGNAME Elements.

Parameters:
contentModelElement - the content model Element that encloses the XMLMESSAGE_TAGNAME Elements.
Throws:
java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.
Method Detail

loadXPathExpressions

protected final void loadXPathExpressions()
                                   throws java.lang.Exception
Loads the <xmlmessage-messagetype-xpathexpression-list> element and populates the:

Example configuration:

<xmlmessage-messagetype-xpathexpression-list>
          <!--
              namespace-qualified XPath expressions
          -->
          <xmlmessage namespaceURI = "http://osesb.test.com">
              <!-- SiebelToGetBasicInfoByAcctNumResponseBroker.xml -->
              <xpathExpression>SiebelMessage/@MessageId</xpathExpression>
              <!-- IVRToGetBasicInfoByAcctNumRequestBroker.xml -->
              <xpathExpression>IVRMessage/@messageType</xpathExpression>
              <!-- WebSiteAddressChangeMessage.xml -->
              <xpathExpression>WebSiteMessage/@MessageType</xpathExpression>
          </xmlmessage>
          <!-- ipo.xml -->
          <xmlmessage namespaceURI = "http://www.altova.com/IPO">
              <xpathExpression>//@msgType</xpathExpression>
          </xmlmessage>
          <!--
              unqualified XPath expressions
          -->
          <xmlmessage namespaceURI = "">
              <!-- reservation.xml -->
              <xpathExpression>/Reservation/MessageType</xpathExpression>
               <!-- RewardsGetPoints.xml AND RewardsUpdatePoints.xml -->
              <xpathExpression>/*</xpathExpression>
          </xmlmessage>
      </xmlmessage-messagetype-xpathexpression-list>
 

Note that this method should not be overridden as it is invoked from this class's constructor.

Throws:
java.lang.Exception - if there is a fatal error transversing the content models.

getNamespaceQualifiedMessageTypeXPathExpressions

public java.util.List getNamespaceQualifiedMessageTypeXPathExpressions(java.lang.String namespaceURI)
Return the List of configured namespace-qualified message type XPath expressions for a namespaceURI.

Parameters:
namespaceURI - The namespaceURI to get the XPath expression for.
Returns:
The List of namespace-qualified message type XPath expressions for a namespaceURI.

getUnqualifiedMessageTypeXPathExpressions

public java.util.List getUnqualifiedMessageTypeXPathExpressions()
Return the List of configured unqualified message type XPath expressions.

Returns:
The List of unqualified message type XPath expressions.

toString

public java.lang.String toString()
Returns the String representation of this XMLMessageTypeXPathExpressionListConfiguration.

Overrides:
toString in class XMLConfiguration
Returns:
the String representation of this XMLMessageTypeXPathExpressionListConfiguration.

main

public static void main(java.lang.String[] args)
main() For testing and sandboxing.

Parameters:
args - commandline arguments