org.mule.providers
Class AbstractMessageDispatcher

java.lang.Object
  extended byorg.mule.providers.AbstractMessageDispatcher
All Implemented Interfaces:
Disposable, ExceptionListener, UMOConnectable, UMOMessageDispatcher
Direct Known Subclasses:
AxisMessageDispatcher, DQMessageDispatcher, FileMessageDispatcher, FtpMessageDispatcher, GlueMessageDispatcher, HttpClientMessageDispatcher, JbiMessageDispatcher, JdbcMessageDispatcher, JmsMessageDispatcher, Pop3MessageDispatcher, QuartzMessageDispatcher, RmiMessageDispatcher, SmtpMessageDispatcher, SpaceMessageDispatcher, StreamMessageDispatcher, TcpMessageDispatcher, TestMessageDispatcher, UdpMessageDispatcher, VMMessageDispatcher, XFireMessageDispatcher, XmppMessageDispatcher

public abstract class AbstractMessageDispatcher
extends Object
implements UMOMessageDispatcher, ExceptionListener

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


Field Summary
protected  WaitableBoolean connected
           
protected  ConnectionStrategy connectionStrategy
           
protected  AbstractConnector connector
           
protected  boolean disposed
           
protected  boolean doThreading
           
protected  UMOImmutableEndpoint endpoint
           
protected  Log logger
          logger used by this class
protected  UMOWorkManager workManager
          Thread pool of Connector sessions
 
Fields inherited from interface org.mule.umo.provider.UMOMessageDispatcher
RECEIVE_NO_WAIT, RECEIVE_WAIT_INDEFINITELY
 
Constructor Summary
AbstractMessageDispatcher(UMOImmutableEndpoint endpoint)
           
 
Method Summary
 void connect()
          Make the connection to the underlying transport.
 void disconnect()
          Disconnect the from the underlying transport
 void dispatch(UMOEvent 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 doConnect(UMOImmutableEndpoint endpoint)
           
protected abstract  void doDisconnect()
           
protected abstract  void doDispatch(UMOEvent event)
           
protected abstract  void doDispose()
           
protected abstract  UMOMessage doReceive(UMOImmutableEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
protected abstract  UMOMessage doSend(UMOEvent event)
           
 void exceptionThrown(Exception e)
           
protected  String getConnectEventId(UMOImmutableEndpoint endpoint)
           
 String getConnectionDescription()
          Returns a string identifying the underlying resource
 UMOConnector getConnector()
          Gets the connector for this dispatcher
 OutputStream getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message)
          Well get the output stream (if any) for this type of transport.
 boolean isConnected()
          Determines if this object is connected or not
 boolean isDisposed()
          Determines if this dispatcher has been disposed.
protected  boolean isTransactionRollback()
          Checks to see if the current transaction has been rolled back
 UMOMessage receive(UMOEndpointURI endpointUri, long timeout)
          Make a specific request to the underlying transport
 UMOMessage receive(UMOImmutableEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
 void reconnect()
           
 UMOMessage send(UMOEvent event)
          Sends an event from the endpoint to the external system
protected  boolean useRemoteSync(UMOEvent event)
          RemoteSync causes the message dispatch to wait for a response to an event on a response channel after it sends the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOMessageDispatcher
getDelegateSession
 

Field Detail

logger

protected transient Log logger
logger used by this class


workManager

protected UMOWorkManager workManager
Thread pool of Connector sessions


endpoint

protected final UMOImmutableEndpoint endpoint

connector

protected final AbstractConnector connector

disposed

protected boolean disposed

doThreading

protected boolean doThreading

connectionStrategy

protected ConnectionStrategy connectionStrategy

connected

protected final WaitableBoolean connected
Constructor Detail

AbstractMessageDispatcher

public AbstractMessageDispatcher(UMOImmutableEndpoint endpoint)
Method Detail

dispatch

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

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

send

public final UMOMessage send(UMOEvent event)
                      throws DispatchException
Description copied from interface: UMOMessageDispatcher
Sends an event from the endpoint to the external system

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

receive

public final UMOMessage receive(UMOEndpointURI endpointUri,
                                long timeout)
                         throws Exception
Make a specific request to the underlying transport

Specified by:
receive in interface UMOMessageDispatcher
Parameters:
endpointUri - the endpoint URI to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception //@deprecated Use receive(UMOImmutableEndpoint endpoint, long timeout)

receive

public final UMOMessage receive(UMOImmutableEndpoint endpoint,
                                long timeout)
                         throws Exception
Make a specific request to the underlying transport

Specified by:
receive in interface UMOMessageDispatcher
Parameters:
endpoint - the endpoint to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

exceptionThrown

public void exceptionThrown(Exception e)
Specified by:
exceptionThrown in interface ExceptionListener

isDisposed

public final boolean isDisposed()
Description copied from interface: UMOMessageDispatcher
Determines if this dispatcher has been disposed. Once disposed a dispatcher cannot be used again

Specified by:
isDisposed in interface UMOMessageDispatcher
Returns:
true if this dispatcher has been disposed, false otherwise

dispose

public final void dispose()
Template method to destroy any resources held by the Message Dispatcher

Specified by:
dispose in interface Disposable

getConnector

public UMOConnector getConnector()
Description copied from interface: UMOMessageDispatcher
Gets the connector for this dispatcher

Specified by:
getConnector in interface UMOMessageDispatcher
Returns:
the connector for this dispatcher

useRemoteSync

protected boolean useRemoteSync(UMOEvent 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 component 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.

getOutputStream

public OutputStream getOutputStream(UMOImmutableEndpoint endpoint,
                                    UMOMessage message)
                             throws UMOException
Well get the output stream (if any) for this type of transport. Typically this will be called only when Streaming is being used on an outbound endpoint

Specified by:
getOutputStream in interface UMOMessageDispatcher
Parameters:
endpoint - the endpoint that releates to this Dispatcher
message - the current message being processed
Returns:
the output stream to use for this request or null if the transport does not support streaming
Throws:
UMOException

connect

public void connect()
             throws Exception
Description copied from interface: UMOConnectable
Make the connection to the underlying transport. The fact that this object is connected or not should have no influence on the lifecycle, especially the start / stop state if applicable.

Specified by:
connect in interface UMOConnectable
Throws:
Exception

disconnect

public void disconnect()
                throws Exception
Description copied from interface: UMOConnectable
Disconnect the from the underlying transport

Specified by:
disconnect in interface UMOConnectable
Throws:
Exception

getConnectEventId

protected String getConnectEventId(UMOImmutableEndpoint endpoint)

isConnected

public final boolean isConnected()
Description copied from interface: UMOConnectable
Determines if this object is connected or not

Specified by:
isConnected in interface UMOConnectable
Returns:

getConnectionDescription

public String getConnectionDescription()
Returns a string identifying the underlying resource

Specified by:
getConnectionDescription in interface UMOConnectable
Returns:

reconnect

public void reconnect()
               throws Exception
Throws:
Exception

doDispose

protected abstract void doDispose()

doDispatch

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

doSend

protected abstract UMOMessage doSend(UMOEvent event)
                              throws Exception
Throws:
Exception

doConnect

protected abstract void doConnect(UMOImmutableEndpoint endpoint)
                           throws Exception
Throws:
Exception

doDisconnect

protected abstract void doDisconnect()
                              throws Exception
Throws:
Exception

doReceive

protected abstract UMOMessage doReceive(UMOImmutableEndpoint endpoint,
                                        long timeout)
                                 throws Exception
Make a specific request to the underlying transport

Parameters:
endpoint - the endpoint to use when connecting to the resource
timeout - the maximum time the operation should block before returning. The call should return immediately if there is data available. If no data becomes available before the timeout elapses, null will be returned
Returns:
the result of the request wrapped in a UMOMessage object. Null will be returned if no data was avaialable
Throws:
Exception - if the call to the underlying protocal cuases an exception

isTransactionRollback

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

Returns:


Copyright © 2003-2006 MuleSource Inc.. All Rights Reserved.