org.mule.transport
Class AbstractMessageDispatcher

java.lang.Object
  extended by org.mule.transport.AbstractConnectable
      extended by org.mule.transport.AbstractMessageDispatcher
All Implemented Interfaces:
ExceptionListener, Disposable, Initialisable, Startable, Stoppable, Connectable, MessageDispatcher, MessageDispatching
Direct Known Subclasses:
AxisMessageDispatcher, CxfMessageDispatcher, FileMessageDispatcher, FtpMessageDispatcher, HttpClientMessageDispatcher, JdbcMessageDispatcher, JmsMessageDispatcher, ProcessMessageDispatcher, QuartzMessageDispatcher, RmiMessageDispatcher, SmtpMessageDispatcher, StdioMessageDispatcher, TcpMessageDispatcher, UdpMessageDispatcher, UnsupportedMessageDispatcher, VMMessageDispatcher, XmppMessageDispatcher

public abstract class AbstractMessageDispatcher
extends AbstractConnectable
implements MessageDispatcher

Provide a default dispatch (client) support for handling threads lifecycle and validation.


Field Summary
 
Fields inherited from class org.mule.transport.AbstractConnectable
connected, connector, disposed, endpoint, logger, retryTemplate, started, startOnConnect
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.transport.MessageDispatching
RECEIVE_NO_WAIT, RECEIVE_WAIT_INDEFINITELY
 
Constructor Summary
AbstractMessageDispatcher(OutboundEndpoint endpoint)
           
 
Method Summary
 void dispatch(MuleEvent event)
          Dispatches an event from the endpoint to the external system
 void dispose()
          Template method to destroy any resources held by the Message Dispatcher
protected abstract  void doDispatch(MuleEvent event)
           
protected abstract  MuleMessage doSend(MuleEvent event)
           
 OutboundEndpoint getEndpoint()
           
protected  WorkManager getWorkManager()
           
 void initialise()
          Method used to perform any initialisation work.
protected  boolean isTransactionRollback()
          Checks to see if the current transaction has been rolled back
protected  boolean returnResponse(MuleEvent event)
          RemoteSync causes the message dispatch to wait for a response to an event on a response channel after it sends the event.
 MuleMessage send(MuleEvent event)
          Sends an event from the endpoint to the external system
 
Methods inherited from class org.mule.transport.AbstractConnectable
activate, connect, disconnect, disposeAndLogException, doConnect, doDisconnect, doDispose, doInitialise, doStart, doStop, exceptionThrown, getConnectEventId, getConnectionDescription, getConnector, handleException, isConnected, isDoThreading, isStarted, passivate, setEndpoint, start, stop, toString, validate, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transport.MessageDispatcher
activate, getConnector, passivate, validate
 
Methods inherited from interface org.mule.api.transport.Connectable
connect, disconnect, getConnectionDescription, isConnected, validateConnection
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 

Constructor Detail

AbstractMessageDispatcher

public AbstractMessageDispatcher(OutboundEndpoint endpoint)
Method Detail

initialise

public final void initialise()
                      throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractConnectable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

dispose

public final void dispose()
Description copied from class: AbstractConnectable
Template method to destroy any resources held by the Message Dispatcher

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractConnectable

dispatch

public final void dispatch(MuleEvent event)
                    throws DispatchException
Description copied from interface: MessageDispatching
Dispatches an event from the endpoint to the external system

Specified by:
dispatch in interface MessageDispatching
Parameters:
event - The event to dispatch
Throws:
DispatchException - if the event fails to be dispatched

send

public final MuleMessage send(MuleEvent event)
                       throws DispatchException
Description copied from interface: MessageDispatching
Sends an event from the endpoint to the external system

Specified by:
send in interface MessageDispatching
Parameters:
event - The event to send
Returns:
event the response form the external system wrapped in a MuleEvent
Throws:
DispatchException - if the event fails to be dispatched

returnResponse

protected boolean returnResponse(MuleEvent event)
RemoteSync causes the message dispatch to wait for a response to an event on a response channel after it sends the event. The following rules apply to RemoteSync:
  1. The connector has to support remoteSync. Some transports do not have the notion of a response channel.
  2. Check if the endpoint has been configured for remoteSync.
  3. Check if the REMOTE_SYNC message header has been set.
  4. Finally, if the current service has a response router configured, that the router will handle the response channel event and we should not try and receive a response in the Message dispatcher If remotesync should not be used we must remove the REMOTE_SYNC header Note the MuleClient will automatically set the REMOTE_SYNC header when client.send(..) is called so that results are returned from remote invocations too.

Parameters:
event - the current event
Returns:
true if a response channel should be used to get a resposne from the event dispatch.

isTransactionRollback

protected boolean isTransactionRollback()
Checks to see if the current transaction has been rolled back

Returns:

getWorkManager

protected WorkManager getWorkManager()
Specified by:
getWorkManager in class AbstractConnectable

getEndpoint

public OutboundEndpoint getEndpoint()
Specified by:
getEndpoint in interface MessageDispatcher
Overrides:
getEndpoint in class AbstractConnectable
Returns:
the endpoint which we are dispatching events to

doDispatch

protected abstract void doDispatch(MuleEvent event)
                            throws Exception
Throws:
Exception

doSend

protected abstract MuleMessage doSend(MuleEvent event)
                               throws Exception
Throws:
Exception


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.