org.activemq.transport
Class TransportChannelSupport

java.lang.Object
  extended byorg.activemq.transport.TransportChannelSupport
All Implemented Interfaces:
Service, TransportChannel
Direct Known Subclasses:
ActiveIOTransportChannel, CompositeTransportChannel, TcpTransportChannel, UdpTransportChannel, VmTransportChannel

public abstract class TransportChannelSupport
extends Object
implements TransportChannel

Some basic functionality, common across most transport implementations of channels

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  boolean cachingEnabled
           
protected  WireFormat currentWireFormat
           
protected  boolean noDelay
           
protected  boolean pendingStop
           
protected  boolean transportConnected
           
protected  boolean usedInternally
           
 
Constructor Summary
protected TransportChannelSupport()
           
protected TransportChannelSupport(WireFormat wf)
           
 
Method Summary
 void addTransportStatusEventListener(TransportStatusEventListener listener)
          Add a listener for changes in a channels status
 ReceiptHolder asyncSendWithReceipt(Packet packet)
          Asynchronously send a Packet with receipt.
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
protected  Packet doAsyncSend(Packet packet)
          send a Packet to the raw underlying transport This method is here to allow specific implementations to override this method
protected  void doConsumePacket(Packet packet)
          consume a packet from the channel
protected  void doConsumePacket(Packet packet, PacketListener listener)
           
 boolean doesSupportMessageCompression()
          Some transports/wireformats will not be able to understand compressed messages
 boolean doesSupportMessageFragmentation()
          some transports/wire formats will implement their own fragementation
 boolean doesSupportWireFormatVersioning()
          Does the transport support wire format version info
protected  boolean doHandleReceipt(Packet packet)
           
protected  boolean doHandleWireFormat(Packet packet)
           
protected  void fireStatusEvent(TransportStatusEvent event)
          Fire status event to any status event listeners
protected  void fireStatusEvent(URI remoteURI, int status)
          Fire status event to any status event listeners
 String getClientID()
           
 int getCurrentWireFormatVersion()
           
 BrokerConnector getEmbeddedBrokerConnector()
          Some transports that rely on an embedded broker need to create the connector used by the broker
 ExceptionListener getExceptionListener()
           
 long getLastReceiptTimestamp()
          Gets the timestamp of the last received receipt packet.
 PacketListener getPacketListener()
           
 TransportChannelListener getTransportChannelListener()
           
 WireFormat getWireFormat()
          Get the current wireformat used by this channel
 boolean isCachingEnabled()
           
 boolean isMulticast()
           
 boolean isNoDelay()
          Inform Transport to send messages as quickly as possible - for Tcp - this means disabling Nagles, which on OSX may provide better performance for sync sends
 boolean isPendingStop()
           
 boolean isServerSide()
           
 boolean isTransportConnected()
           
 boolean isUsedInternally()
           
protected  void onAsyncException(JMSException e)
          Handles an exception thrown while performing async dispatch of messages
 void removeTransportStatusEventListener(TransportStatusEventListener listener)
          Remove a listener for changes in a channels status
 boolean requiresEmbeddedBroker()
          Some transports rely on an embedded broker (beer based protocols)
 Receipt send(Packet packet)
          synchronously send a Packet
 Receipt send(Packet packet, int timeout)
          Synchronously send a Packet
 void setCachingEnabled(boolean cachingEnabled)
           
 void setClientID(String clientID)
          Provides a way to specify the client ID that this channel is using
 void setExceptionListener(ExceptionListener listener)
          Set an exception listener to listen for asynchronously generated exceptions
 void setNoDelay(boolean noDelay)
           
 void setPacketListener(PacketListener l)
          Set a listener for Packets
 void setPendingStop(boolean pendingStop)
          Give the TransportChannel a hint it's about to stop
 void setServerSide(boolean serverSide)
          set the server flag
 void setTransportChannelListener(TransportChannelListener transportChannelListener)
          A listener to be notified when the channel is removed
protected  void setTransportConnected(boolean value)
           
 void setUsedInternally(boolean usedInternally)
           
 void setWireFormat(WireFormat wireformat)
          set the wire format to be used by this channel
 void stop()
          close the channel
protected  void stopExecutor(Executor executor)
          A helper method to stop the execution of an executor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.activemq.transport.TransportChannel
asyncSend, forceDisconnect, start
 

Field Detail

pendingStop

protected boolean pendingStop

transportConnected

protected boolean transportConnected

currentWireFormat

protected WireFormat currentWireFormat

cachingEnabled

protected boolean cachingEnabled

noDelay

protected boolean noDelay

usedInternally

protected boolean usedInternally
Constructor Detail

TransportChannelSupport

protected TransportChannelSupport()

TransportChannelSupport

protected TransportChannelSupport(WireFormat wf)
Method Detail

setPendingStop

public void setPendingStop(boolean pendingStop)
Give the TransportChannel a hint it's about to stop

Specified by:
setPendingStop in interface TransportChannel
Parameters:
pendingStop -

isPendingStop

public boolean isPendingStop()
Specified by:
isPendingStop in interface TransportChannel
Returns:
true if the channel is about to stop

setWireFormat

public void setWireFormat(WireFormat wireformat)
set the wire format to be used by this channel

Specified by:
setWireFormat in interface TransportChannel
Parameters:
wireformat -

getWireFormat

public WireFormat getWireFormat()
Get the current wireformat used by this channel

Specified by:
getWireFormat in interface TransportChannel
Returns:
the current wire format - or null if not set

stop

public void stop()
close the channel

Specified by:
stop in interface TransportChannel

send

public Receipt send(Packet packet)
             throws JMSException
synchronously send a Packet

Specified by:
send in interface TransportChannel
Parameters:
packet -
Returns:
a Receipt
Throws:
JMSException

send

public Receipt send(Packet packet,
                    int timeout)
             throws JMSException
Synchronously send a Packet

Specified by:
send in interface TransportChannel
Parameters:
packet - packet to send
timeout - amount of time to wait for a receipt
Returns:
the Receipt
Throws:
JMSException

asyncSendWithReceipt

public ReceiptHolder asyncSendWithReceipt(Packet packet)
                                   throws JMSException
Asynchronously send a Packet with receipt.

Specified by:
asyncSendWithReceipt in interface TransportChannel
Parameters:
packet - the packet to send
Returns:
a ReceiptHolder for the packet
Throws:
JMSException

getTransportChannelListener

public TransportChannelListener getTransportChannelListener()
Returns:
the transportChannelListener

setTransportChannelListener

public void setTransportChannelListener(TransportChannelListener transportChannelListener)
Description copied from interface: TransportChannel
A listener to be notified when the channel is removed

Specified by:
setTransportChannelListener in interface TransportChannel
Parameters:
transportChannelListener -

addTransportStatusEventListener

public void addTransportStatusEventListener(TransportStatusEventListener listener)
Add a listener for changes in a channels status

Specified by:
addTransportStatusEventListener in interface TransportChannel
Parameters:
listener -

removeTransportStatusEventListener

public void removeTransportStatusEventListener(TransportStatusEventListener listener)
Remove a listener for changes in a channels status

Specified by:
removeTransportStatusEventListener in interface TransportChannel
Parameters:
listener -

getClientID

public String getClientID()
Specified by:
getClientID in interface TransportChannel
Returns:
the clientID

setClientID

public void setClientID(String clientID)
Description copied from interface: TransportChannel
Provides a way to specify the client ID that this channel is using

Specified by:
setClientID in interface TransportChannel
Parameters:
clientID - set the clientID

getExceptionListener

public ExceptionListener getExceptionListener()
Returns:
the exception listener

getPacketListener

public PacketListener getPacketListener()
Returns:
the packet listener

setPacketListener

public void setPacketListener(PacketListener l)
Set a listener for Packets

Specified by:
setPacketListener in interface TransportChannel
Parameters:
l -

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Set an exception listener to listen for asynchronously generated exceptions

Specified by:
setExceptionListener in interface TransportChannel
Parameters:
listener -

isServerSide

public boolean isServerSide()
Specified by:
isServerSide in interface TransportChannel
Returns:
true if server side

setServerSide

public void setServerSide(boolean serverSide)
Description copied from interface: TransportChannel
set the server flag

Specified by:
setServerSide in interface TransportChannel
Parameters:
serverSide -

isTransportConnected

public boolean isTransportConnected()
Specified by:
isTransportConnected in interface TransportChannel
Returns:
true if the transport channel is active, this value will be false through reconnecting

setTransportConnected

protected void setTransportConnected(boolean value)

requiresEmbeddedBroker

public boolean requiresEmbeddedBroker()
Some transports rely on an embedded broker (beer based protocols)

Specified by:
requiresEmbeddedBroker in interface TransportChannel
Returns:
true if an embedded broker required

getEmbeddedBrokerConnector

public BrokerConnector getEmbeddedBrokerConnector()
                                           throws JMSException
Some transports that rely on an embedded broker need to create the connector used by the broker

Specified by:
getEmbeddedBrokerConnector in interface TransportChannel
Returns:
the BrokerConnector or null if not applicable
Throws:
JMSException

isMulticast

public boolean isMulticast()
Specified by:
isMulticast in interface TransportChannel
Returns:
true if this transport is multicast based (i.e. broadcasts to multiple nodes)

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

getLastReceiptTimestamp

public long getLastReceiptTimestamp()
Description copied from interface: TransportChannel
Gets the timestamp of the last received receipt packet.

Specified by:
getLastReceiptTimestamp in interface TransportChannel
Returns:
the timestamp in milliseconds

isUsedInternally

public boolean isUsedInternally()
Specified by:
isUsedInternally in interface TransportChannel
Returns:
Returns the usedInternally.

setUsedInternally

public void setUsedInternally(boolean usedInternally)
Specified by:
setUsedInternally in interface TransportChannel
Parameters:
usedInternally - The usedInternally to set.

doesSupportWireFormatVersioning

public boolean doesSupportWireFormatVersioning()
Does the transport support wire format version info

Specified by:
doesSupportWireFormatVersioning in interface TransportChannel
Returns:

getCurrentWireFormatVersion

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

doesSupportMessageFragmentation

public boolean doesSupportMessageFragmentation()
some transports/wire formats will implement their own fragementation

Specified by:
doesSupportMessageFragmentation in interface TransportChannel
Returns:
true unless a transport/wire format supports it's own fragmentation

doesSupportMessageCompression

public boolean doesSupportMessageCompression()
Some transports/wireformats will not be able to understand compressed messages

Specified by:
doesSupportMessageCompression in interface TransportChannel
Returns:
true unless a transport/wire format cannot understand compression

doConsumePacket

protected void doConsumePacket(Packet packet)
consume a packet from the channel

Parameters:
packet -
Throws:
UnsupportedWireFormatException

doConsumePacket

protected void doConsumePacket(Packet packet,
                               PacketListener listener)

doHandleReceipt

protected boolean doHandleReceipt(Packet packet)

doHandleWireFormat

protected boolean doHandleWireFormat(Packet packet)

doAsyncSend

protected Packet doAsyncSend(Packet packet)
                      throws JMSException
send a Packet to the raw underlying transport This method is here to allow specific implementations to override this method

Parameters:
packet -
Returns:
a response or null
Throws:
JMSException

onAsyncException

protected void onAsyncException(JMSException e)
Handles an exception thrown while performing async dispatch of messages

Parameters:
e -

fireStatusEvent

protected void fireStatusEvent(URI remoteURI,
                               int status)
Fire status event to any status event listeners

Parameters:
remoteURI -
status -

fireStatusEvent

protected void fireStatusEvent(TransportStatusEvent event)
Fire status event to any status event listeners

Parameters:
event -

stopExecutor

protected void stopExecutor(Executor executor)
                     throws InterruptedException,
                            JMSException
A helper method to stop the execution of an executor

Parameters:
executor - the executor or null if one is not created yet
Throws:
InterruptedException
JMSException

isCachingEnabled

public boolean isCachingEnabled()
Specified by:
isCachingEnabled in interface TransportChannel
Returns:
Returns the cachingEnabled.

setCachingEnabled

public void setCachingEnabled(boolean cachingEnabled)
Specified by:
setCachingEnabled in interface TransportChannel
Parameters:
cachingEnabled - The cachingEnabled to set.

isNoDelay

public boolean isNoDelay()
Inform Transport to send messages as quickly as possible - for Tcp - this means disabling Nagles, which on OSX may provide better performance for sync sends

Specified by:
isNoDelay in interface TransportChannel
Returns:
Returns the noDelay.

setNoDelay

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


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