org.fusesource.stompjms.client.transport
Class TcpTransport

java.lang.Object
  extended by org.fusesource.stompjms.client.transport.BaseService
      extended by org.fusesource.stompjms.client.transport.TcpTransport
All Implemented Interfaces:
Transport
Direct Known Subclasses:
SslTransport

public class TcpTransport
extends BaseService
implements Transport

An implementation of the Transport interface using raw tcp/ip

Author:
Hiram Chirino

Nested Class Summary
 
Nested classes/interfaces inherited from class org.fusesource.stompjms.client.transport.BaseService
BaseService.STARTING, BaseService.State, BaseService.STOPPING
 
Field Summary
protected  java.nio.channels.SocketChannel channel
           
protected  ProtocolCodec codec
           
protected  org.fusesource.hawtdispatch.DispatchQueue dispatchQueue
           
static int IPTOS_LOWCOST
           
static int IPTOS_LOWDELAY
           
static int IPTOS_RELIABILITY
           
static int IPTOS_THROUGHPUT
           
protected  TransportListener listener
           
protected  java.net.URI localLocation
           
protected  org.fusesource.stompjms.client.transport.TcpTransport.RateLimitingChannel rateLimitingChannel
           
protected  java.net.URI remoteLocation
           
protected  org.fusesource.stompjms.client.transport.TcpTransport.SocketState socketState
           
protected  boolean useLocalHost
           
 
Fields inherited from class org.fusesource.stompjms.client.transport.BaseService
_serviceState, CREATED, STARTED, STOPPED
 
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()
           
 org.fusesource.hawtdispatch.DispatchQueue getDispatchQueue()
          Returns the dispatch queue used by the transport
 java.net.SocketAddress getLocalAddress()
           
 int getMaxReadRate()
           
 int getMaxWriteRate()
           
 ProtocolCodec getProtocolCodec()
           
 int getReceiveBufferSize()
           
 java.net.SocketAddress getRemoteAddress()
           
 int getSendBufferSize()
           
 java.nio.channels.SocketChannel getSocketChannel()
           
 int getTrafficClass()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 java.lang.String getTypeId()
           
protected  void initializeCodec()
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isFaultTolerant()
          Indicates if the transport can handle faults
 boolean isUseLocalHost()
           
<T> T
narrow(java.lang.Class<T> target)
           
 boolean offer(java.lang.Object command)
          A one way asynchronous send of a command.
protected  void onConnected()
           
 void onTransportFailure(java.io.IOException error)
           
 java.nio.channels.ReadableByteChannel readChannel()
           
 void reconnect(java.net.URI uri)
          reconnect to another location
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 setMaxReadRate(int maxReadRate)
           
 void setMaxWriteRate(int maxWriteRate)
           
 void setProtocolCodec(ProtocolCodec protocolCodec)
          Sets the protocol codec for the transport
 void setReceiveBufferSize(int receiveBufferSize)
           
 void setSendBufferSize(int sendBufferSize)
           
 void setTrafficClass(int trafficClass)
           
 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 suspendRead()
          suspend delivery of commands.
protected  void suspendWrite()
           
 java.nio.channels.WritableByteChannel writeChannel()
           
 
Methods inherited from class org.fusesource.stompjms.client.transport.BaseService
getServiceState, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.fusesource.stompjms.client.transport.Transport
start, stop
 

Field Detail

remoteLocation

protected java.net.URI remoteLocation

localLocation

protected java.net.URI localLocation

listener

protected TransportListener listener

codec

protected ProtocolCodec codec

channel

protected java.nio.channels.SocketChannel channel

socketState

protected org.fusesource.stompjms.client.transport.TcpTransport.SocketState socketState

dispatchQueue

protected org.fusesource.hawtdispatch.DispatchQueue dispatchQueue

useLocalHost

protected boolean useLocalHost

IPTOS_LOWCOST

public static final int IPTOS_LOWCOST
See Also:
Constant Field Values

IPTOS_RELIABILITY

public static final int IPTOS_RELIABILITY
See Also:
Constant Field Values

IPTOS_THROUGHPUT

public static final int IPTOS_THROUGHPUT
See Also:
Constant Field Values

IPTOS_LOWDELAY

public static final int IPTOS_LOWDELAY
See Also:
Constant Field Values

rateLimitingChannel

protected org.fusesource.stompjms.client.transport.TcpTransport.RateLimitingChannel rateLimitingChannel
Constructor Detail

TcpTransport

public TcpTransport()
Method Detail

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()
                        throws java.lang.Exception
Throws:
java.lang.Exception

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

getDispatchQueue

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

Specified by:
getDispatchQueue in interface Transport
Specified by:
getDispatchQueue in class BaseService
Returns:

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)
Specified by:
_start in class BaseService

_stop

public void _stop(java.lang.Runnable onCompleted)
Specified by:
_stop in class BaseService

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()

getLocalAddress

public java.net.SocketAddress getLocalAddress()
Specified by:
getLocalAddress in interface Transport
Returns:
the remote address for this connection

getRemoteAddress

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

narrow

public <T> T narrow(java.lang.Class<T> target)
Specified by:
narrow in interface Transport
Returns:
the target

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()

getTypeId

public java.lang.String getTypeId()
Specified by:
getTypeId in interface Transport
Returns:
the identifier for the transport type. Example "tcp" for the tcp transport.

reconnect

public void reconnect(java.net.URI uri)
Description copied from interface: Transport
reconnect to another location

Specified by:
reconnect in interface Transport

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)
                      throws java.lang.Exception
Description copied from interface: Transport
Sets the protocol codec for the transport

Specified by:
setProtocolCodec in interface Transport
Throws:
java.lang.Exception

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

isFaultTolerant

public boolean isFaultTolerant()
Description copied from interface: Transport
Indicates if the transport can handle faults

Specified by:
isFaultTolerant in interface Transport
Returns:
true if fault tolerant

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()

getMaxReadRate

public int getMaxReadRate()

setMaxReadRate

public void setMaxReadRate(int maxReadRate)

getMaxWriteRate

public int getMaxWriteRate()

setMaxWriteRate

public void setMaxWriteRate(int maxWriteRate)

getTrafficClass

public int getTrafficClass()

setTrafficClass

public void setTrafficClass(int trafficClass)

getReceiveBufferSize

public int getReceiveBufferSize()

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)

getSendBufferSize

public int getSendBufferSize()

setSendBufferSize

public void setSendBufferSize(int sendBufferSize)


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