org.openeai.jms.consumer.commands
Class ConsumerCommand


java.lang.Object

  |

  +--org.openeai.OpenEaiObject

        |

        +--org.openeai.jms.consumer.commands.ConsumerCommand

Direct Known Subclasses:
RequestCommandImpl, SyncCommandImpl

public class ConsumerCommand
extends OpenEaiObject

The "default" anscestor of all Commands that are executed by either PubSubConsumer or PointToPointConsumer.

Organizations can add an additional layer between this class and the command implementations they develop or they can even eliminate the use of this class altogether. This class provides many useful convenience methods that are commonly needed by all command implementations. Additional common routines will be added to this layer as time goes by...

Version:
3.0 beta2 - 28 January 2003

Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)
See Also:
RequestCommandImpl, RequestCommand, SyncCommandImpl, SyncCommand

Field Summary
protected static java.lang.String CREATE_ACTION
           
protected static java.lang.String DELETE_ACTION
           
protected static java.lang.String MESSAGE_ACTION
           
protected static java.lang.String MESSAGE_CATEGORY
           
protected static java.lang.String MESSAGE_OBJECT
           
protected static java.lang.String MESSAGE_RELEASE
           
protected static java.lang.String MESSAGE_TYPE
           
protected static java.lang.String QUERY_ACTION
           
protected static java.lang.String UPDATE_ACTION
           
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
ConsumerCommand()
           
ConsumerCommand(CommandConfig cConfig)
          Default constructor behavior that will apply to all command implementations.
 
Method Summary
protected  void addAppConfig(AppConfig aConfig)
           
protected  Error buildError(java.lang.String errType, java.lang.String errNumber, java.lang.String errDescription)
          Builds a single Error object that can be added to the ArrayList of errors (or for any other reason) to pass to the publishSyncError method.
protected  java.lang.String convertToString(org.jdom.Document doc)
           
 java.lang.String generateRelease(java.lang.String release)
          Takes the release number passed in which is generally pulled from a message passed to a command and converts it into a release number that can be used for naming conventions in configuration documents.
 AppConfig getAppConfig()
          Get AppConfig associated to this command.
protected  java.util.Vector getAppConfigs()
           
protected  org.jdom.Element getControlArea(org.jdom.Element root)
          This method looks at the document and returns the appropriate ControlArea.
protected  boolean getInboundXmlValidation()
          Get inbound xml validation.
protected  java.lang.String getMessageAction(org.jdom.Document inDoc)
          Returns the value of the 'messageAction' Attribute from the ControlArea in the Document passed in.
 java.lang.String getMessageBody(org.jdom.Document inDoc)
          Returns the messageBody that was built during the initializeInput method call.
protected  java.lang.String getMessageCategory(org.jdom.Document inDoc)
          Returns the value of the 'messageCategory' Attribute from the ControlArea in the Document passed in.
protected  java.lang.String getMessageDumpDirectory()
          Returns the messageDumpDirectory variable that will be the target of the writeMessageToFile call if the command needs to write the incoming message to a file.
protected  java.lang.String getMessageObject(org.jdom.Document inDoc)
          Returns the value of the 'messageObject' Attribute from the ControlArea in the Document passed in.
protected  java.lang.String getMessageRelease(org.jdom.Document inDoc)
          Returns the value of the 'messageRelease' Attribute from the ControlArea in the Document passed in.
protected  java.lang.String getMessageType(org.jdom.Document inDoc)
          Returns the value of the 'messageType' Attribute from the ControlArea in the Document passed in.
 java.util.HashMap getMsgComponents()
          Returns the HashMap that is a list of Messaging Components (gateways) that this command needs to know about.
protected  boolean getOutboundXmlValidation()
          Get outbound xml validation.
protected  org.jdom.Document initializeInput(int messageNumber, javax.jms.Message aMessage)
          Gets the message body from the JMS message passed in and creates an XML document from that data.
protected  void setAppConfig(AppConfig aConfig)
          Set AppConfig associated to this command.
protected  void setInboundXmlValidation(boolean validate)
          Set inbound xml validation.
protected  void setMessageDumpDirectory(java.lang.String dumpDir)
          Sets the messageDumpDirectory variable that will be the target of the writeMessageToFile call if the command needs to write the incoming message to a file.
 void setMsgComponents(java.util.HashMap components)
          Sets the HashMap that is a list of Messaging Components (gateways) that this command needs to know about.
protected  void setOutboundXmlValidation(boolean validate)
          Set outbound xml validation.
protected  void setWriteToFile(boolean writeToFile)
          Sets the writeToFile variable that will be used by the commands to determine if they should write the message to a file.
protected  void writeMessageToFile(java.lang.String msgObject, org.jdom.Document doc, java.lang.String msgDumpDir)
          Used by decendant commands to serialize a message passed to the command to the file system.
protected  boolean writeToFile()
          Returns the writeToFile variable that will be used by the commands to determine if they should write the message to a file.
 
Methods inherited from class org.openeai.OpenEaiObject
addLog4jProperty, getAppName, getDebug, getFromAddr, getLog4jProperties, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setAppName, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_ACTION


protected static final java.lang.String MESSAGE_ACTION
See Also:
Constant Field Values

MESSAGE_CATEGORY


protected static final java.lang.String MESSAGE_CATEGORY
See Also:
Constant Field Values

MESSAGE_OBJECT


protected static final java.lang.String MESSAGE_OBJECT
See Also:
Constant Field Values

MESSAGE_RELEASE


protected static final java.lang.String MESSAGE_RELEASE
See Also:
Constant Field Values

MESSAGE_TYPE


protected static final java.lang.String MESSAGE_TYPE
See Also:
Constant Field Values

CREATE_ACTION


protected static final java.lang.String CREATE_ACTION
See Also:
Constant Field Values

DELETE_ACTION


protected static final java.lang.String DELETE_ACTION
See Also:
Constant Field Values

QUERY_ACTION


protected static final java.lang.String QUERY_ACTION
See Also:
Constant Field Values

UPDATE_ACTION


protected static final java.lang.String UPDATE_ACTION
See Also:
Constant Field Values
Constructor Detail

ConsumerCommand


public ConsumerCommand()

ConsumerCommand


public ConsumerCommand(CommandConfig cConfig)
                throws java.lang.InstantiationException
Default constructor behavior that will apply to all command implementations. Sets the AppConfig object Sets Xml Validation (inbound and outbound) Determines if this command should write incomming messages to a file and establishes the location to which those files should be written.

Throws:
java.lang.InstantiationException - if errors occur during initialization.
Method Detail

getMessageCategory


protected java.lang.String getMessageCategory(org.jdom.Document inDoc)
Returns the value of the 'messageCategory' Attribute from the ControlArea in the Document passed in. Returns null if the attribute does not exist.

Returns:
String the messageCategory value from the ControlArea or null if none exists

getMessageObject


protected java.lang.String getMessageObject(org.jdom.Document inDoc)
Returns the value of the 'messageObject' Attribute from the ControlArea in the Document passed in. Returns null if the attribute does not exist.

Returns:
String the messageObject value from the ControlArea or null if none exists

getMessageAction


protected java.lang.String getMessageAction(org.jdom.Document inDoc)
Returns the value of the 'messageAction' Attribute from the ControlArea in the Document passed in. Returns null if the attribute does not exist.

Returns:
String the messageAction value from the ControlArea or null if none exists

getMessageType


protected java.lang.String getMessageType(org.jdom.Document inDoc)
Returns the value of the 'messageType' Attribute from the ControlArea in the Document passed in. Returns null if the attribute does not exist.

Returns:
String the messageType value from the ControlArea or null if none exists

getMessageRelease


protected java.lang.String getMessageRelease(org.jdom.Document inDoc)
Returns the value of the 'messageRelease' Attribute from the ControlArea in the Document passed in. Returns null if the attribute does not exist.

Returns:
String the messageRelease value from the ControlArea or null if none exists

initializeInput


protected org.jdom.Document initializeInput(int messageNumber,
                                            javax.jms.Message aMessage)
                                     throws javax.jms.JMSException
Gets the message body from the JMS message passed in and creates an XML document from that data. Also, this method writes the message to a file (as an xml document) if writeToFile is true, this is established in the Command's constructor.

javax.jms.JMSException

setMessageDumpDirectory


protected void setMessageDumpDirectory(java.lang.String dumpDir)
Sets the messageDumpDirectory variable that will be the target of the writeMessageToFile call if the command needs to write the incoming message to a file. It is called in the from the Command constructor.


getMessageDumpDirectory


protected java.lang.String getMessageDumpDirectory()
Returns the messageDumpDirectory variable that will be the target of the writeMessageToFile call if the command needs to write the incoming message to a file. It is called by the Command if it needs to write the message to file.

Returns:
- String

setWriteToFile


protected void setWriteToFile(boolean writeToFile)
Sets the writeToFile variable that will be used by the commands to determine if they should write the message to a file. It is called in the from the Command constructor.


writeToFile


protected boolean writeToFile()
Returns the writeToFile variable that will be used by the commands to determine if they should write the message to a file. It is called by commands to determine if they should write the incoming message to a file.

Returns:
- boolean

getMessageBody


public final java.lang.String getMessageBody(org.jdom.Document inDoc)
Returns the messageBody that was built during the initializeInput method call. this will be a 'String' object built from the message body of the JMS message passed in.

Returns:
String

setAppConfig


protected void setAppConfig(AppConfig aConfig)
Set AppConfig associated to this command. It is called in the constructor of Command.


getAppConfig


public final AppConfig getAppConfig()
Get AppConfig associated to this command. It is called by commands to get access to command specific OpenEAI objects like message objects, db connection pools, producers threadpools, properties etc..

Returns:
AppConfig

setInboundXmlValidation


protected void setInboundXmlValidation(boolean validate)
Set inbound xml validation. This is used to determine whether or not to validate the xml document as when it's first consumed. It is called in the constructor of Command.


getInboundXmlValidation


protected boolean getInboundXmlValidation()
Get inbound xml validation. This is used to determine whether or not to validate the xml document as when it's first consumed.

Returns:
boolean

setOutboundXmlValidation


protected void setOutboundXmlValidation(boolean validate)
Set outbound xml validation. This is used to determine whether or not to validate the xml document before it's returned or routed. It is called in the constructor of Command.


getOutboundXmlValidation


protected boolean getOutboundXmlValidation()
Get outbound xml validation. This is used to determine whether or not to validate the xml document before it's returned or routed. It is called by commands...

Returns:
boolean

addAppConfig


protected void addAppConfig(AppConfig aConfig)

getAppConfigs


protected java.util.Vector getAppConfigs()

setMsgComponents


public final void setMsgComponents(java.util.HashMap components)
Sets the HashMap that is a list of Messaging Components (gateways) that this command needs to know about. This is specifically used by gateways like Routers and Proxies which need to forward sync or request messages to an end point. This is a list of AppConfig objects that correspond to that end point and contains message object, producers etc. that are needed to route/forward a message to that end point.

Returns:
void

getMsgComponents


public final java.util.HashMap getMsgComponents()
Returns the HashMap that is a list of Messaging Components (gateways) that this command needs to know about. This is specifically used by gateways like Routers and Proxies which need to forward sync or request messages to an end point. This is a list of AppConfig objects that correspond to that end point and contains message object, producers etc. that are needed to route/forward a message to that end point.

Returns:
HashMap a HashMap containing AppConfigs for end points of intrest to this command.

writeMessageToFile


protected void writeMessageToFile(java.lang.String msgObject,
                                  org.jdom.Document doc,
                                  java.lang.String msgDumpDir)
                           throws java.io.IOException
Used by decendant commands to serialize a message passed to the command to the file system. Generally, this method will only be called when the initializeInput method is called and the JMS Message is initially turned into an XML Document (org.jdom.Document). However, some commands may also wish to serialize the document themselves, for example, a Router may wish to serialize the document after it's modified the content of the message and before it routes it.

java.io.IOException

buildError


protected Error buildError(java.lang.String errType,
                           java.lang.String errNumber,
                           java.lang.String errDescription)
Builds a single Error object that can be added to the ArrayList of errors (or for any other reason) to pass to the publishSyncError method.

Returns:
org.openeai.moa.objects.Error the error object that gets built.

convertToString


protected java.lang.String convertToString(org.jdom.Document doc)
                                    throws java.io.IOException
java.io.IOException

generateRelease


public final java.lang.String generateRelease(java.lang.String release)
Takes the release number passed in which is generally pulled from a message passed to a command and converts it into a release number that can be used for naming conventions in configuration documents. Since gateways have to be able to support multiple versions of a message object, it is sometimes helpful to adopt a naming convention to name these objects. Then, a ConsumerCommand implementation can take the release from the message and convert it into the release used to name an object in order to retrieve that object from an AppConfig.

For example, the messageRelease attribute in the message consumed is "1.0", this method will convert that to "v1_0" which is a common naming convention that's been used by many of the OpenEAI reference implementation applications/gateways. The gateway has a message object with this release appended to its name in its configuration document. For example, "BasicPerson.v1_0". Then, the command can retrieve message objects from its AppConfig without having to hard code any names etc. instead, it can rely on the contents of the message and use that information to derive the necessary name.

Returns:
String the converted release (e.g. - v1_0, v2_0 etc.) that can be used to pull the object from the commands AppConfig.

getControlArea


protected org.jdom.Element getControlArea(org.jdom.Element root)
This method looks at the document and returns the appropriate ControlArea. Since there can be three different control areas based on the message (ControlAreaRequest, ControlAreaReply and ControlAreaSync) we need to have some intelligence built in when retrieving the element from the document. Therefore, command implementations can just call this method and get a ControlArea element based on the type of message being processed without having to make assumptions regarding the type of message it's processing and without performing this logic themselves.

Parameters:
root - org.jdom.Element the root element of the document
Returns:
Element the ControlArea element (may be ControlAreaRequest, ControlAreaReply or ControlAreaSync depending on the doc)


Copyright © 2002, OpenEAI Software Foundation