org.springframework.integration.handler
Class AbstractMessageHandler

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, Orderable, MessageHandler, TrackableComponent
Direct Known Subclasses:
AbstractInternetProtocolSendingMessageHandler, AbstractMessageRouter, AbstractReplyProducingMessageHandler, AbstractXmppConnectionAwareMessageHandler, ApplicationEventPublishingMessageHandler, ByteStreamWritingMessageHandler, CharacterStreamWritingMessageHandler, CorrelatingMessageBarrier, CorrelatingMessageHandler, DirectMessageSendingMessageHandler, FileTransferringMessageHandler, JdbcMessageHandler, JmsSendingMessageHandler, LoggingHandler, MailSendingMessageHandler, MessageHandlerChain, MethodInvokingMessageHandler, NotificationPublishingMessageHandler, StatusUpdatingMessageHandler, TcpSendingMessageHandler

public abstract class AbstractMessageHandler
extends IntegrationObjectSupport
implements MessageHandler, TrackableComponent, Orderable

Base class for MessageHandler implementations that provides basic validation and error handling capabilities. Asserts that the incoming Message is not null and that it does not contain a null payload. Converts checked exceptions into runtime MessagingExceptions.


Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractMessageHandler()
           
 
Method Summary
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
 int getOrder()
           
 void handleMessage(Message<?> message)
          Handles the message if possible.
protected abstract  void handleMessageInternal(Message<?> message)
           
 void setOrder(int order)
          Set the order for this component.
 void setShouldTrack(boolean shouldTrack)
           
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

AbstractMessageHandler

public AbstractMessageHandler()
Method Detail

setOrder

public void setOrder(int order)
Description copied from interface: Orderable
Set the order for this component.

Specified by:
setOrder in interface Orderable

getOrder

public int getOrder()
Specified by:
getOrder in interface Ordered

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class IntegrationObjectSupport

setShouldTrack

public void setShouldTrack(boolean shouldTrack)
Specified by:
setShouldTrack in interface TrackableComponent

handleMessage

public final void handleMessage(Message<?> message)
Description copied from interface: MessageHandler
Handles the message if possible. If the handler cannot deal with the message this will result in a MessageRejectedException e.g. in case of a Selective Consumer. When a consumer tries to handle a message, but fails to do so, a MessageHandlingException is thrown. In the last case it is recommended to treat the message as tainted and go into an error scenario.

When the handling results in a failure of another message being sent (e.g. a "reply" message), that failure will trigger a MessageDeliveryException.

Specified by:
handleMessage in interface MessageHandler
Parameters:
message - the message to be handled

handleMessageInternal

protected abstract void handleMessageInternal(Message<?> message)
                                       throws java.lang.Exception
Throws:
java.lang.Exception