org.fusesource.fabric.dosgi.tcp
Class TcpTransport

java.lang.Object
  extended by org.fusesource.fabric.dosgi.tcp.TcpTransport
All Implemented Interfaces:
Dispatched, Service, Transport

public class TcpTransport
extends java.lang.Object
implements Transport


Nested Class Summary
static class TcpTransport.STARTING
           
static class TcpTransport.State
           
static class TcpTransport.STOPPING
           
 
Field Summary
protected  TcpTransport.State _serviceState
           
protected  java.nio.channels.SocketChannel channel
           
protected  ProtocolCodec codec
           
static TcpTransport.State CREATED
           
protected  org.fusesource.hawtdispatch.DispatchQueue dispatchQueue
           
protected  TransportListener listener
           
protected  java.net.URI localLocation
           
protected  org.fusesource.fabric.dosgi.tcp.TcpTransport.RateLimitingChannel rateLimitingChannel
           
protected  java.lang.String remoteAddress
           
protected  java.net.URI remoteLocation
           
protected  java.util.Map<java.lang.String,java.lang.Object> socketOptions
           
protected  org.fusesource.fabric.dosgi.tcp.TcpTransport.SocketState socketState
           
static TcpTransport.State STARTED
           
static TcpTransport.State STOPPED
           
protected  boolean useLocalHost
           
 
Constructor Summary
TcpTransport()
           
 
Method Summary
 void _start(java.lang.Runnable onCompleted)
           
 void _stop(java.lang.Runnable onCompleted)
           
 void connected(java.nio.channels.SocketChannel channel)
           
 void connecting(java.net.URI remoteLocation, java.net.URI localLocation)
           
protected  void drainInbound()
           
protected  void drainOutbound()
           
protected  boolean flush()
           
 boolean full()
           
 int getMax_read_rate()
           
 int getMax_write_rate()
           
 ProtocolCodec getProtocolCodec()
           
 java.lang.String getRemoteAddress()
           
protected  TcpTransport.State getServiceState()
           
 java.nio.channels.SocketChannel getSocketChannel()
           
 TransportListener getTransportListener()
          Returns the current transport listener
protected  void initializeCodec()
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isUseLocalHost()
           
 boolean offer(java.lang.Object command)
          A one way asynchronous send of a command.
protected  void onConnected()
           
 void onTransportFailure(java.io.IOException error)
           
 org.fusesource.hawtdispatch.DispatchQueue queue()
           
 java.nio.channels.ReadableByteChannel readChannel()
           
protected  java.lang.String resolveHostName(java.lang.String host)
           
 void resumeRead()
          resume delivery of commands.
protected  void resumeWrite()
           
 void setDispatchQueue(org.fusesource.hawtdispatch.DispatchQueue queue)
          Sets the dispatch queue used by the transport
 void setMax_read_rate(int max_read_rate)
           
 void setMax_write_rate(int max_write_rate)
           
 void setProtocolCodec(ProtocolCodec protocolCodec)
          Sets the protocol codec for the transport
 void setSocketOptions(java.util.Map<java.lang.String,java.lang.Object> socketOptions)
           
 void setTransportListener(TransportListener listener)
          Registers an inbound command listener
 void setUseLocalHost(boolean useLocalHost)
          Sets whether 'localhost' or the actual local host name should be used to make local connections.
 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 suspendRead()
          suspend delivery of commands.
protected  void suspendWrite()
           
 java.nio.channels.WritableByteChannel writeChannel()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_serviceState

protected TcpTransport.State _serviceState

socketOptions

protected java.util.Map<java.lang.String,java.lang.Object> socketOptions

CREATED

public static final TcpTransport.State CREATED

STARTED

public static final TcpTransport.State STARTED

STOPPED

public static final TcpTransport.State STOPPED

remoteLocation

protected java.net.URI remoteLocation

localLocation

protected java.net.URI localLocation

listener

protected TransportListener listener

remoteAddress

protected java.lang.String remoteAddress

codec

protected ProtocolCodec codec

channel

protected java.nio.channels.SocketChannel channel

socketState

protected org.fusesource.fabric.dosgi.tcp.TcpTransport.SocketState socketState

dispatchQueue

protected org.fusesource.hawtdispatch.DispatchQueue dispatchQueue

useLocalHost

protected boolean useLocalHost

rateLimitingChannel

protected org.fusesource.fabric.dosgi.tcp.TcpTransport.RateLimitingChannel rateLimitingChannel
Constructor Detail

TcpTransport

public TcpTransport()
Method Detail

start

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

stop

public final 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

start

public final void start(java.lang.Runnable onCompleted)
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.

stop

public final 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.

getServiceState

protected TcpTransport.State getServiceState()

connected

public void connected(java.nio.channels.SocketChannel channel)
               throws java.io.IOException,
                      java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception

initializeCodec

protected void initializeCodec()

connecting

public void connecting(java.net.URI remoteLocation,
                       java.net.URI localLocation)
                throws java.io.IOException,
                       java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception

queue

public org.fusesource.hawtdispatch.DispatchQueue queue()
Specified by:
queue in interface Dispatched

setDispatchQueue

public void setDispatchQueue(org.fusesource.hawtdispatch.DispatchQueue queue)
Description copied from interface: Transport
Sets the dispatch queue used by the transport

Specified by:
setDispatchQueue in interface Transport

_start

public void _start(java.lang.Runnable onCompleted)

_stop

public void _stop(java.lang.Runnable onCompleted)

resolveHostName

protected java.lang.String resolveHostName(java.lang.String host)
                                    throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

onConnected

protected void onConnected()
                    throws java.io.IOException
Throws:
java.io.IOException

onTransportFailure

public void onTransportFailure(java.io.IOException error)

full

public boolean full()
Specified by:
full in interface Transport

offer

public boolean offer(java.lang.Object command)
Description copied from interface: Transport
A one way asynchronous send of a command. Only sent if the the transport is not full.

Specified by:
offer in interface Transport
Returns:
true if the command was accepted.

drainOutbound

protected void drainOutbound()

flush

protected boolean flush()
                 throws java.io.IOException
Throws:
java.io.IOException

drainInbound

protected void drainInbound()

getRemoteAddress

public java.lang.String getRemoteAddress()
Specified by:
getRemoteAddress in interface Transport
Returns:
the remote address for this connection

suspendRead

public void suspendRead()
Description copied from interface: Transport
suspend delivery of commands.

Specified by:
suspendRead in interface Transport

resumeRead

public void resumeRead()
Description copied from interface: Transport
resume delivery of commands.

Specified by:
resumeRead in interface Transport

suspendWrite

protected void suspendWrite()

resumeWrite

protected void resumeWrite()

getTransportListener

public TransportListener getTransportListener()
Description copied from interface: Transport
Returns the current transport listener

Specified by:
getTransportListener in interface Transport
Returns:

setTransportListener

public void setTransportListener(TransportListener listener)
Description copied from interface: Transport
Registers an inbound command listener

Specified by:
setTransportListener in interface Transport

getProtocolCodec

public ProtocolCodec getProtocolCodec()
Specified by:
getProtocolCodec in interface Transport
Returns:
The protocol codec for the transport.

setProtocolCodec

public void setProtocolCodec(ProtocolCodec protocolCodec)
Description copied from interface: Transport
Sets the protocol codec for the transport

Specified by:
setProtocolCodec in interface Transport

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Transport
Returns:
true if the transport is connected

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface Transport
Returns:
true if the transport is disposed

setSocketOptions

public void setSocketOptions(java.util.Map<java.lang.String,java.lang.Object> socketOptions)

isUseLocalHost

public boolean isUseLocalHost()

setUseLocalHost

public void setUseLocalHost(boolean useLocalHost)
Sets whether 'localhost' or the actual local host name should be used to make local connections. On some operating systems such as Macs its not possible to connect as the local host name so localhost is better.


getSocketChannel

public java.nio.channels.SocketChannel getSocketChannel()

readChannel

public java.nio.channels.ReadableByteChannel readChannel()

writeChannel

public java.nio.channels.WritableByteChannel writeChannel()

getMax_read_rate

public int getMax_read_rate()

setMax_read_rate

public void setMax_read_rate(int max_read_rate)

getMax_write_rate

public int getMax_write_rate()

setMax_write_rate

public void setMax_write_rate(int max_write_rate)


Copyright © 2013 Red Hat. All Rights Reserved.