org.osesb.msgrouting.configuration
Class ClientGatewayConfiguration

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

public class ClientGatewayConfiguration
extends XMLConfiguration

ClientGatewayConfiguration extends XMLConfiguration to configure a org.osesb.msgrouting.ClientGateway.

ClientGateway(s) facilitate communication with broker end points such as JMS Queues and web services. ClientGateway is used to hide messaging infrastructure from client applications. Client applications are not aware of target destinations, the message transport, or how a request is fulfilled. Initiating applications merely send a message, and possibly, receive a response.

ClientGatewayConfiguration include a MessageRouterConfiguration. ClientGateway(s) 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.

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

  1. A ClientGateway can be configured with a static messageType by using the <clientGatewayMessageType> configuration element. In this case all messages sent from the gateway will be assigned the same message type.
  2. If a ClientGateway is not configured with a static message type, then the configured MessageRouter uses a XMLMessageTypeHelper to extract a message type from the 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.

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

Example ClientGatewayConfiguration content model:

<client-gateway-configuration>
          <!-- debugFlag for ClientGateway -->
          <debugFlag>false</debugFlag>
          <!--
              A ClientGateway can be configured with a static messageType by using the
              <clientGatewayMessageType> configuration element. In this case
              all messages sent from the gateway will be assigned the same message type.

              messageTypes are QNames with a 'localPart' and an optional 'namespaceURI'.

              If a ClientGateway is not configured with a static message type,
              then it uses a XMLMessageTypeHelper to extract a message type from the
              XML message using the <xmlmessage-messagetype-xpathexpression-list>
              configuration element of the MessageRouterConfiguration.
          -->
          <clientGatewayMessageType></clientGatewayMessageType>
          <!--  The MessageRouterConfiguration can be embedded or reference an external config file. -->
          <message-router-configuration>
              <!-- debugFlag for the MessageRouter -->
              <debugFlag>false</debugFlag>
              <!--  XPath expressions for extracting the localPart of the messageType from the XML message -->
              <xmlmessage-messagetype-xpathexpression-list>
                  <!--
                      namespace-qualified XPath expressions
                  -->
                  <xmlmessage namespaceURI="http://osesb.test.com/attachment">
                      <!-- attachments-1.xml -->
                      <xpathExpression>testFiles/@messageType</xpathExpression>
                  </xmlmessage>
                 <xmlmessage namespaceURI="http://osesb.test.com/cdcatalog">
                      <!-- cdcatalog.xml -->
                      <xpathExpression>catalog/@messageType</xpathExpression>
                  </xmlmessage>
                  <!--
                      unqualified XPath expressions
                  -->
                  <xmlmessage>
                  </xmlmessage>
              </xmlmessage-messagetype-xpathexpression-list>
              <!--
                  A messageType maps to one, and only one MessagePipeline.

                  message-pipeline-configuration(s) can be configured inline or
                  reference an external configuration file.

                  If the message-pipeline-configuration 'enabled' attribute is false,
                  the MessagePipeline remains configured, but messages are not routed
                  to the MessagePipeline for processing.

                  enabled, defaults to true.
              -->
              <messagetype-to-messagepipeline-map key-class="org.osesb.configuration.QNameMapEntry">
                   <!--
                      All messageTypes mapped to the same MessagePipeline.
                      The MessagePipeline is configured with a single JMSClientPipelineStage
                      that sends messages to the deployed transport handler,
                      org.osesb.transporthandlers.jms.mdb.JMSXMLMessageTransportHandlerMDB.
                  -->
                   <!-- cdcatalog.xml -->
                  <message-type namespaceURI="http://osesb.test.com/cdcatalog" localPart="cdOrder_1">
                      <message-pipeline-configuration
                          configFile="org/osesb/transporthandlers/test/deployabletestpackage1/testdata/messagepipeline-for-clientgateway-to-JMSXMLMessageTransportHandlerMDB-config.xml"/>
                  </message-type>
                   <!-- cdcatalog.xml -->
                  <message-type namespaceURI="http://osesb.test.com/cdcatalog" localPart="cdOrder_2">
                      <message-pipeline-configuration
                          configFile="org/osesb/transporthandlers/test/deployabletestpackage1/testdata/messagepipeline-for-clientgateway-to-SOAPXMLMessageTransportHandlerBean-config.xml"/>
                  </message-type>
                  <!-- attachments-1.xml -->
                  <message-type namespaceURI="http://osesb.test.com/attachment" localPart="processAttachments">
                      <message-pipeline-configuration
                          configFile="org/osesb/transporthandlers/test/deployabletestpackage1/testdata/messagepipeline-for-clientgateway-to-JMSXMLMessageTransportHandlerMDB-config.xml"/>
                  </message-type>
              </messagetype-to-messagepipeline-map>
          </message-router-configuration>
      </client-gateway-configuration>
 

Since:
Version .9

Field Summary
static java.lang.String CLIENT_GATEWAY_CONFIG_CONTENTMODEL
          The content model tag for a ClientGatewayConfiguration.
protected  javax.xml.namespace.QName clientGatewayMessageType
          From the <clientGatewayMessageType> configuration element, which includes a 'namespaceURI' attribute and a 'localPart' attribute that define the messageType (QName) that will be associated with all messages sent form the configured ClientGateway.
protected  MessageRouterConfiguration messageRouterConfiguration
          The MessageRouterConfiguration for this ClientGatewayConfiguration.
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
ClientGatewayConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of ClientGatewayConfiguration given the content model Element.
ClientGatewayConfiguration(java.lang.String configFile)
          Creates a new instance of ClientGatewayConfiguration given a XML configuration file.
ClientGatewayConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of ClientGatewayConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 javax.xml.namespace.QName getClientGatewayMessageType()
          A ClientGateway can have a static messageType that will be set for all outgoing messages.
 MessageRouterConfiguration getMessageRouterConfiguration()
          Return the MessageRouterConfiguration for this ClientGatewayConfiguration.
 java.lang.String getPoolKey()
          Returns the poolKey for the ClientGateway.
 boolean isPooled()
          Returns the isPooled flag, which indicates that this is a pooled ClientGateway.
protected  void loadClientGatewayMessageType()
          A ClientGateway can have a static messageType that will be set for all outgoing messages.
protected  void loadMessageRouterConfiguration()
          Loads a MessageRouterConfiguration that is enclosed within this ClientGatewayConfiguration.
static void main(java.lang.String[] args)
          main() - For testing and sandbboxing.
 void setConfigFilePath(java.lang.String configFile)
          Set the configuration file name.
 void setDebugFlag(boolean debugFlag)
          Set the debugFlag.
 void setIsPooled(boolean isPooled)
          Sets the isPooled flag, which indicates that this is a pooled ClientGateway.
 void setPoolKey(java.lang.String poolKey)
          Set the poolKey for the ClientGateway.
 java.lang.String toString()
          Returns the String representation of this ClientGatewayConfiguration.
 
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, setConfigurationProperty, 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

messageRouterConfiguration

protected MessageRouterConfiguration messageRouterConfiguration
The MessageRouterConfiguration for this ClientGatewayConfiguration.

See Also:
loadMessageRouterConfiguration()

clientGatewayMessageType

protected javax.xml.namespace.QName clientGatewayMessageType
From the <clientGatewayMessageType> configuration element, which includes a 'namespaceURI' attribute and a 'localPart' attribute that define the messageType (QName) that will be associated with all messages sent form the configured ClientGateway.

A ClientGateway can have a static messageType that will be set for all outgoing messages.

The messageType is used by the configured MessageRouter to route a message to a MessagePipeline for processing.

If not specified, the messageType is determined by the configured org.osesb.msgrouting.MessageRouter according to the <xmlmessage-messagetype-xpathexpression-list> configuration element of the MessageRouterConfiguration.

See Also:
loadClientGatewayMessageType()

CLIENT_GATEWAY_CONFIG_CONTENTMODEL

public static final java.lang.String CLIENT_GATEWAY_CONFIG_CONTENTMODEL
The content model tag for a ClientGatewayConfiguration.

See Also:
Constant Field Values
Constructor Detail

ClientGatewayConfiguration

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

ClientGatewayConfiguration

public ClientGatewayConfiguration(java.lang.String configFile,
                                  java.lang.String xpathExpression)
                           throws java.lang.Exception
Creates a new instance of ClientGatewayConfiguration 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. If following the framework convention for ClientGatewayConfiguration(s), xpathExpression should have 'client-gateway-configuration' as the last Element in the path.
Throws:
java.lang.Exception - if there is a problem reading or parsing the configuration file.

ClientGatewayConfiguration

public ClientGatewayConfiguration(org.w3c.dom.Element contentModelElement)
                           throws java.lang.Exception
Creates a new instance of ClientGatewayConfiguration 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

loadMessageRouterConfiguration

protected final void loadMessageRouterConfiguration()
                                             throws java.lang.Exception
Loads a MessageRouterConfiguration that is enclosed within this ClientGatewayConfiguration.

Throws:
java.lang.Exception - if there is a problem loading the MessageRouterConfiguration.

loadClientGatewayMessageType

protected final void loadClientGatewayMessageType()
A ClientGateway can have a static messageType that will be set for all outgoing messages.

Load the clientGatewayMessageType from the <clientGatewayMessageType> configuration element, which includes a 'namespaceURI' attribute and a 'localPart' attribute that define the messageType (QName) that will be associated with all messages sent form the configured ClientGateway.

The messageType is used by the configured MessageRouter to route a message to a MessagePipeline for processing.

If <clientGatewayMessageType> is not configured, the configured MessageRouter determines the messageType using a XMLMessageTypeHelper to extract a message type. For example DefaultXMLMessageTypeHelper applies a List of XPath expressions to a XML message in order to extract the message type.


getMessageRouterConfiguration

public MessageRouterConfiguration getMessageRouterConfiguration()
Return the MessageRouterConfiguration for this ClientGatewayConfiguration.

Returns:
the MessageRouterConfiguration for this ClientGatewayConfiguration.
See Also:
loadMessageRouterConfiguration()

getClientGatewayMessageType

public javax.xml.namespace.QName getClientGatewayMessageType()
A ClientGateway can have a static messageType that will be set for all outgoing messages.

Return the <clientGatewayMessageType> configuration element, which includes a 'namespaceURI' attribute and a 'localPart' attribute that define the messageType (QName) that will be associated with all messages sent form the configured ClientGateway.

The messageType is used by the configured MessageRouter to route a message to a MessagePipeline for processing.

If <clientGatewayMessageType> is not configured, the configured MessageRouter determines the messageType using a XMLMessageTypeHelper to extract a message type. For example DefaultXMLMessageTypeHelper applies a List of XPath expressions to a XML message in order to extract the message type.

Returns:
the static messageType for this ClientGateway.
See Also:
loadClientGatewayMessageType()

setConfigFilePath

public void setConfigFilePath(java.lang.String configFile)
Set the configuration file name.

Overrides:
setConfigFilePath in class XMLConfiguration
Parameters:
configFile - the configuration file name.

setDebugFlag

public void setDebugFlag(boolean debugFlag)
Set the debugFlag.

Overrides:
setDebugFlag in class XMLConfiguration
Parameters:
debugFlag - The debugFlag.

isPooled

public boolean isPooled()
Returns the isPooled flag, which indicates that this is a pooled ClientGateway. 'isPoooled' is set by the KeyedObjectPoolFactory that created the pooled ClientGateway.

Note that the isPooled flag is set on the configuration by the object pool when the pooled object is created.

Returns:
the ClientGateway isPooled flag.

setIsPooled

public void setIsPooled(boolean isPooled)
Sets the isPooled flag, which indicates that this is a pooled ClientGateway. 'isPoooled' is set by the KeyedObjectPoolFactory that created the pooled ClientGateway.

Note that the isPooled flag is set on the configuration by the object pool when the pooled object is created.

Parameters:
isPooled - The ClientGateway isPooled flag.

getPoolKey

public java.lang.String getPoolKey()
Returns the poolKey for the ClientGateway. 'poolKey' is set by the KeyedObjectPoolFactory that created the pooled ClientGateway.

Note that the poolKey is set on the configuration by the object pool when the pooled object is created.

Returns:
the ClientGateway poolKey.

setPoolKey

public void setPoolKey(java.lang.String poolKey)
Set the poolKey for the ClientGateway. 'poolKey' is set by the KeyedObjectPoolFactory that created the pooled ClientGateway.

Note that the poolKey is set on the configuration by the object pool when the pooled object is created.

Parameters:
poolKey - the ClientGateway poolKey.

toString

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

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

main

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