org.fusesource.hawtdispatch.transport
Interface Transport

All Known Implementing Classes:
PipeTransport, SslTransport, TcpTransport

public interface Transport

Represents an abstract connection. It can be a client side or server side connection.

Author:
Hiram Chirino

Method Summary
 void flush()
          Forces a flush of any output buffers.
 boolean full()
           
 DispatchQueue getDispatchQueue()
          Returns the dispatch queue used by the transport
 SocketAddress getLocalAddress()
           
 ProtocolCodec getProtocolCodec()
           
 SocketAddress getRemoteAddress()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 String getTypeId()
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isFaultTolerant()
          Indicates if the transport can handle faults
<T> T
narrow(Class<T> target)
           
 boolean offer(Object command)
          A one way asynchronous send of a command.
 void reconnect(URI uri)
          reconnect to another location
 void resumeRead()
          resume delivery of commands.
 void setDispatchQueue(DispatchQueue queue)
          Sets the dispatch queue used by the transport
 void setProtocolCodec(ProtocolCodec protocolCodec)
          Sets the protocol codec for the transport
 void setTransportListener(TransportListener commandListener)
          Registers an inbound command listener
 void start(Runnable onComplete)
          Starts the service.
 void stop(Runnable onComplete)
          Stops the service.
 void suspendRead()
          suspend delivery of commands.
 

Method Detail

start

void start(Runnable onComplete)
Starts the service. Executes the onComplete runnable once the service has fully started up.

Parameters:
onComplete - my be set to null if not interested in a callback.

stop

void stop(Runnable onComplete)
Stops the service. Executes the onComplete runnable once the service has fully stopped.

Parameters:
onComplete - my be set to null if not interested in a callback.

full

boolean full()

offer

boolean offer(Object command)
A one way asynchronous send of a command. Only sent if the the transport is not full.

Parameters:
command -
Returns:
true if the command was accepted.

flush

void flush()
Forces a flush of any output buffers. Once the flush completes the listener's 'onRefill()' method will execute.


getTransportListener

TransportListener getTransportListener()
Returns the current transport listener

Returns:

setTransportListener

void setTransportListener(TransportListener commandListener)
Registers an inbound command listener

Parameters:
commandListener -

getDispatchQueue

DispatchQueue getDispatchQueue()
Returns the dispatch queue used by the transport

Returns:

setDispatchQueue

void setDispatchQueue(DispatchQueue queue)
Sets the dispatch queue used by the transport

Parameters:
queue -

suspendRead

void suspendRead()
suspend delivery of commands.


resumeRead

void resumeRead()
resume delivery of commands.


narrow

<T> T narrow(Class<T> target)
Parameters:
target -
Returns:
the target

getRemoteAddress

SocketAddress getRemoteAddress()
Returns:
the remote address for this connection

getLocalAddress

SocketAddress getLocalAddress()
Returns:
the remote address for this connection

isFaultTolerant

boolean isFaultTolerant()
Indicates if the transport can handle faults

Returns:
true if fault tolerant

isDisposed

boolean isDisposed()
Returns:
true if the transport is disposed

isConnected

boolean isConnected()
Returns:
true if the transport is connected

getProtocolCodec

ProtocolCodec getProtocolCodec()
Returns:
The protocol codec for the transport.

setProtocolCodec

void setProtocolCodec(ProtocolCodec protocolCodec)
                      throws Exception
Sets the protocol codec for the transport

Parameters:
protocolCodec -
Throws:
Exception

reconnect

void reconnect(URI uri)
reconnect to another location

Parameters:
uri -
Throws:
IOException - on failure of if not supported

getTypeId

String getTypeId()
Returns:
the identifier for the transport type. Example "tcp" for the tcp transport.


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