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:
EventListener, javax.resource.spi.work.WorkListener, Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable, NameableObject, NamedObject, Connectable, Connector
Direct Known Subclasses:
HttpConnector, PollingTcpConnector, 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 int DEFAULT_WAIT_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
createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, dispatcherFactory, dispatcherPoolFactory, dispatchers, initialStateStopped, lifecycleManager, logger, muleContext, muleMessageFactory, name, numberOfConcurrentTransactedReceivers, PROPERTY_POLLING_FREQUENCY, receivers, requesterFactory, requesters, serviceDescriptor, serviceOverrides, sessionHandler, startOnConnect
 
Fields inherited from interface org.mule.api.transport.Connector
INT_VALUE_NOT_SET
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
TcpConnector(MuleContext context)
           
 
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()
           
 int getConnectionTimeout()
           
 ConfigurableKeyedObjectPool getDispatchers()
           
 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 getSocketMaxWait()
           
 int getSocketSoLinger()
           
 int getSocketsPoolMaxActive()
           
 int getSocketsPoolMaxIdle()
           
 long getSocketsPoolMaxWait()
           
 int getSocketsPoolNumActive()
           
 TcpProtocol getTcpProtocol()
           
 Boolean isFailOnUnresolvedHost()
           
 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 setConnectionTimeout(int timeout)
           
 void setDispatcherFactory(MessageDispatcherFactory dispatcherFactory)
          The dispatcher factory is used to create a message dispatcher of the current request
 void setFailOnUnresolvedHost(Boolean failOnUnresolvedHost)
           
 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 setSocketMaxWait(int timeout)
           
 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
clearDispatchers, clearRequesters, configureDispatcherPool, connect, createDefaultRedeliveryPolicy, createDispatcherMessageProcessor, createMuleMessageFactory, createOperationResource, createReceiver, createScheduler, destroyReceiver, disconnect, dispose, disposeReceivers, disposeWorkManagers, doUnregisterListener, fireNotification, getConnectEventId, getConnectionDescription, getDefaultExchangePattern, getDefaultInboundTransformers, getDefaultOutboundTransformers, getDefaultResponseTransformers, getDispatcherFactory, getDispatcherPoolFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getInboundExchangePatterns, getLifecycleState, getMaxDispatchersActive, getMaxRequestersActive, getMaxTotalDispatchers, getMuleContext, getMuleMessageFactory, getName, getNumberOfConcurrentTransactedReceivers, getOperationResourceFactory, getOutboundExchangePatterns, getOutputStream, getReceiver, getReceiverKey, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getReplyToHandler, getRequesterFactory, getRequesterThreadingProfile, getRequesterWorkManager, getRetryPolicyTemplate, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getSupportedProtocols, getTransactionalResource, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, initWorkManagers, isConnected, isConnecting, isCreateMultipleTransactedReceivers, isDisposed, isEnableMessageEvents, isInitialised, isInitialStateStopped, isStarted, isStarting, isStopped, isStopping, isValidateConnections, lookupReceiver, registerListener, registerSupportedMetaProtocol, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, request, request, setConnected, setConnecting, setCreateMultipleTransactedReceivers, setDispatcherPoolFactory, setDispatcherPoolMaxWait, setDispatcherPoolWhenExhaustedAction, setDispatcherThreadingProfile, setDynamicNotification, setInitialStateStopped, setMaxDispatchersActive, setMaxRequestersActive, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setRequesterFactory, setRequesterPoolMaxWait, setRequesterPoolWhenExhaustedAction, setRequesterThreadingProfile, setRetryPolicyTemplate, setServiceOverrides, setSessionHandler, setSupportedProtocols, setupDispatchReturn, setupRequestReturn, setValidateConnections, shutdownScheduler, start, startAfterConnect, 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

DEFAULT_WAIT_TIMEOUT

public static final int DEFAULT_WAIT_TIMEOUT
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(MuleContext context)
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

@Deprecated
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)

getConnectionTimeout

public int getConnectionTimeout()

setConnectionTimeout

public void setConnectionTimeout(int timeout)

getServerSoTimeout

public int getServerSoTimeout()

setServerSoTimeout

public void setServerSoTimeout(int timeout)

getSocketMaxWait

public int getSocketMaxWait()

setSocketMaxWait

public void setSocketMaxWait(int timeout)

getBufferSize

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


setBufferSize

@Deprecated
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

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


setBacklog

@Deprecated
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)


setDispatcherFactory

public void setDispatcherFactory(MessageDispatcherFactory dispatcherFactory)
Description copied from interface: Connector
The dispatcher factory is used to create a message dispatcher of the current request

Specified by:
setDispatcherFactory in interface Connector
Overrides:
setDispatcherFactory in class AbstractConnector
Parameters:
dispatcherFactory - The dispatcherFactory to set.

getDispatchers

public ConfigurableKeyedObjectPool getDispatchers()

getSocketsPoolMaxActive

public int getSocketsPoolMaxActive()

getSocketsPoolMaxIdle

public int getSocketsPoolMaxIdle()

getSocketsPoolNumActive

public int getSocketsPoolNumActive()

getSocketsPoolMaxWait

public long getSocketsPoolMaxWait()

isFailOnUnresolvedHost

public Boolean isFailOnUnresolvedHost()

setFailOnUnresolvedHost

public void setFailOnUnresolvedHost(Boolean failOnUnresolvedHost)


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.