org.activemq.transport.tcp
Class TcpTransportChannel

java.lang.Object
  extended byorg.activemq.transport.TransportChannelSupport
      extended byorg.activemq.transport.tcp.TcpTransportChannel
All Implemented Interfaces:
java.lang.Runnable, Service, TransportChannel
Direct Known Subclasses:
JabberTransportChannel, StompTransportChannel

public class TcpTransportChannel
extends TransportChannelSupport
implements java.lang.Runnable

A tcp implementation of a TransportChannel

Version:
$Revision: 1.2 $

Field Summary
protected  java.io.DataInputStream dataIn
           
protected  java.io.DataOutputStream dataOut
           
protected  java.net.Socket socket
           
 
Fields inherited from class org.activemq.transport.TransportChannelSupport
cachingEnabled, currentWireFormat, noDelay, pendingStop, transportConnected, usedInternally
 
Constructor Summary
  TcpTransportChannel(TcpTransportServerChannel serverChannel, WireFormat wireFormat, java.net.Socket socket, EDU.oswego.cs.dl.util.concurrent.Executor executor)
          Initialize from a ServerSocket
protected TcpTransportChannel(WireFormat wireFormat)
          Construct basic helpers
  TcpTransportChannel(WireFormat wireFormat, java.net.Socket socket, EDU.oswego.cs.dl.util.concurrent.Executor executor)
           
  TcpTransportChannel(WireFormat wireFormat, java.net.URI remoteLocation)
          Connect to a remote Node - e.g.
  TcpTransportChannel(WireFormat wireFormat, java.net.URI remoteLocation, java.net.URI localLocation)
          Connect to a remote Node - e.g.
 
Method Summary
 void asyncSend(Packet packet)
          Asynchronously send a Packet
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
protected  void closeStreams()
           
protected  java.net.Socket createSocket(java.net.URI remoteLocation)
          Factory method to create a new socket
protected  java.net.Socket createSocket(java.net.URI remoteLocation, java.net.URI localLocation)
          Factory method to create a new socket
protected  Packet doAsyncSend(Packet packet)
          Actually performs the async send of a packet
protected  void doClose(java.lang.Exception ex)
           
 void forceDisconnect()
          Forces an immediate transport-level disconnect which will be asynchronously reported as an exception to the exceptionListener.
 int getCurrentWireFormatVersion()
           
 java.net.Socket getSocket()
           
 int getSocketBufferSize()
           
 int getSoTimeout()
           
protected  void initialiseSocket(java.net.Socket sock)
          Configures the socket for use
protected  void initializeStreams()
           
 boolean isClosed()
           
 boolean isMulticast()
           
 boolean isUseAsyncSend()
           
 void run()
          reads packets from a Socket
 void setNoDelay(boolean noDelay)
           
 void setSocketBufferSize(int socketBufferSize)
           
 void setSoTimeout(int soTimeout)
          set the socket so timeout
 void setUseAsyncSend(boolean useAsyncSend)
          set the useAsync flag
 void start()
          start listeneing for events
 void stop()
          close the channel
 java.lang.String toString()
          pretty print for object
 
Methods inherited from class org.activemq.transport.TransportChannelSupport
addTransportStatusEventListener, asyncSendWithReceipt, doConsumePacket, doConsumePacket, doesSupportMessageCompression, doesSupportMessageFragmentation, doesSupportWireFormatVersioning, doHandleReceipt, doHandleWireFormat, fireStatusEvent, fireStatusEvent, getClientID, getEmbeddedBrokerConnector, getExceptionListener, getLastReceiptTimestamp, getPacketListener, getTransportChannelListener, getWireFormat, isCachingEnabled, isNoDelay, isPendingStop, isServerSide, isTransportConnected, isUsedInternally, onAsyncException, removeTransportStatusEventListener, requiresEmbeddedBroker, send, send, setCachingEnabled, setClientID, setExceptionListener, setPacketListener, setPendingStop, setServerSide, setTransportChannelListener, setTransportConnected, setUsedInternally, setWireFormat, stopExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket

dataOut

protected java.io.DataOutputStream dataOut

dataIn

protected java.io.DataInputStream dataIn
Constructor Detail

TcpTransportChannel

protected TcpTransportChannel(WireFormat wireFormat)
Construct basic helpers

Parameters:
wireFormat -

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           java.net.URI remoteLocation)
                    throws javax.jms.JMSException
Connect to a remote Node - e.g. a Broker

Parameters:
wireFormat -
remoteLocation -
Throws:
javax.jms.JMSException

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           java.net.URI remoteLocation,
                           java.net.URI localLocation)
                    throws javax.jms.JMSException
Connect to a remote Node - e.g. a Broker

Parameters:
wireFormat -
remoteLocation -
localLocation - - e.g. local InetAddress and local port
Throws:
javax.jms.JMSException

TcpTransportChannel

public TcpTransportChannel(TcpTransportServerChannel serverChannel,
                           WireFormat wireFormat,
                           java.net.Socket socket,
                           EDU.oswego.cs.dl.util.concurrent.Executor executor)
                    throws javax.jms.JMSException
Initialize from a ServerSocket

Parameters:
serverChannel -
wireFormat -
socket -
executor -
Throws:
javax.jms.JMSException

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           java.net.Socket socket,
                           EDU.oswego.cs.dl.util.concurrent.Executor executor)
                    throws javax.jms.JMSException
Method Detail

start

public void start()
           throws javax.jms.JMSException
start listeneing for events

Specified by:
start in interface TransportChannel
Throws:
javax.jms.JMSException - if an error occurs

stop

public void stop()
close the channel

Specified by:
stop in interface TransportChannel
Overrides:
stop in class TransportChannelSupport

forceDisconnect

public void forceDisconnect()
Description copied from interface: TransportChannel
Forces an immediate transport-level disconnect which will be asynchronously reported as an exception to the exceptionListener. If the channel isn't connected, the call will be ignored.

Specified by:
forceDisconnect in interface TransportChannel

asyncSend

public void asyncSend(Packet packet)
               throws javax.jms.JMSException
Asynchronously send a Packet

Specified by:
asyncSend in interface TransportChannel
Parameters:
packet -
Throws:
javax.jms.JMSException

isMulticast

public boolean isMulticast()
Specified by:
isMulticast in interface TransportChannel
Overrides:
isMulticast in class TransportChannelSupport
Returns:
false

run

public void run()
reads packets from a Socket

Specified by:
run in interface java.lang.Runnable

isClosed

public boolean isClosed()

toString

public java.lang.String toString()
pretty print for object

Returns:
String representation of this object

getSocket

public java.net.Socket getSocket()
Returns:
the socket used by the TcpTransportChannel

canProcessWireFormatVersion

public boolean canProcessWireFormatVersion(int version)
Can this wireformat process packets of this version

Specified by:
canProcessWireFormatVersion in interface TransportChannel
Overrides:
canProcessWireFormatVersion in class TransportChannelSupport
Parameters:
version - the version number to test
Returns:
true if can accept the version

getCurrentWireFormatVersion

public int getCurrentWireFormatVersion()
Specified by:
getCurrentWireFormatVersion in interface TransportChannel
Overrides:
getCurrentWireFormatVersion in class TransportChannelSupport
Returns:
the current version of this wire format

isUseAsyncSend

public boolean isUseAsyncSend()
Returns:
true if packets are enqueued to a separate queue before dispatching

setUseAsyncSend

public void setUseAsyncSend(boolean useAsyncSend)
set the useAsync flag

Parameters:
useAsyncSend -

getSoTimeout

public int getSoTimeout()
Returns:
the current so timeout used on the socket

setSoTimeout

public void setSoTimeout(int soTimeout)
                  throws javax.jms.JMSException
set the socket so timeout

Parameters:
soTimeout -
Throws:
javax.jms.JMSException

setNoDelay

public void setNoDelay(boolean noDelay)
Specified by:
setNoDelay in interface TransportChannel
Overrides:
setNoDelay in class TransportChannelSupport
Parameters:
noDelay - The noDelay to set.

getSocketBufferSize

public int getSocketBufferSize()
Returns:
Returns the socketBufferSize.

setSocketBufferSize

public void setSocketBufferSize(int socketBufferSize)
Parameters:
socketBufferSize - The socketBufferSize to set.

doAsyncSend

protected Packet doAsyncSend(Packet packet)
                      throws javax.jms.JMSException
Actually performs the async send of a packet

Overrides:
doAsyncSend in class TransportChannelSupport
Parameters:
packet -
Returns:
a response or null
Throws:
javax.jms.JMSException

doClose

protected void doClose(java.lang.Exception ex)

initialiseSocket

protected void initialiseSocket(java.net.Socket sock)
                         throws java.net.SocketException
Configures the socket for use

Parameters:
sock -
Throws:
java.net.SocketException

initializeStreams

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

closeStreams

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

createSocket

protected java.net.Socket createSocket(java.net.URI remoteLocation)
                                throws java.net.UnknownHostException,
                                       java.io.IOException
Factory method to create a new socket

Parameters:
remoteLocation - the URI to connect to
Returns:
the newly created socket
Throws:
java.net.UnknownHostException
java.io.IOException

createSocket

protected java.net.Socket createSocket(java.net.URI remoteLocation,
                                       java.net.URI localLocation)
                                throws java.io.IOException,
                                       java.net.UnknownHostException
Factory method to create a new socket

Parameters:
remoteLocation -
localLocation -
Returns:
@throws IOException
Throws:
java.io.IOException
java.net.UnknownHostException


Copyright © 2004-2005 Protique, Ltd.. All Rights Reserved.