org.codehaus.activemq.transport.tcp
Class TcpTransportChannel

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

public class TcpTransportChannel
extends TransportChannelSupport
implements Runnable

A tcp implementation of a TransportChannel

Version:
$Revision: 1.53 $

Field Summary
protected  Socket socket
           
 
Fields inherited from class org.codehaus.activemq.transport.TransportChannelSupport
pendingStop, transportConnected
 
Constructor Summary
protected TcpTransportChannel(WireFormat wireFormat)
          Construct basic helpers
  TcpTransportChannel(WireFormat wireFormat, Socket socket, Executor executor)
           
  TcpTransportChannel(WireFormat wireFormat, URI remoteLocation)
          Connect to a remote Node - e.g.
  TcpTransportChannel(WireFormat wireFormat, URI remoteLocation, 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  Socket createSocket(URI remoteLocation)
          Factory method to create a new socket
protected  Socket createSocket(URI remoteLocation, URI localLocation)
          Factory method to create a new socket
protected  void doAsyncSend(Packet packet)
          Actually performs the async send of a packet
 int getCurrentWireFormatVersion()
           
 Socket getSocket()
           
 int getSoTimeout()
           
protected  void initialiseSocket()
          Configures the socket for use
 boolean isChangeTimeout()
           
 boolean isMulticast()
           
 boolean isUseAsyncSend()
           
 void run()
          reads packets from a Socket
 void setChangeTimeout(boolean changeTimeout)
           
 void setSoTimeout(int soTimeout)
           
 void setUseAsyncSend(boolean useAsyncSend)
           
 void start()
          start listeneing for events
 void stop()
          close the channel
 String toString()
          pretty print for object
 
Methods inherited from class org.codehaus.activemq.transport.TransportChannelSupport
addTransportStatusEventListener, doConsumePacket, doConsumePacket, doHandleReceipt, doHandleWireFormat, fireStatusEvent, fireStatusEvent, getClientID, getExceptionListener, getPacketListener, getTransportChannelListener, isPendingStop, isServerSide, isTransportConnected, onAsyncException, removeTransportStatusEventListener, send, send, setClientID, setExceptionListener, setPacketListener, setPendingStop, setServerSide, setTransportChannelListener, setTransportConnected, stopExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected Socket socket
Constructor Detail

TcpTransportChannel

protected TcpTransportChannel(WireFormat wireFormat)
Construct basic helpers


TcpTransportChannel

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

Parameters:
remoteLocation -
Throws:
JMSException

TcpTransportChannel

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

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

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           Socket socket,
                           Executor executor)
                    throws JMSException
Parameters:
socket -
Throws:
JMSException
Method Detail

start

public void start()
           throws JMSException
start listeneing for events

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

stop

public void stop()
close the channel

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

asyncSend

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

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

isMulticast

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

run

public void run()
reads packets from a Socket

Specified by:
run in interface Runnable

toString

public String toString()
pretty print for object

Returns:
String representation of this object

getSocket

public Socket getSocket()

canProcessWireFormatVersion

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

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

getCurrentWireFormatVersion

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

isChangeTimeout

public boolean isChangeTimeout()

setChangeTimeout

public void setChangeTimeout(boolean changeTimeout)

isUseAsyncSend

public boolean isUseAsyncSend()

setUseAsyncSend

public void setUseAsyncSend(boolean useAsyncSend)

getSoTimeout

public int getSoTimeout()

setSoTimeout

public void setSoTimeout(int soTimeout)

doAsyncSend

protected void doAsyncSend(Packet packet)
                    throws JMSException
Actually performs the async send of a packet

Overrides:
doAsyncSend in class TransportChannelSupport
Parameters:
packet -
Throws:
JMSException

initialiseSocket

protected void initialiseSocket()
                         throws IOException
Configures the socket for use

Throws:
IOException

createSocket

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

Parameters:
remoteLocation - the URI to connect to
Returns:
the newly created socket
Throws:
UnknownHostException
IOException

createSocket

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

Parameters:
remoteLocation -
localLocation -
Returns:
@throws IOException
Throws:
IOException
UnknownHostException


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