org.openeai.config
Class CommandConfig

java.lang.Object
  |
  +--org.openeai.OpenEaiObject
        |
        +--org.openeai.config.EnterpriseConfigurationObjectImpl
              |
              +--org.openeai.config.CommandConfig
All Implemented Interfaces:
EnterpriseConfigurationObject

public class CommandConfig
extends EnterpriseConfigurationObjectImpl
implements EnterpriseConfigurationObject

A CommandConfig is a wrapper class that takes information stored in an OpenEAI Deployment document (Command Element) and stores it in a Java object. Then the configuration object is passed to the constructor of command implementations (both ScheduledCommands and ConsumerCommands) and they are able to configure themselves with the information found in the config object.

Configuration Parameters:

These are the configuration parameters specified by the Command Element in the Deployment document. NOTE: Like all other OpenEAI configuration objects, there is a "container" level associated to Command objects. Many Elements and attributes are required at that level and may be optionally overridden at this level. This is to avoid having to enter redundant information in the Deployment document if all (or most) Command objects being configured should use the same configuration information. Therefore, many of the Command configuration parameters are optional at this level but required at the "container" level. Where this is the case, it will be indicated by an "*".

Name Required Description
CommandName yes Name of the Command. The consumer will look at the COMMAND_NAME JMS Property associated to each message it consumes and execute the command with that name.
CommandClass yes Fully qualified class name of the Command implementation for the consumer to instantiate. The consumer will then execute this instance each time it consumes a message that has a COMMAND_NAME JMS Property with this CommandName.
Configuration no The configuration Element that specifies what components this Command will have at its disposal. This is the Command's AppConfig object.
MessagingComponents no Other messaging components that this command might need to interact with. Typically, this is only needed for infrastructure type gateways, like Routers and Proxies that will forward messages to other components in an enterprise. This will end up being an AppConfig object for each one of those components so this Command may have Producers, Properties, MessageObjects etc. set up according to that components needs. It is mostly just a convienient way to accomplish this goal re-using existing foundation to configure and organize those objects.
type yes The type of command being initialized (Request, Sync or Scheduled)
isDefault (true | false) no (defaults to false) Signifies that the command being initialized is the "default" command to be executed if the message consumed by the consumer does not have the COMMAND_NAME JMS Property set on it.
isAbsolute (true | false) no (defaults to false) If true, indicates that the command being initialized is the ONLY command that will ever be executed by the consumer no matter what the COMMAND_NAME JMS Property set to. It is only appropriate to set this to true if the Consumer only executes one command.
inboundXmlValidation (true | false) no* Indicates whether or not this Command should perform XML validation on the messages passed to it. This is automatically checked and performed when the command uses the initializeInput method to build the Document out of the JMS Message passed to it by the Consumer.
outboundXmlValidation (true | false) no* Indicates whether or not this Command should perform XML validation on the messages it returns or forwards after it's finished performing the business logic associated to the command. This is NOT currently automatically performed by any foundation code. It is up to the Command itself to check this flag and validate the document itself. This may eventually be put in the buildReplyDocument method as a convenience.
writeToFile (true | false) no* Indicates whether or not this Command should serialize the contents of the Message passed to it when it builds the XML Document from the message.
messageDumpDirectory no Indicates the directory where the message should be serialized to (if writeToFile is true). If no directory is specified, it will default to the current directory of the running application (the gateway).

Version:
3.0 beta2 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
CommandConfig()
          This is the constructor used by ConsumerConfig to instantiate the config object.
CommandConfig(org.jdom.Element configElement)
           
CommandConfig(java.lang.String configDocUrl, java.lang.String commandName)
           
 
Method Summary
 void addMsgComponent(java.lang.String name, org.jdom.Element eComponent)
          Adds a configuration Element to a HashMap for another Message Component that this command may need to know about.
 AppConfig getAppConfig()
          Returns the AppConfig object associated to this command as specified in the Command's Configuration Element in the config document.
 java.lang.String getClassName()
          Returns the ClassName associated to this command as specified in the Command's Configuration Element in the config document.
 org.jdom.Element getDefaultParms()
          Returns the default paramaters associated to this command as specified in the "Commands" Configuration Element (the container) in the application's config document.
 boolean getInboundXmlValidation()
          Returns a boolean value that indicates whether or not this command should validate the Xml Document it creates from the JMS message that it receives.
 java.lang.String getMessageDumpDirectory()
          Returns the message dump directory that this command should use to persist incomming messages if the "writeToFile" flag is true.
 org.jdom.Element getMsgComponent(java.lang.String name)
          Returns a configuration Element associated to a particular end-point by name.
 java.util.HashMap getMsgComponents()
          Returns the entire HashMap of configuration Elements for all messaging components that this command might need to know about.
 java.lang.String getName()
          Returns the name of this command as specified in the configuration document.
 boolean getOutboundXmlValidation()
          Returns a boolean value that indicates whether or not this command should validate any Xml Documents it publishes or returns to a client.
 java.lang.String getType()
          Returns type associated to this command.
 void init(org.jdom.Element eCommand)
          Implements the init(Element) method that all EnterpriseConfiguration objects must implement.
 boolean isAbsolute()
          Returns a boolean value that indicates if this command is the "absolute" command the consumer instantiating this command should execute no matter what "COMMAND_NAME" is specified in the JMS Message it consumes.
 boolean isDefault()
          Returns a boolean value that indicates if this command is the "default" command the consumer instantiating this command should execute if no "COMMAND_NAME" is specified in the JMS Message it consumes.
 void setAbsolute(boolean def)
          Sets the boolean value that indicates if this command is the "absolute" command the consumer instantiating this command should execute no matter what "COMMAND_NAME" is specified in the JMS Message it consumes.
 void setAppConfig(AppConfig appConfig)
          Sets the AppConfig object associated to this command as specified in the Command's Configuration Element in the config document.
 void setClassName(java.lang.String className)
          Sets the ClassName associated to this command as specified in the Command's Configuration Element in the config document.
 void setDefault(boolean def)
          Sets the boolean value that indicates if this command is the "default" command the consumer instantiating this command should execute if no "COMMAND_NAME" is specified in the JMS Message it consumes.
 void setDefaultParms(org.jdom.Element eDefaultParms)
          Sets the default paramaters associated to this command as specified in the "Commands" Configuration Element (the container) in the application's config document.
 void setInboundXmlValidation(boolean validate)
          Sets the boolean indicator which will be used to determine whether or not this command should validate the Xml Document it creates from the JMS message that it receives.
 void setMessageDumpDirectory(java.lang.String dumpDir)
          Sets the message dump directory that this command should use to persist incomming messages if the "writeToFile" flag is true.
 void setName(java.lang.String name)
          Sets the name of this command as specified in the configuration document.
 void setOutboundXmlValidation(boolean validate)
          Sets an indicator that specifies if this command should validate any Xml Documents it publishes or returns to a client.
 void setType(java.lang.String type)
          Sets the type associated to this command.
 void setWriteToFile(boolean writeToFile)
          Sets a boolean value that indicates if this command should write the incomming messages it recieves to the file system.
 boolean writeToFile()
          Returns a boolean value that indicates if this command should write the incomming messages it recieves to the file system.
 
Methods inherited from class org.openeai.config.EnterpriseConfigurationObjectImpl
addProperty, getAppName, getConfigDoc, getConfigElementByAttributeValue, getElementByAttributeValue, getValidation, setAppName, setConfigDoc, setValidation
 
Methods inherited from class org.openeai.OpenEaiObject
addLog4jProperty, getDebug, getFromAddr, getLog4jProperties, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openeai.config.EnterpriseConfigurationObject
getAppName, getProperties, setAppName
 

Constructor Detail

CommandConfig

public CommandConfig()
This is the constructor used by ConsumerConfig to instantiate the config object. Then, ConsumerConfig calls this object's init(Element) method passing the configuration element it retrieved from the XML configuration document which this object uses to configure itself. After this object has initialized itself, it will be used to instantiate and initialize the framework object (MessageObject, Producers, Consumers, ThreadPools etc.) with the properties it's been initialized with.


CommandConfig

public CommandConfig(java.lang.String configDocUrl,
                     java.lang.String commandName)
              throws EnterpriseConfigurationObjectException

CommandConfig

public CommandConfig(org.jdom.Element configElement)
              throws EnterpriseConfigurationObjectException
Method Detail

setDefaultParms

public void setDefaultParms(org.jdom.Element eDefaultParms)
Sets the default paramaters associated to this command as specified in the "Commands" Configuration Element (the container) in the application's config document.

These default parameters are built from the "container" level configuration component in the config document (Commands). This is to allow "default" configuration information to be specified for all Commands that exist within this container. If needed a particular Command can override these default parameters. Otherwise the default parameters are used. This way, duplicate configuration information does not have to be specified for each Command.


getDefaultParms

public org.jdom.Element getDefaultParms()
Returns the default paramaters associated to this command as specified in the "Commands" Configuration Element (the container) in the application's config document.

These default parameters are built from the "container" level configuration component in the config document (Commands). This is to allow "default" configuration information to be specified for all Commands that exist within this container. If needed a particular Command can override these default parameters. Otherwise the default parameters are used. This way, duplicate configuration information does not have to be specified for each Command.

Returns:
Element

setMessageDumpDirectory

public void setMessageDumpDirectory(java.lang.String dumpDir)
Sets the message dump directory that this command should use to persist incomming messages if the "writeToFile" flag is true. This information is obtained from the configuration document for this command.


getMessageDumpDirectory

public java.lang.String getMessageDumpDirectory()
Returns the message dump directory that this command should use to persist incomming messages if the "writeToFile" flag is true.

Returns:
String

setInboundXmlValidation

public void setInboundXmlValidation(boolean validate)
Sets the boolean indicator which will be used to determine whether or not this command should validate the Xml Document it creates from the JMS message that it receives. This is specified in the Configuration document for the command.


getInboundXmlValidation

public boolean getInboundXmlValidation()
Returns a boolean value that indicates whether or not this command should validate the Xml Document it creates from the JMS message that it receives. This is specified in the Configuration document for the command.

Returns:
boolean

setWriteToFile

public void setWriteToFile(boolean writeToFile)
Sets a boolean value that indicates if this command should write the incomming messages it recieves to the file system. This is specified in the Configuration document for the command via the "writeToFile" attribute.

Returns:
boolean

writeToFile

public boolean writeToFile()
Returns a boolean value that indicates if this command should write the incomming messages it recieves to the file system. This is specified in the Configuration document for the command via the "writeToFile" attribute.

Returns:
boolean

setOutboundXmlValidation

public void setOutboundXmlValidation(boolean validate)
Sets an indicator that specifies if this command should validate any Xml Documents it publishes or returns to a client. It would publish the message if it's a SyncCommand and it would return the message if it's a RequestCommand. This is specified in the Configuration document for the command.


getOutboundXmlValidation

public boolean getOutboundXmlValidation()
Returns a boolean value that indicates whether or not this command should validate any Xml Documents it publishes or returns to a client. It would publish the message if it's an SyncCommand and it would return the message if it's an RequestCommand. This is specified in the Configuration document for the command.

Returns:
boolean

addMsgComponent

public void addMsgComponent(java.lang.String name,
                            org.jdom.Element eComponent)
Adds a configuration Element to a HashMap for another Message Component that this command may need to know about. Some gateways need to forward Sync or Request messages to other gateways. Typically, these are infrastructure type gateways like routers and request proxies. This structure allows those types of gateways to store up the configuration for the end points that they need to message with. Then, those gateways can treat these 'message component' elements as AppConfig objects for the end points. They can know the 'application' configuration for that end-point (like message objects, producers etc.) and use that configuration to determine when to message with that end-point and what foundation objects to use to do so.


getMsgComponent

public org.jdom.Element getMsgComponent(java.lang.String name)
Returns a configuration Element associated to a particular end-point by name. This is the "Configuration" Element listed in the deployment document for the command being configured.

Returns:
Element the configuration Element that was stored for that end-point.

getMsgComponents

public java.util.HashMap getMsgComponents()
Returns the entire HashMap of configuration Elements for all messaging components that this command might need to know about.

Returns:
HashMap the list of Messaging Components that was built based on informatino found in this command's configuration document.

getAppConfig

public AppConfig getAppConfig()
Returns the AppConfig object associated to this command as specified in the Command's Configuration Element in the config document.

Returns:
AppConfig

setAppConfig

public void setAppConfig(AppConfig appConfig)
Sets the AppConfig object associated to this command as specified in the Command's Configuration Element in the config document.


isDefault

public boolean isDefault()
Returns a boolean value that indicates if this command is the "default" command the consumer instantiating this command should execute if no "COMMAND_NAME" is specified in the JMS Message it consumes. This is specified in the Configuration document for the command via the "isDefault" attribute.

Returns:
boolean

setDefault

public void setDefault(boolean def)
Sets the boolean value that indicates if this command is the "default" command the consumer instantiating this command should execute if no "COMMAND_NAME" is specified in the JMS Message it consumes. This is specified in the Configuration document for the command via the "isDefault" attribute.

Returns:
boolean

isAbsolute

public boolean isAbsolute()
Returns a boolean value that indicates if this command is the "absolute" command the consumer instantiating this command should execute no matter what "COMMAND_NAME" is specified in the JMS Message it consumes. This is specified in the Configuration document for the command via the "isAbsolute" attribute.

Returns:
boolean

setAbsolute

public void setAbsolute(boolean def)
Sets the boolean value that indicates if this command is the "absolute" command the consumer instantiating this command should execute no matter what "COMMAND_NAME" is specified in the JMS Message it consumes. This is specified in the Configuration document for the command via the "isAbsolute" attribute.

Returns:
boolean

setType

public void setType(java.lang.String type)
Sets the type associated to this command. This is specified in the Configuration document for the command. Currently, valid values include "syncMessage", "requestMessage" and "scheduled".

Overrides:
setType in class EnterpriseConfigurationObjectImpl
Returns:
String

getType

public java.lang.String getType()
Returns type associated to this command. This is specified in the Configuration document for the command. Currently, valid values include "syncMessage", "requestMessage" and "scheduled".

Overrides:
getType in class EnterpriseConfigurationObjectImpl
Returns:
String

setName

public void setName(java.lang.String name)
Sets the name of this command as specified in the configuration document.

Overrides:
setName in class EnterpriseConfigurationObjectImpl

getName

public java.lang.String getName()
Returns the name of this command as specified in the configuration document.

Overrides:
getName in class EnterpriseConfigurationObjectImpl
Returns:
String

setClassName

public void setClassName(java.lang.String className)
Sets the ClassName associated to this command as specified in the Command's Configuration Element in the config document.


getClassName

public java.lang.String getClassName()
Returns the ClassName associated to this command as specified in the Command's Configuration Element in the config document.

Returns:
String

init

public void init(org.jdom.Element eCommand)
          throws EnterpriseConfigurationObjectException
Implements the init(Element) method that all EnterpriseConfiguration objects must implement. This init method takes the Configuration element passed in and pulls out configuration information specific to the Command being initialized. Then it sets various instance variables and properties on itself which will be used by the Command when the Consumer or Schedule instantiates it passing this configuration object. The Command will then use the configuration java object to initialize itself.

Specified by:
init in interface EnterpriseConfigurationObject
Throws:
EnterpriseConfigurationObjectException - if errors occur processing the configuration Element.


Copyright © 2002, OpenEAI Software Foundation