org.mule.transport.tcp
Class TcpConnector

java.lang.Object
  extended by org.mule.transport.AbstractConnector
      extended by org.mule.transport.tcp.TcpConnector
All Implemented Interfaces:
ExceptionListener, EventListener, javax.resource.spi.work.WorkListener, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, NamedObject, Connectable, Connector
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 boolean CLIENT
           
static int DEFAULT_BACKLOG
           
static int DEFAULT_BUFFER_SIZE
           
static int DEFAULT_SO_LINGER
           
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
static boolean SERVER
           
static String TCP
           
 
Fields inherited from class org.mule.transport.AbstractConnector
connected, createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, dispatcherFactory, dispatchers, disposed, exceptionListener, initialised, logger, muleContext, name, numberOfConcurrentTransactedReceivers, receivers, requesterFactory, requesters, serviceDescriptor, serviceOverrides, sessionHandler, started, startOnConnect
 
Fields inherited from interface org.mule.api.transport.Connector
INT_VALUE_NOT_SET
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
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.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
TcpConnector()
           
 
Method Summary
 void configureSocket(boolean client, Socket socket)
           
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()
 int getClientSoTimeout()
           
 ExpiryMonitor getKeepAliveMonitor()
           
 int getKeepAliveTimeout()
           
 OutputStream getOutputStream(ImmutableEndpoint endpoint, MuleMessage message)
           
 String getProtocol()
           
 int getReceiveBacklog()
           
 int getReceiveBufferSize()
           
 int getSendBufferSize()
           
protected  ServerSocket getServerSocket(URI uri)
           
 SimpleServerSocketFactory getServerSocketFactory()
           
 int getServerSoTimeout()
           
protected  Socket getSocket(ImmutableEndpoint endpoint)
          Lookup a socket in the list of dispatcher sockets but don't create a new socket
protected  AbstractTcpSocketFactory getSocketFactory()
           
 int getSocketSoLinger()
           
 TcpProtocol getTcpProtocol()
           
 boolean isKeepAlive()
           
 boolean isKeepSendSocketOpen()
           
 boolean isResponseEnabled()
           
 Boolean isReuseAddress()
           
 boolean isSendTcpNoDelay()
           
 void setBacklog(int backlog)
          Deprecated. should use setReceiveBacklog(int)
 void setBufferSize(int bufferSize)
          Deprecated. Should use setSendBufferSize(int) or setReceiveBufferSize(int)
 void setClientSoTimeout(int timeout)
           
 void setKeepAlive(boolean keepAlive)
           
 void setKeepAliveTimeout(int keepAliveTimeout)
          Sets the keep alive timeout (in Milliseconds)
 void setKeepSendSocketOpen(boolean keepSendSocketOpen)
           
 void setReceiveBacklog(int receiveBacklog)
           
 void setReceiveBufferSize(int bufferSize)
           
 void setReuseAddress(Boolean reuseAddress)
          This allows closed sockets to be reused while they are still in TIME_WAIT state
 void setSendBufferSize(int bufferSize)
           
 void setSendTcpNoDelay(boolean sendTcpNoDelay)
           
 void setServerSocketFactory(SimpleServerSocketFactory serverSocketFactory)
           
 void setServerSoTimeout(int timeout)
           
protected  void setSocketFactory(AbstractTcpSocketFactory socketFactory)
           
 void setSocketSoLinger(int soLinger)
           
 void setTcpProtocol(TcpProtocol tcpProtocol)
           
 void setTimeout(int timeout)
          Deprecated. The time out should be set explicitly for each
 
Methods inherited from class org.mule.transport.AbstractConnector
checkDisposed, connect, createReceiver, destroyReceiver, disconnect, dispatch, dispose, disposeDispatchers, disposeReceivers, disposeRequesters, disposeWorkManagers, exceptionThrown, fireNotification, getConnectEventId, getConnectionDescription, getDefaultInboundTransformers, getDefaultOutboundTransformers, getDefaultResponseTransformers, getDispatcherFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getExceptionListener, getMaxDispatchersActive, getMaxRequestersActive, getMessageAdapter, getMuleContext, getName, getNumberOfConcurrentTransactedReceivers, getOutputStream, getReceiver, getReceiverKey, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getReplyToHandler, getRequesterFactory, getRequesterThreadingProfile, getRequesterWorkManager, getRetryPolicyTemplate, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getSupportedProtocols, handleException, handleException, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, initWorkManagers, isConnected, isCreateMultipleTransactedReceivers, isDisposed, isEnableMessageEvents, isStarted, isSyncEnabled, isValidateConnections, lookupReceiver, registerListener, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, request, request, send, setConnected, setCreateMultipleTransactedReceivers, setDispatcherFactory, setDispatcherThreadingProfile, setDynamicNotification, setExceptionListener, setMaxDispatchersActive, setMaxRequestersActive, setMuleContext, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setRequesterFactory, setRequesterThreadingProfile, setRetryPolicyTemplate, setServiceOverrides, setSessionHandler, setSupportedProtocols, setupDispatchReturn, setupRequestReturn, setValidateConnections, start, stop, supportsProtocol, toString, unregisterListener, unregisterSupportedProtocol, updateCachedNotificationHandler, validateConnection, workAccepted, workCompleted, workRejected, workStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TCP

public static final String TCP
See Also:
Constant Field Values

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_SO_LINGER

public static final int DEFAULT_SO_LINGER
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

SERVER

public static final boolean SERVER
See Also:
Constant Field Values

CLIENT

public static final boolean CLIENT
See Also:
Constant Field Values
Constructor Detail

TcpConnector

public TcpConnector()
Method Detail

configureSocket

public void configureSocket(boolean client,
                            Socket socket)
                     throws SocketException
Throws:
SocketException

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(ImmutableEndpoint 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(ImmutableEndpoint endpoint,
                                    MuleMessage message)
                             throws MuleException
Throws:
MuleException

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 MuleException
Description copied from class: AbstractConnector
Template method to perform any work when starting the connectoe

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

doStop

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

Specified by:
doStop in class AbstractConnector
Throws:
MuleException - 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.


getClientSoTimeout

public int getClientSoTimeout()

setClientSoTimeout

public void setClientSoTimeout(int timeout)

getServerSoTimeout

public int getServerSoTimeout()

setServerSoTimeout

public void setServerSoTimeout(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)

getSocketSoLinger

public int getSocketSoLinger()

setSocketSoLinger

public void setSocketSoLinger(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)

isResponseEnabled

public boolean isResponseEnabled()
Specified by:
isResponseEnabled in interface Connector
Overrides:
isResponseEnabled 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(AbstractTcpSocketFactory socketFactory)

getSocketFactory

protected AbstractTcpSocketFactory getSocketFactory()

getServerSocketFactory

public SimpleServerSocketFactory getServerSocketFactory()

setServerSocketFactory

public void setServerSocketFactory(SimpleServerSocketFactory serverSocketFactory)

getServerSocket

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

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

getKeepAliveMonitor

public ExpiryMonitor getKeepAliveMonitor()

getKeepAliveTimeout

public int getKeepAliveTimeout()
Returns:
keep alive timeout in Milliseconds

setKeepAliveTimeout

public void setKeepAliveTimeout(int keepAliveTimeout)
Sets the keep alive timeout (in Milliseconds)



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