org.mule.providers.tcp
Class TcpConnector

java.lang.Object
  extended by org.mule.providers.AbstractConnector
      extended by org.mule.providers.tcp.TcpConnector
All Implemented Interfaces:
ExceptionListener, EventListener, javax.resource.spi.work.WorkListener, Disposable, Initialisable, UMOConnectable, UMOConnector
Direct Known Subclasses:
HttpConnector, SslConnector

public class TcpConnector
extends AbstractConnector

TcpConnector can bind or sent to a given TCP port on a given host. Other socket-based transports can be built on top of this class by providing the appropriate socket factories and application level protocols as required (see the constructor and the SSL transport for examples).


Field Summary
static int DEFAULT_BACKLOG
           
static int DEFAULT_BUFFER_SIZE
           
static int DEFAULT_SOCKET_TIMEOUT
           
static String KEEP_SEND_SOCKET_OPEN_PROPERTY
          Property can be set on the endpoint to configure how the socket is managed
 
Fields inherited from class org.mule.providers.AbstractConnector
connected, connecting, connectionStrategy, createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, defaultInboundTransformer, defaultOutboundTransformer, defaultResponseTransformer, dispatcherFactory, dispatchers, disposed, disposing, exceptionListener, initialised, logger, name, numberOfConcurrentTransactedReceivers, receivers, serviceDescriptor, serviceOverrides, sessionHandler, started, startOnConnect
 
Fields inherited from interface org.mule.umo.provider.UMOConnector
INT_VALUE_NOT_SET
 
Constructor Summary
TcpConnector()
           
 
Method Summary
protected  void doConnect()
          Template method where any connections should be made for the connector
protected  void doDisconnect()
          Template method where any connected resources used by the connector should be disconnected
protected  void doDispose()
          Template method to perform any work when destroying the connectoe
protected  void doInitialise()
           
protected  void doStart()
          Template method to perform any work when starting the connectoe
protected  void doStop()
          Template method to perform any work when stopping the connectoe
 int getBacklog()
          Deprecated. should use getReceiveBacklog()
 int getBufferSize()
          Deprecated. Should use getSendBufferSize() or getReceiveBufferSize()
 OutputStream getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message)
          Will get the output stream for this type of transport.
 String getProtocol()
           
 int getReceiveBacklog()
           
 int getReceiveBufferSize()
           
 int getReceiveTimeout()
           
 int getSendBufferSize()
           
 int getSendSocketLinger()
           
 int getSendTimeout()
           
protected  ServerSocket getServerSocket(URI uri)
           
 SimpleServerSocketFactory getServerSocketFactory()
           
protected  Socket getSocket(UMOImmutableEndpoint endpoint)
          Lookup a socket in the list of dispatcher sockets but don't create a new socket
protected  PooledSocketFactory getSocketFactory()
           
 TcpProtocol getTcpProtocol()
           
 String getTcpProtocolClassName()
           
 boolean isKeepAlive()
           
 boolean isKeepSendSocketOpen()
           
 boolean isRemoteSyncEnabled()
          
 Boolean isReuseAddress()
           
 boolean isSendTcpNoDelay()
           
 boolean isValidateConnections()
          Should the connection be checked before sending data?
 void setBacklog(int backlog)
          Deprecated. should use setReceiveBacklog(int)
 void setBufferSize(int bufferSize)
          Deprecated. Should use setSendBufferSize(int) or setReceiveBufferSize(int)
 void setKeepAlive(boolean keepAlive)
           
 void setKeepSendSocketOpen(boolean keepSendSocketOpen)
           
 void setReceiveBacklog(int receiveBacklog)
           
 void setReceiveBufferSize(int bufferSize)
           
 void setReceiveTimeout(int timeout)
           
 void setReuseAddress(Boolean reuseAddress)
          This allows closed sockets to be reused while they are still in TIME_WAIT state
 void setSendBufferSize(int bufferSize)
           
 void setSendSocketLinger(int soLinger)
           
 void setSendTcpNoDelay(boolean sendTcpNoDelay)
           
 void setSendTimeout(int timeout)
           
 void setServerSocketFactory(SimpleServerSocketFactory serverSocketFactory)
           
protected  void setSocketFactory(PooledSocketFactory socketFactory)
           
 void setTcpProtocol(TcpProtocol tcpProtocol)
           
 void setTcpProtocolClassName(String protocolClassName)
           
 void setTimeout(int timeout)
          Deprecated. The time out should be set explicitly for each
 void setValidateConnections(boolean validateConnections)
           
 
Methods inherited from class org.mule.providers.AbstractConnector
checkDisposed, connect, createReceiver, destroyReceiver, disconnect, dispatch, dispose, disposeDispatchers, disposeReceivers, disposeWorkManagers, exceptionThrown, fireNotification, getConnectEventId, getConnectionDescription, getConnectionStrategy, getDefaultInboundTransformer, getDefaultOutboundTransformer, getDefaultResponseTransformer, getDispatcherFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getExceptionListener, getMaxDispatchersActive, getMessageAdapter, getName, getNumberOfConcurrentTransactedReceivers, getReceiver, getReceiverKey, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getReplyToHandler, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getStreamMessageAdapter, getSupportedProtocols, handleException, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, isConnected, isCreateMultipleTransactedReceivers, isDisposed, isDisposing, isEnableMessageEvents, isStarted, lookupReceiver, receive, receive, registerListener, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, send, setConnectionStrategy, setCreateMultipleTransactedReceivers, setDefaultInboundTransformer, setDefaultOutboundTransformer, setDefaultResponseTransformer, setDispatcherFactory, setDispatcherThreadingProfile, setEnableMessageEvents, setExceptionListener, setMaxDispatchersActive, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setServiceOverrides, setSessionHandler, setSupportedProtocols, startConnector, stopConnector, supportsProtocol, toString, unregisterListener, unregisterSupportedProtocol, workAccepted, workCompleted, workRejected, workStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEEP_SEND_SOCKET_OPEN_PROPERTY

public static final String KEEP_SEND_SOCKET_OPEN_PROPERTY
Property can be set on the endpoint to configure how the socket is managed

See Also:
Constant Field Values

DEFAULT_SOCKET_TIMEOUT

public static final int DEFAULT_SOCKET_TIMEOUT
See Also:
Constant Field Values

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

DEFAULT_BACKLOG

public static final int DEFAULT_BACKLOG
See Also:
Constant Field Values
Constructor Detail

TcpConnector

public TcpConnector()
Method Detail

doInitialise

protected void doInitialise()
                     throws InitialisationException
Specified by:
doInitialise in class AbstractConnector
Throws:
InitialisationException

doDispose

protected void doDispose()
Description copied from class: AbstractConnector
Template method to perform any work when destroying the connectoe

Specified by:
doDispose in class AbstractConnector

getSocket

protected Socket getSocket(UMOImmutableEndpoint endpoint)
                    throws Exception
Lookup a socket in the list of dispatcher sockets but don't create a new socket

Throws:
Exception

getOutputStream

public OutputStream getOutputStream(UMOImmutableEndpoint endpoint,
                                    UMOMessage message)
                             throws UMOException
Description copied from class: AbstractConnector
Will get the output stream for this type of transport. Typically this will be called only when Streaming is being used on an outbound endpoint. If Streaming is not supported by this transport an UnsupportedOperationException is thrown. Note that the stream MUST release resources on close. For help doing so, see CallbackOutputStream.

Specified by:
getOutputStream in interface UMOConnector
Overrides:
getOutputStream in class AbstractConnector
Parameters:
endpoint - the endpoint that releates to this Dispatcher
message - the current message being processed
Returns:
the output stream to use for this request
Throws:
UMOException - in case of any error

doConnect

protected void doConnect()
                  throws Exception
Description copied from class: AbstractConnector
Template method where any connections should be made for the connector

Specified by:
doConnect in class AbstractConnector
Throws:
Exception

doDisconnect

protected void doDisconnect()
                     throws Exception
Description copied from class: AbstractConnector
Template method where any connected resources used by the connector should be disconnected

Specified by:
doDisconnect in class AbstractConnector
Throws:
Exception

doStart

protected void doStart()
                throws UMOException
Description copied from class: AbstractConnector
Template method to perform any work when starting the connectoe

Specified by:
doStart in class AbstractConnector
Throws:
UMOException - if the method fails

doStop

protected void doStop()
               throws UMOException
Description copied from class: AbstractConnector
Template method to perform any work when stopping the connectoe

Specified by:
doStop in class AbstractConnector
Throws:
UMOException - if the method fails

getProtocol

public String getProtocol()
Returns:
the primary protocol name for endpoints of this connector

isKeepSendSocketOpen

public boolean isKeepSendSocketOpen()

setKeepSendSocketOpen

public void setKeepSendSocketOpen(boolean keepSendSocketOpen)

setTimeout

public void setTimeout(int timeout)
Deprecated. The time out should be set explicitly for each

A shorthand property setting timeout for both SEND and RECEIVE sockets.


getSendTimeout

public int getSendTimeout()

setSendTimeout

public void setSendTimeout(int timeout)

getReceiveTimeout

public int getReceiveTimeout()

setReceiveTimeout

public void setReceiveTimeout(int timeout)

getBufferSize

public int getBufferSize()
Deprecated. Should use getSendBufferSize() or getReceiveBufferSize()


setBufferSize

public void setBufferSize(int bufferSize)
Deprecated. Should use setSendBufferSize(int) or setReceiveBufferSize(int)


getSendBufferSize

public int getSendBufferSize()

setSendBufferSize

public void setSendBufferSize(int bufferSize)

getReceiveBufferSize

public int getReceiveBufferSize()

setReceiveBufferSize

public void setReceiveBufferSize(int bufferSize)

getReceiveBacklog

public int getReceiveBacklog()

setReceiveBacklog

public void setReceiveBacklog(int receiveBacklog)

getSendSocketLinger

public int getSendSocketLinger()

setSendSocketLinger

public void setSendSocketLinger(int soLinger)

getBacklog

public int getBacklog()
Deprecated. should use getReceiveBacklog()

Returns:

setBacklog

public void setBacklog(int backlog)
Deprecated. should use setReceiveBacklog(int)

Parameters:
backlog -

getTcpProtocol

public TcpProtocol getTcpProtocol()

setTcpProtocol

public void setTcpProtocol(TcpProtocol tcpProtocol)

getTcpProtocolClassName

public String getTcpProtocolClassName()

setTcpProtocolClassName

public void setTcpProtocolClassName(String protocolClassName)

isRemoteSyncEnabled

public boolean isRemoteSyncEnabled()
Description copied from class: AbstractConnector

Specified by:
isRemoteSyncEnabled in interface UMOConnector
Overrides:
isRemoteSyncEnabled in class AbstractConnector

isKeepAlive

public boolean isKeepAlive()

setKeepAlive

public void setKeepAlive(boolean keepAlive)

isSendTcpNoDelay

public boolean isSendTcpNoDelay()

setSendTcpNoDelay

public void setSendTcpNoDelay(boolean sendTcpNoDelay)

setSocketFactory

protected void setSocketFactory(PooledSocketFactory socketFactory)

getSocketFactory

protected PooledSocketFactory getSocketFactory()

getServerSocketFactory

public SimpleServerSocketFactory getServerSocketFactory()

setServerSocketFactory

public void setServerSocketFactory(SimpleServerSocketFactory serverSocketFactory)

getServerSocket

protected ServerSocket getServerSocket(URI uri)
                                throws IOException
Throws:
IOException

isValidateConnections

public boolean isValidateConnections()
Should the connection be checked before sending data?

Returns:
If true, the message adapter opens and closes the socket on intialisation.

setValidateConnections

public void setValidateConnections(boolean validateConnections)
Parameters:
validateConnections - If true, the message adapter opens and closes the socket on intialisation.
See Also:
isValidateConnections()

isReuseAddress

public Boolean isReuseAddress()
Returns:
true if the server socket sets SO_REUSEADDRESS before opening

setReuseAddress

public void setReuseAddress(Boolean reuseAddress)
This allows closed sockets to be reused while they are still in TIME_WAIT state

Parameters:
reuseAddress - Whether the server socket sets SO_REUSEADDRESS before opening


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