org.mule.providers.tcp
Class TcpMessageDispatcher

java.lang.Object
  extended byorg.mule.providers.AbstractMessageDispatcher
      extended byorg.mule.providers.tcp.TcpMessageDispatcher
All Implemented Interfaces:
Disposable, ExceptionListener, UMOConnectable, UMOMessageDispatcher
Direct Known Subclasses:
SslMessageDispatcher

public class TcpMessageDispatcher
extends AbstractMessageDispatcher

TcpMessageDispatcher will send transformed Mule events over TCP.


Field Summary
protected  Socket connectedSocket
           
protected  boolean keepSendSocketOpen
           
protected  SerializableToByteArray serializableToByteArray
           
 
Fields inherited from class org.mule.providers.AbstractMessageDispatcher
connected, connectionStrategy, disposed, doThreading, endpoint, logger, workManager
 
Fields inherited from interface org.mule.umo.provider.UMOMessageDispatcher
RECEIVE_NO_WAIT, RECEIVE_WAIT_INDEFINITELY
 
Constructor Summary
TcpMessageDispatcher(UMOImmutableEndpoint endpoint)
           
 
Method Summary
protected  Socket createSocket(int port, InetAddress inetAddress)
           
protected  void doConnect(UMOImmutableEndpoint endpoint)
           
protected  void doDisconnect()
           
protected  void doDispatch(UMOEvent event)
           
protected  void doDispose()
           
protected  void doInternalDispatch(UMOEvent event)
          The doSend() and doDispatch() methods need to handle socket disposure differently, thus the need to extract this common code.
protected  UMOMessage doReceive(UMOImmutableEndpoint endpoint, long timeout)
          Make a specific request to the underlying transport
protected  UMOMessage doSend(UMOEvent event)
           
 UMOConnector getConnector()
          Gets the connector for this dispatcher
 Object getDelegateSession()
          If the underlying transport has the notion of a client session when writing to it, the session should be obtainable using this method.
 OutputStream getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message)
          Well get the output stream (if any) for this type of transport.
protected  Socket initSocket(String endpoint)
           
protected  byte[] receive(Socket socket, int timeout)
           
protected  void write(Socket socket, Object data)
           
 
Methods inherited from class org.mule.providers.AbstractMessageDispatcher
connect, disconnect, dispatch, dispose, exceptionThrown, getConnectEventId, getConnectionDescription, isConnected, isDisposed, isTransactionRollback, receive, receive, reconnect, send, useRemoteSync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serializableToByteArray

protected final SerializableToByteArray serializableToByteArray

connectedSocket

protected Socket connectedSocket

keepSendSocketOpen

protected boolean keepSendSocketOpen
Constructor Detail

TcpMessageDispatcher

public TcpMessageDispatcher(UMOImmutableEndpoint endpoint)
Method Detail

initSocket

protected Socket initSocket(String endpoint)
                     throws IOException,
                            URISyntaxException
Throws:
IOException
URISyntaxException

doDispatch

protected void doDispatch(UMOEvent event)
                   throws Exception
Specified by:
doDispatch in class AbstractMessageDispatcher
Throws:
Exception

doSend

protected UMOMessage doSend(UMOEvent event)
                     throws Exception
Specified by:
doSend in class AbstractMessageDispatcher
Throws:
Exception

doInternalDispatch

protected void doInternalDispatch(UMOEvent event)
                           throws Exception
The doSend() and doDispatch() methods need to handle socket disposure differently, thus the need to extract this common code.

Parameters:
event - event
Throws:
Exception - in case of any error

createSocket

protected Socket createSocket(int port,
                              InetAddress inetAddress)
                       throws IOException
Throws:
IOException

write

protected void write(Socket socket,
                     Object data)
              throws IOException,
                     TransformerException
Throws:
IOException
TransformerException

receive

protected byte[] receive(Socket socket,
                         int timeout)
                  throws IOException
Throws:
IOException

doReceive

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

Specified by:
doReceive in class AbstractMessageDispatcher
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

getDelegateSession

public Object getDelegateSession()
                          throws UMOException
Description copied from interface: UMOMessageDispatcher
If the underlying transport has the notion of a client session when writing to it, the session should be obtainable using this method. If there is no session a null will be returned

Returns:
the transport specific session or null if there is no session
Throws:
UMOException

getConnector

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

Specified by:
getConnector in interface UMOMessageDispatcher
Overrides:
getConnector in class AbstractMessageDispatcher

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
Overrides:
getOutputStream in class AbstractMessageDispatcher
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

doDispose

protected void doDispose()
Specified by:
doDispose in class AbstractMessageDispatcher

doConnect

protected void doConnect(UMOImmutableEndpoint endpoint)
                  throws Exception
Specified by:
doConnect in class AbstractMessageDispatcher
Throws:
Exception

doDisconnect

protected void doDisconnect()
                     throws Exception
Specified by:
doDisconnect in class AbstractMessageDispatcher
Throws:
Exception


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