org.osesb.msgrouting.configuration
Class DroolsXMLMessageTypeHelperConfiguration

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

public class DroolsXMLMessageTypeHelperConfiguration
extends XMLConfiguration

Configures a DroolsXMLMessageTypeHelper.

DroolsXMLMessageTypeHelper extends DefaultXMLMessageTypeHelper with a getMessageType() method that incorporates a Drools rule.

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.

DroolsXMLMessageTypeHelper is constructed with a DroolsXMLMessageTypeHelperConfiguration, which combines XMLMessageTypeXPathExpressionListConfiguration and DroolsRuleApplierConfiguration.

DroolsXMLMessageTypeHelper allows for more complex determination of the messageType for a XML message as follows:

  1. DroolsXMLMessageTypeHelper#getMessageType() invokes the ancestor method to determine a messageType based on namespace and the value for an element or attribute value. Note that the messageType returned by the ancestor can be null; the ancestor is not required to return a messageType.
  2. DroolsXMLMessageTypeHelperConfiguration configures additional XPath expressions which are applied to the XML and creates a org.osesb.utilities.xml.XMLNode for each extracted value.. The resulting XMLNodes are passed to the configured Drools rule as facts.
  3. The namespace for the XML and the messageType returned by the ancestor are passed to the Drools WorkingMemory as global objects.
  4. The configured Drools rule uses the XMLNodes extracted from the XML, the namespace for the XML, and the messageType returned by the ancestor to determine the messageType.


Field Summary
protected  DroolsRuleApplierConfiguration droolsRuleApplierConfiguration
          The required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.
protected  XMLMessageTypeXPathExpressionListConfiguration xmlMessageTypeXPathExpressionListConfiguration
          The optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
DroolsXMLMessageTypeHelperConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of DroolsXMLMessageTypeHelperConfiguration given the content model Element.
DroolsXMLMessageTypeHelperConfiguration(java.lang.String configFile)
          Creates a new instance of DroolsXMLMessageTypeHelperConfiguration given a XML configuration file.
DroolsXMLMessageTypeHelperConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of DroolsXMLMessageTypeHelperConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 DroolsRuleApplierConfiguration getDroolsRuleApplierConfiguration()
          Return the required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.
 XMLMessageTypeXPathExpressionListConfiguration getXmlMessageTypeXPathExpressionListConfiguration()
          Return the optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.
protected  void loadDroolsRuleApplierConfiguration()
          Loads the required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.
protected  void loadXMLMessageTypeXPathExpressionListConfiguration()
          Loads the optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.
static void main(java.lang.String[] args)
          main() For testing and sandboxing.
 java.lang.String toString()
          Returns the String representation of this MessageRouterConfiguration.
 
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

xmlMessageTypeXPathExpressionListConfiguration

protected XMLMessageTypeXPathExpressionListConfiguration xmlMessageTypeXPathExpressionListConfiguration
The optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.


droolsRuleApplierConfiguration

protected DroolsRuleApplierConfiguration droolsRuleApplierConfiguration
The required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.

Constructor Detail

DroolsXMLMessageTypeHelperConfiguration

public DroolsXMLMessageTypeHelperConfiguration(java.lang.String configFile)
                                        throws java.lang.Exception
Creates a new instance of DroolsXMLMessageTypeHelperConfiguration 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.

DroolsXMLMessageTypeHelperConfiguration

public DroolsXMLMessageTypeHelperConfiguration(java.lang.String configFile,
                                               java.lang.String xpathExpression)
                                        throws java.lang.Exception
Creates a new instance of DroolsXMLMessageTypeHelperConfiguration 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 XML configuration document to parse.
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.

DroolsXMLMessageTypeHelperConfiguration

public DroolsXMLMessageTypeHelperConfiguration(org.w3c.dom.Element contentModelElement)
                                        throws java.lang.Exception
Creates a new instance of DroolsXMLMessageTypeHelperConfiguration given the content model Element.

Parameters:
contentModelElement - The top level Element for the for the configuration.
Throws:
java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.
Method Detail

loadXMLMessageTypeXPathExpressionListConfiguration

protected final void loadXMLMessageTypeXPathExpressionListConfiguration()
                                                                 throws java.lang.Exception
Loads the optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.

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 DOM that contains the configuration content model.

loadDroolsRuleApplierConfiguration

protected final void loadDroolsRuleApplierConfiguration()
                                                 throws java.lang.Exception
Loads the required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.

Throws:
java.lang.Exception - if there is a fatal error transversing the DOM that contains the configuration content model.

getXmlMessageTypeXPathExpressionListConfiguration

public XMLMessageTypeXPathExpressionListConfiguration getXmlMessageTypeXPathExpressionListConfiguration()
Return the optional XMLMessageTypeXPathExpressionListConfiguration, which configures XPath expressions for extracting message types from XML messages using the default implementation of XMLMessageTypeHelper, which is DefaultXMLMessageTypeHelper.

Returns:
the XMLMessageTypeXPathExpressionListConfiguration for this DroolsXMLMessageTypeHelperConfiguration

getDroolsRuleApplierConfiguration

public DroolsRuleApplierConfiguration getDroolsRuleApplierConfiguration()
Return the required DroolsRuleApplierConfiguration, which configures the location of the Drools Rule file and an optional XPathExpressionListConfiguration which can be used to extract XML Nodes for evaluation by the configured Drools rules.

Returns:
the DroolsRuleApplierConfiguration for this DroolsXMLMessageTypeHelperConfiguration

toString

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

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

main

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

Parameters:
args - commandline arguments