org.fusesource.fabric.dosgi.tcp
Class TcpTransportServer

java.lang.Object
  extended by org.fusesource.fabric.dosgi.tcp.TcpTransportServer
All Implemented Interfaces:
Service, TransportServer

public class TcpTransportServer
extends java.lang.Object
implements TransportServer

A TCP based transport server

Author:
Hiram Chirino

Constructor Summary
TcpTransportServer(java.net.URI location)
           
 
Method Summary
protected  TcpTransport createTransport()
           
protected  TcpTransport createTransport(java.nio.channels.SocketChannel socketChannel, java.util.HashMap<java.lang.String,java.lang.Object> options)
           
 int getBacklog()
           
 java.lang.String getBoundAddress()
           
 java.lang.String getConnectAddress()
           
 org.fusesource.hawtdispatch.DispatchQueue getDispatchQueue()
          Returns the dispatch queue used by the transport
 java.net.InetSocketAddress getSocketAddress()
           
protected  void handleSocket(java.nio.channels.SocketChannel socket)
           
protected  java.lang.String resolveHostName()
           
 void resume()
          resume accepting new transports
 void setAcceptListener(TransportAcceptListener listener)
          Registers an TransportAcceptListener which is notified of accepted channels.
 void setBacklog(int backlog)
           
 void setDispatchQueue(org.fusesource.hawtdispatch.DispatchQueue dispatchQueue)
          Sets the dispatch queue used by the transport
 void setTransportOption(java.util.Map<java.lang.String,java.lang.Object> transportOptions)
           
 void start()
          Starts the service.
 void start(java.lang.Runnable onCompleted)
          Starts the service.
 void stop()
          Stops the service.
 void stop(java.lang.Runnable onCompleted)
          Stops the service.
 void suspend()
          suspend accepting new transports
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TcpTransportServer

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

setAcceptListener

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

Specified by:
setAcceptListener in interface TransportServer

getSocketAddress

public java.net.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 org.fusesource.hawtdispatch.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(org.fusesource.hawtdispatch.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

public void start()
           throws java.lang.Exception
Description copied from interface: Service
Starts the service. No guarantee is given that the service has fully started by the time this method returns.

Specified by:
start in interface Service
Throws:
java.lang.Exception

start

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

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

getBoundAddress

public java.lang.String getBoundAddress()
Specified by:
getBoundAddress in interface TransportServer

getConnectAddress

public java.lang.String getConnectAddress()
Specified by:
getConnectAddress in interface TransportServer

resolveHostName

protected java.lang.String resolveHostName()

stop

public void stop()
Description copied from interface: Service
Stops the service. No guarantee is given that the service has fully stopped by the time this method returns.

Specified by:
stop in interface Service

stop

public void stop(java.lang.Runnable onCompleted)
Description copied from interface: Service
Stops the service. Executes the onComplete runnable once the service has fully stopped.

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

getBacklog

public int getBacklog()

setBacklog

public void setBacklog(int backlog)

handleSocket

protected final void handleSocket(java.nio.channels.SocketChannel socket)
                           throws java.lang.Exception
Throws:
java.lang.Exception

createTransport

protected TcpTransport createTransport(java.nio.channels.SocketChannel socketChannel,
                                       java.util.HashMap<java.lang.String,java.lang.Object> options)
                                throws java.lang.Exception
Throws:
java.lang.Exception

createTransport

protected TcpTransport createTransport()

setTransportOption

public void setTransportOption(java.util.Map<java.lang.String,java.lang.Object> transportOptions)

toString

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


Copyright © 2013 Red Hat. All Rights Reserved.