atg.commerce.approval
Class MessagePipelineMapper

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.messaging.SourceSinkTemplate
              extended by atg.commerce.approval.MessagePipelineMapper
All Implemented Interfaces:
MessageSink, MessageSource, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
MessagePipelineMapper

public class MessagePipelineMapper
extends SourceSinkTemplate

This class executes a Pipeline chain upon receipt of a JMS message. It is designed to execute the chain in its own transaction. If an exception occurs, then an error chain is executed rather than throwing the exception back to the messaging system which would then resend it.


Field Summary
static java.lang.String CLASS_VERSION
           
protected static java.util.ResourceBundle sResourceBundle
          Resource Bundle
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
MessagePipelineMapper()
          Creates a new MessagePipelineMapper instance.
 
Method Summary
protected  void executeErrorChain(javax.jms.ObjectMessage pMessage, java.lang.String pMessageType, java.lang.String pPortName, java.lang.Object pParams)
          This method is executed when a fatal error occurs.
 PipelineManager getApprovalPipelineManager()
          Returns property approvalPipelineManager
protected  java.lang.String getErrorPipelineIdForMessage(javax.jms.ObjectMessage pMessage, java.lang.String pMessageType, java.lang.String pPortName)
          This method is used to obtain the error pipeline chain that should be executed if the execution for a given incoming message fails.
 java.util.Properties getMessageTypeToChainNameMap()
          Return the MessageTypeToChainNameMap property.
 java.util.Properties getMessageTypeToErrorChainNameMap()
          Return the MessageTypeToErrorChainNameMap property.
protected  java.lang.String getPipelineIdForMessage(javax.jms.ObjectMessage pMessage, java.lang.String pMessageType, java.lang.String pPortName)
          This method is used to obtain the pipeline chain that should be executed for a given incoming message.
protected  java.util.Map getPipelineParamsForMessage(javax.jms.ObjectMessage pMessage, java.lang.String pMessageType, java.lang.String pPortName)
          This method is responsible for populating a Map with the appropriate information on what data should be passed to a pipline chain.
 javax.transaction.TransactionManager getTransactionManager()
          Returns property transactionManager
protected  void handleObjectMessage(javax.jms.ObjectMessage pMessage, java.lang.String pMessageType, java.lang.String pPortName, java.lang.Object pParams)
          make a call to the appropriate method to handle the type of message that we have.
protected  boolean processPipelineErrors(PipelineResult pResult)
          This method processes the pipeline result error messages.
 void receiveMessage(java.lang.String pPortName, javax.jms.Message pMessage)
          This method is called when an ApprovalUpdateMessage is sent to it.
 void setApprovalPipelineManager(PipelineManager pApprovalPipelineManager)
          Sets property approvalPipelineManager
 void setMessageTypeToChainNameMap(java.util.Properties pMessageTypeToChainNameMap)
          Set the MessageTypeToChainNameMap property.
 void setMessageTypeToErrorChainNameMap(java.util.Properties pMessageTypeToErrorChainNameMap)
          Set the MessageTypeToErrorChainNameMap property.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets property transactionManager
 
Methods inherited from class atg.commerce.messaging.SourceSinkTemplate
getDelayOnSendRetry, getMessageSourceContext, getMessageSourceName, isAllowMessageSending, sendCommerceMessage, sendObjectMessage, setAllowMessageSending, setDelayOnSendRetry, setMessageSourceContext, setMessageSourceName, startMessageSource, stopMessageSource
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle

Constructor Detail

MessagePipelineMapper

public MessagePipelineMapper()
Creates a new MessagePipelineMapper instance. Creates a new HashMap for the messageTypeToChainNameMap property.

Method Detail

getMessageTypeToChainNameMap

public java.util.Properties getMessageTypeToChainNameMap()
Return the MessageTypeToChainNameMap property.

Returns:

setMessageTypeToChainNameMap

public void setMessageTypeToChainNameMap(java.util.Properties pMessageTypeToChainNameMap)
Set the MessageTypeToChainNameMap property.

Parameters:
pMessageTypeToChainNameMap -

getMessageTypeToErrorChainNameMap

public java.util.Properties getMessageTypeToErrorChainNameMap()
Return the MessageTypeToErrorChainNameMap property.

Returns:

setMessageTypeToErrorChainNameMap

public void setMessageTypeToErrorChainNameMap(java.util.Properties pMessageTypeToErrorChainNameMap)
Set the MessageTypeToErrorChainNameMap property.

Parameters:
pMessageTypeToErrorChainNameMap -

getApprovalPipelineManager

public PipelineManager getApprovalPipelineManager()
Returns property approvalPipelineManager

Returns:
returns property approvalPipelineManager

setApprovalPipelineManager

public void setApprovalPipelineManager(PipelineManager pApprovalPipelineManager)
Sets property approvalPipelineManager

Parameters:
pApprovalPipelineManager - the value to set for property approvalPipelineManager

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns property transactionManager

Overrides:
getTransactionManager in class SourceSinkTemplate
Returns:
returns property transactionManager

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets property transactionManager

Overrides:
setTransactionManager in class SourceSinkTemplate
Parameters:
pTransactionManager - the value to set for property transactionManager

receiveMessage

public void receiveMessage(java.lang.String pPortName,
                           javax.jms.Message pMessage)
                    throws javax.jms.JMSException
This method is called when an ApprovalUpdateMessage is sent to it. Based on the message type it will execute a pipeline chain configured in the ApprovalPipelineManager component which is configured in this class. The mapping is defined in the messageTypeToChainNameMap property. If an error occurs, then an error chain is executed. The error chain mapping is defined in the messageTypeToErrorChainNameMap property.

Specified by:
receiveMessage in interface MessageSink
Overrides:
receiveMessage in class SourceSinkTemplate
Throws:
javax.jms.JMSException

handleObjectMessage

protected void handleObjectMessage(javax.jms.ObjectMessage pMessage,
                                   java.lang.String pMessageType,
                                   java.lang.String pPortName,
                                   java.lang.Object pParams)
                            throws RunProcessException
make a call to the appropriate method to handle the type of message that we have.

Parameters:
pMessage - an ObjectMessage value
pPortName - a String value
Throws:
RunProcessException

executeErrorChain

protected void executeErrorChain(javax.jms.ObjectMessage pMessage,
                                 java.lang.String pMessageType,
                                 java.lang.String pPortName,
                                 java.lang.Object pParams)
This method is executed when a fatal error occurs. It executes the error chain for the corresponding message.

Parameters:
pMessage - an ObjectMessage value
pMessageType - a String value
pPortName - a String value

getPipelineIdForMessage

protected java.lang.String getPipelineIdForMessage(javax.jms.ObjectMessage pMessage,
                                                   java.lang.String pMessageType,
                                                   java.lang.String pPortName)
This method is used to obtain the pipeline chain that should be executed for a given incoming message. Using this method of named pipelinechain to a message allows the addition of new behavior by this class with no additional extension to this class necessary, just its configuration.

The way that this method works is that it determins a pipeline chain to execute based upon the String in the pMessageType parameter. This by default is the JMSType of the ObjectMessage. This class maintains a Map of messageType to chain names. The key into this map should be the JMSType of the particular message. So, if a message of type atg.commerce.order.SubmitOrder comes into

Parameters:
pMessage - an ObjectMessage value
pMessageType - a String value
pPortName - a String value
Returns:
a String value

getErrorPipelineIdForMessage

protected java.lang.String getErrorPipelineIdForMessage(javax.jms.ObjectMessage pMessage,
                                                        java.lang.String pMessageType,
                                                        java.lang.String pPortName)
This method is used to obtain the error pipeline chain that should be executed if the execution for a given incoming message fails. Using this method of named errorpipelinechain to a message allows the addition of new behavior by this class with no additional extension to this class necessary, just its configuration.

Parameters:
pMessage - an ObjectMessage value
pMessageType - a String value
pPortName - a String value
Returns:
a String value

getPipelineParamsForMessage

protected java.util.Map getPipelineParamsForMessage(javax.jms.ObjectMessage pMessage,
                                                    java.lang.String pMessageType,
                                                    java.lang.String pPortName)
This method is responsible for populating a Map with the appropriate information on what data should be passed to a pipline chain. By default, the information passed is the object message, the message type and the portname that the message came in on. This information is placed into the Hashmap using the appropriate values from the ApprovalConstants file. The relevant values are as follows This method can be overriden if necessary to populate the pipeline chain with additional information besides this data. The intention though is that the data that is relevant to any chain is contained in the object message itself, and thus by configuring a JMSType to ChainName property, the individual chain can be responsible for sucking out the correct information.

Parameters:
pMessage - an ObjectMessage value
pMessageType - a String value
pPortName - a String value
Returns:
a Map value

processPipelineErrors

protected boolean processPipelineErrors(PipelineResult pResult)
This method processes the pipeline result error messages.