atg.commerce.order.processor
Class EventSender

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.logging.ApplicationLoggingImpl
          extended by atg.commerce.order.processor.EventSender
All Implemented Interfaces:
MessageSource, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, PipelineProcessor
Direct Known Subclasses:
ProcSendApprovalCompleteMessage, ProcSendApprovalMessage, ProcSendApprovalRequiredMessage, ProcSendFulfillmentMessage, ProcSendGiftPurchasedMessage, ProcSendPromotionUsedMessage, ProcSendScenarioEvent

public class EventSender
extends ApplicationLoggingImpl
implements PipelineProcessor, MessageSource

This is a base class that should be extended by other processors that wish to send events from within a chain. @see ProcSendFulfillmentMessage is an example of just such a processor.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  int FAILURE
           
protected  int SUCCESS
           
 
Fields inherited from interface atg.service.pipeline.PipelineProcessor
STOP_CHAIN_EXECUTION, STOP_CHAIN_EXECUTION_AND_COMMIT, STOP_CHAIN_EXECUTION_AND_ROLLBACK
 
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
EventSender()
          An empty constructor.
 
Method Summary
 java.io.Serializable createEventToSend(java.lang.Object pParam, PipelineResult pResult)
          This method creates and returns the event to be sent by this processor.
 java.lang.String getEventType()
          Deprecated. Subclasses of this (such as ProcSendScenarioEvent) may dynamically determine the type of event. meaning getEventType may not be thread safe (since the type is set in "createEventToSend" and and checked when calling "sendObjectMessage"). Use the getEventType method that takes an Object as a parameter instead.
 java.lang.String getEventType(java.lang.Object pEventToSend)
          This will return the event type defined on the class (same behavior as calling getEventType().
 IdGenerator getMessageIdGenerator()
          The service that generates Ids for all messages.
 java.lang.String getMessageIdSpaceName()
          The name of the idspace to get our message ids from
 MessageSourceContext getMessageSourceContext()
          Return the message source context for this source.
 java.lang.String getNextMessageId()
          Uses the id generator to get the next message id.
 java.lang.String getPortName()
          The port on which this message is sent.
 int[] getRetCodes()
          Returns the valid return codes 1 - The processor executed successfully 2 - The processor failed to execute properly
protected  java.lang.String getSiteId(java.lang.Object pParams)
          Retrieves site id from pipeline parameters
 boolean isAllowMessageSending()
          This class cannot send messages if this is false.
 int runProcess(java.lang.Object pParam, PipelineResult pResult)
          This method will call @see #createEventToSend which will return the event object to be sent.
 void sendObjectMessage(java.io.Serializable pObjectMessage, java.lang.String pType, java.lang.String pPortName)
          Sends an object message of type pType, out on port pPortName.
 void setAllowMessageSending(boolean pAllowMessageSending)
           
 void setEventType(java.lang.String pEventType)
           
 void setMessageIdGenerator(IdGenerator pMessageIdGenerator)
           
 void setMessageIdSpaceName(java.lang.String pMessageIdSpaceName)
           
 void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
          Set the message source context for this source.
 void setPortName(java.lang.String pPortName)
           
 void startMessageSource()
          This is called to tell the MessageSource that it may begin sending messages.
 void stopMessageSource()
          This is called to tell the MessageSource that it should stop sending messages.
 
Methods inherited from class atg.nucleus.logging.ApplicationLoggingImpl
addGlobalLogListeners, addLogListener, getLoggingForVlogging, getLoggingIdentifer, getLoggingIdentifier, getLogListenerCount, getLogListeners, initializeFromServiceEvent, isAutoInitListeners, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, removeLogListener, sendLogEvent, setAutoInitListeners, setLoggingDebug, setLoggingError, setLoggingIdentifier, setLoggingInfo, setLoggingTrace, setLoggingWarning
 
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
Class version string


SUCCESS

protected final int SUCCESS
See Also:
Constant Field Values

FAILURE

protected final int FAILURE
See Also:
Constant Field Values
Constructor Detail

EventSender

public EventSender()
An empty constructor.

Method Detail

setMessageIdGenerator

public void setMessageIdGenerator(IdGenerator pMessageIdGenerator)

getMessageIdGenerator

public IdGenerator getMessageIdGenerator()
The service that generates Ids for all messages.


setMessageIdSpaceName

public void setMessageIdSpaceName(java.lang.String pMessageIdSpaceName)

getMessageIdSpaceName

public java.lang.String getMessageIdSpaceName()
The name of the idspace to get our message ids from


getNextMessageId

public java.lang.String getNextMessageId()
Uses the id generator to get the next message id.


getRetCodes

public int[] getRetCodes()
Returns the valid return codes 1 - The processor executed successfully 2 - The processor failed to execute properly

Specified by:
getRetCodes in interface PipelineProcessor
Returns:
an integer array of the valid return codes.

createEventToSend

public java.io.Serializable createEventToSend(java.lang.Object pParam,
                                              PipelineResult pResult)
                                       throws java.lang.Exception
This method creates and returns the event to be sent by this processor. The default implementation returns null which is interpreted as a failed result by the runProcess call.

Throws:
java.lang.Exception

runProcess

public int runProcess(java.lang.Object pParam,
                      PipelineResult pResult)
               throws java.lang.Exception
This method will call @see #createEventToSend which will return the event object to be sent. @see #sendObjectMessage will be called with the event to be sent, along with the

Specified by:
runProcess in interface PipelineProcessor
Parameters:
pParam - a HashMap which must contains parameters which are added to the message
pResult - a PipelineResult object which stores any information which must be returned from this method invocation
Returns:
an integer specifying the processor's return code
Throws:
java.lang.Exception - throws any exception back to the caller
See Also:
and the @see #getPortName., PipelineProcessor.runProcess(Object, PipelineResult)

sendObjectMessage

public void sendObjectMessage(java.io.Serializable pObjectMessage,
                              java.lang.String pType,
                              java.lang.String pPortName)
                       throws javax.jms.JMSException
Sends an object message of type pType, out on port pPortName. Note, that it is critical that messages being sent are in a transaction.

Parameters:
pObjectMessage - the object to be placed in the object message.
pType - the type of the message being sent.
pPortName - the port on which this message is going to be sent.
Throws:
javax.jms.JMSException - is thrown when a failure to send the message occurs. This is generally a configuration issue.

setMessageSourceContext

public void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
Set the message source context for this source. @see atg.dms.patchbay.MessageSource

Specified by:
setMessageSourceContext in interface MessageSource

getMessageSourceContext

public MessageSourceContext getMessageSourceContext()
Return the message source context for this source.


setAllowMessageSending

public void setAllowMessageSending(boolean pAllowMessageSending)

isAllowMessageSending

public boolean isAllowMessageSending()
This class cannot send messages if this is false. Usually set during parsing of the configuration file.


startMessageSource

public void startMessageSource()
This is called to tell the MessageSource that it may begin sending messages.

Specified by:
startMessageSource in interface MessageSource

stopMessageSource

public void stopMessageSource()
This is called to tell the MessageSource that it should stop sending messages.

Specified by:
stopMessageSource in interface MessageSource

setEventType

public void setEventType(java.lang.String pEventType)

getEventType

public java.lang.String getEventType()
Deprecated. Subclasses of this (such as ProcSendScenarioEvent) may dynamically determine the type of event. meaning getEventType may not be thread safe (since the type is set in "createEventToSend" and and checked when calling "sendObjectMessage"). Use the getEventType method that takes an Object as a parameter instead.

The type of the event, this should be set to such things as: atg.commerce.order.Order if that is what is being sent.


getEventType

public java.lang.String getEventType(java.lang.Object pEventToSend)
This will return the event type defined on the class (same behavior as calling getEventType(). Subclass of this class should extend this method if they call setEventType during the call to createEventToSend. Instead of just returning the property it should inspect pEventToSend to see what the type is.

Parameters:
pEventToSend -
Returns:
The event type

setPortName

public void setPortName(java.lang.String pPortName)

getPortName

public java.lang.String getPortName()
The port on which this message is sent.


getSiteId

protected java.lang.String getSiteId(java.lang.Object pParams)
Retrieves site id from pipeline parameters

Parameters:
pParams - pipeline parameters
Returns:
site id retrieved from pipeline parameters