org.fusesource.hawtdispatch.transport
Class TcpTransportServer

java.lang.Object
  extended by org.fusesource.hawtdispatch.transport.TcpTransportServer
All Implemented Interfaces:
TransportServer
Direct Known Subclasses:
SslTransportServer

public class TcpTransportServer
extends Object
implements TransportServer

A TCP based implementation of TransportServer

Author:
Hiram Chirino

Field Summary
protected  DispatchSource acceptSource
           
protected  int backlog
           
protected  InetSocketAddress bindAddress
           
protected  String bindScheme
           
protected  Executor blockingExecutor
           
protected  ServerSocketChannel channel
           
protected  DispatchQueue dispatchQueue
           
protected  TransportServerListener listener
           
protected  int receiveBufferSize
           
protected  int sendBufferSize
           
 
Constructor Summary
TcpTransportServer(URI location)
           
 
Method Summary
protected  TcpTransport createTransport()
           
 int getBacklog()
           
 Executor getBlockingExecutor()
           
 String getBoundAddress()
           
 DispatchQueue getDispatchQueue()
          Returns the dispatch queue used by the transport
 int getReceiveBufferSize()
           
 int getSendBufferSize()
           
 InetSocketAddress getSocketAddress()
           
protected  void handleSocket(SocketChannel socket)
           
 void resume()
          resume accepting new transports
 void setBacklog(int backlog)
           
 void setBlockingExecutor(Executor blockingExecutor)
           
 void setDispatchQueue(DispatchQueue dispatchQueue)
          Sets the dispatch queue used by the transport
 void setReceiveBufferSize(int receiveBufferSize)
           
 void setSendBufferSize(int sendBufferSize)
           
 void setTransportServerListener(TransportServerListener listener)
          Registers an TransportAcceptListener which is notified of accepted channels.
 void start(Runnable onCompleted)
          Deprecated. 
 void start(Task onCompleted)
          Starts the service.
 void stop(Runnable onCompleted)
          Deprecated. 
 void stop(Task onCompleted)
          Stops the service.
 void suspend()
          suspend accepting new transports
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bindScheme

protected final String bindScheme

bindAddress

protected final InetSocketAddress bindAddress

backlog

protected int backlog

channel

protected ServerSocketChannel channel

listener

protected TransportServerListener listener

dispatchQueue

protected DispatchQueue dispatchQueue

acceptSource

protected DispatchSource acceptSource

receiveBufferSize

protected int receiveBufferSize

sendBufferSize

protected int sendBufferSize

blockingExecutor

protected Executor blockingExecutor
Constructor Detail

TcpTransportServer

public TcpTransportServer(URI location)
                   throws UnknownHostException
Throws:
UnknownHostException
Method Detail

setTransportServerListener

public void setTransportServerListener(TransportServerListener listener)
Description copied from interface: TransportServer
Registers an TransportAcceptListener which is notified of accepted channels.

Specified by:
setTransportServerListener in interface TransportServer

getSocketAddress

public InetSocketAddress getSocketAddress()
Specified by:
getSocketAddress in interface TransportServer
Returns:
The socket address that this transport is accepting connections on or null if this does not or is not currently accepting connections on a socket.

getDispatchQueue

public DispatchQueue getDispatchQueue()
Description copied from interface: TransportServer
Returns the dispatch queue used by the transport

Specified by:
getDispatchQueue in interface TransportServer
Returns:

setDispatchQueue

public void setDispatchQueue(DispatchQueue dispatchQueue)
Description copied from interface: TransportServer
Sets the dispatch queue used by the transport

Specified by:
setDispatchQueue in interface TransportServer

suspend

public void suspend()
Description copied from interface: TransportServer
suspend accepting new transports

Specified by:
suspend in interface TransportServer

resume

public void resume()
Description copied from interface: TransportServer
resume accepting new transports

Specified by:
resume in interface TransportServer

start

@Deprecated
public void start(Runnable onCompleted)
           throws Exception
Deprecated. 

Specified by:
start in interface TransportServer
Throws:
Exception

stop

@Deprecated
public void stop(Runnable onCompleted)
          throws Exception
Deprecated. 

Specified by:
stop in interface TransportServer
Throws:
Exception

start

public void start(Task onCompleted)
           throws Exception
Description copied from interface: TransportServer
Starts the service. Executes the onComplete runnable once the service has fully started up.

Specified by:
start in interface TransportServer
Parameters:
onCompleted - my be set to null if not interested in a callback.
Throws:
Exception

getBoundAddress

public String getBoundAddress()
Specified by:
getBoundAddress in interface TransportServer

stop

public void stop(Task onCompleted)
          throws Exception
Description copied from interface: TransportServer
Stops the service. Executes the onComplete runnable once the service has fully stopped.

Specified by:
stop in interface TransportServer
Parameters:
onCompleted - my be set to null if not interested in a callback.
Throws:
Exception

getBacklog

public int getBacklog()

setBacklog

public void setBacklog(int backlog)

handleSocket

protected final void handleSocket(SocketChannel socket)
                           throws Exception
Throws:
Exception

createTransport

protected TcpTransport createTransport()

toString

public String toString()
Overrides:
toString in class Object
Returns:
pretty print of this

getReceiveBufferSize

public int getReceiveBufferSize()

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)

getSendBufferSize

public int getSendBufferSize()

setSendBufferSize

public void setSendBufferSize(int sendBufferSize)

getBlockingExecutor

public Executor getBlockingExecutor()
Specified by:
getBlockingExecutor in interface TransportServer

setBlockingExecutor

public void setBlockingExecutor(Executor blockingExecutor)
Specified by:
setBlockingExecutor in interface TransportServer


Copyright © 2010-2014 FuseSource, Corp.. All Rights Reserved.