Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.transport.stomp
Class StompWireFormat  view StompWireFormat download StompWireFormat.java

java.lang.Object
  extended byorg.activemq.transport.stomp.StompWireFormat
All Implemented Interfaces:
org.activemq.io.WireFormat

public class StompWireFormat
extends java.lang.Object
implements org.activemq.io.WireFormat

Implements the TTMP protocol.


Field Summary
private  java.util.List ackListeners
           
private  java.lang.String clientId
           
(package private) static org.activemq.util.IdGenerator clientIds
           
private  CommandParser commandParser
           
private  HeaderParser headerParser
           
private  java.io.DataInputStream in
           
(package private) static org.activemq.util.IdGenerator PACKET_IDS
           
private  EDU.oswego.cs.dl.util.concurrent.Channel pendingReadPackets
           
private  EDU.oswego.cs.dl.util.concurrent.Channel pendingWriteFrames
           
private  java.util.List receiptListeners
           
private  short sessionId
           
private  java.util.Map subscriptions
           
private  java.util.Map transactions
           
 
Fields inherited from interface org.activemq.io.WireFormat
DEFAULT_MAXIMUM_MESSAGE_SIZE
 
Constructor Summary
StompWireFormat()
           
 
Method Summary
 void addAckListener(AckListener listener)
           
(package private)  void addReceiptListener(ReceiptListener listener)
           
 void addSubscription(Subscription s)
           
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
(package private)  void clearTransactionId(java.lang.String user_tx_id)
           
 org.activemq.io.WireFormat copy()
          Creates a new copy of this wire format so it can be used in another thread/context
 boolean doesSupportMessageCompression()
          Some wire formats will not be able to understand compressed messages
 boolean doesSupportMessageFragmentation()
          some wire formats will implement their own fragementation
 void enqueuePacket(org.activemq.message.Packet ack)
           
private  void flushPendingFrames(java.io.DataOutput out)
           
 org.activemq.message.Packet fromBytes(byte[] bytes)
          Reads the packet from the given byte[]
 org.activemq.message.Packet fromBytes(byte[] bytes, int offset, int length)
          Reads the packet from the given byte[]
 java.util.List getAckListeners()
           
(package private)  java.lang.String getClientId()
           
 int getCurrentWireFormatVersion()
           
 short getSessionId()
           
 Subscription getSubscriptionFor(org.activemq.message.ActiveMQDestination destination)
           
 java.lang.String getTransactionId(java.lang.String key)
           
 void initiateClientSideProtocol()
          Some wire formats require a handshake at start-up
 void initiateServerSideProtocol()
          Some wire formats require a handshake at start-up
 boolean isCachingEnabled()
           
 org.activemq.message.Packet readPacket(java.io.DataInput in)
          Reads a packet from the given input stream
 org.activemq.message.Packet readPacket(int firstByte, java.io.DataInput in)
          A helper method for working with sockets where the first byte is read first, then the rest of the message is read.
 org.activemq.message.Packet readPacket(java.lang.String channelID, java.net.DatagramPacket dpacket)
          Read a packet from a Datagram packet from the given channelID.
 void registerTransactionId(java.lang.String user_tx_id, java.lang.String tx_id)
           
 void registerTransportStreams(java.io.DataOutputStream dataOut, java.io.DataInputStream dataIn)
          some transports may register their streams (e.g.
private  void sendError(java.lang.String message)
           
 void setCachingEnabled(boolean enableCaching)
           
 byte[] toBytes(org.activemq.message.Packet packet)
          A helper method which converts a packet into a byte array
 org.activemq.message.Packet writePacket(org.activemq.message.Packet packet, java.io.DataOutput out)
          Writes the packet to the given output stream
 java.net.DatagramPacket writePacket(java.lang.String channelID, org.activemq.message.Packet packet)
          Writes the given package to a new datagram
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKET_IDS

static final org.activemq.util.IdGenerator PACKET_IDS

clientIds

static final org.activemq.util.IdGenerator clientIds

commandParser

private CommandParser commandParser

headerParser

private HeaderParser headerParser

in

private java.io.DataInputStream in

clientId

private java.lang.String clientId

pendingReadPackets

private EDU.oswego.cs.dl.util.concurrent.Channel pendingReadPackets

pendingWriteFrames

private EDU.oswego.cs.dl.util.concurrent.Channel pendingWriteFrames

receiptListeners

private java.util.List receiptListeners

sessionId

private short sessionId

subscriptions

private java.util.Map subscriptions

ackListeners

private java.util.List ackListeners

transactions

private final java.util.Map transactions
Constructor Detail

StompWireFormat

public StompWireFormat()
Method Detail

addReceiptListener

void addReceiptListener(ReceiptListener listener)

readPacket

public org.activemq.message.Packet readPacket(java.io.DataInput in)
                                       throws java.io.IOException
Description copied from interface: org.activemq.io.WireFormat
Reads a packet from the given input stream

Specified by:
readPacket in interface org.activemq.io.WireFormat

writePacket

public org.activemq.message.Packet writePacket(org.activemq.message.Packet packet,
                                               java.io.DataOutput out)
                                        throws java.io.IOException,
                                               javax.jms.JMSException
Description copied from interface: org.activemq.io.WireFormat
Writes the packet to the given output stream

Specified by:
writePacket in interface org.activemq.io.WireFormat

flushPendingFrames

private void flushPendingFrames(java.io.DataOutput out)
                         throws java.io.IOException

sendError

private void sendError(java.lang.String message)

registerTransportStreams

public void registerTransportStreams(java.io.DataOutputStream dataOut,
                                     java.io.DataInputStream dataIn)
some transports may register their streams (e.g. Tcp)

Specified by:
registerTransportStreams in interface org.activemq.io.WireFormat

initiateServerSideProtocol

public void initiateServerSideProtocol()
                                throws java.io.IOException
Some wire formats require a handshake at start-up

Specified by:
initiateServerSideProtocol in interface org.activemq.io.WireFormat

copy

public org.activemq.io.WireFormat copy()
Creates a new copy of this wire format so it can be used in another thread/context

Specified by:
copy in interface org.activemq.io.WireFormat

initiateClientSideProtocol

public void initiateClientSideProtocol()
                                throws java.io.IOException
Some wire formats require a handshake at start-up

Specified by:
initiateClientSideProtocol in interface org.activemq.io.WireFormat

canProcessWireFormatVersion

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

Specified by:
canProcessWireFormatVersion in interface org.activemq.io.WireFormat

getCurrentWireFormatVersion

public int getCurrentWireFormatVersion()
Specified by:
getCurrentWireFormatVersion in interface org.activemq.io.WireFormat

isCachingEnabled

public boolean isCachingEnabled()
Specified by:
isCachingEnabled in interface org.activemq.io.WireFormat

setCachingEnabled

public void setCachingEnabled(boolean enableCaching)
Specified by:
setCachingEnabled in interface org.activemq.io.WireFormat

doesSupportMessageFragmentation

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

Specified by:
doesSupportMessageFragmentation in interface org.activemq.io.WireFormat

doesSupportMessageCompression

public boolean doesSupportMessageCompression()
Some wire formats will not be able to understand compressed messages

Specified by:
doesSupportMessageCompression in interface org.activemq.io.WireFormat

writePacket

public java.net.DatagramPacket writePacket(java.lang.String channelID,
                                           org.activemq.message.Packet packet)
                                    throws java.io.IOException,
                                           javax.jms.JMSException
Writes the given package to a new datagram

Specified by:
writePacket in interface org.activemq.io.WireFormat

fromBytes

public org.activemq.message.Packet fromBytes(byte[] bytes,
                                             int offset,
                                             int length)
                                      throws java.io.IOException
Reads the packet from the given byte[]

Specified by:
fromBytes in interface org.activemq.io.WireFormat

fromBytes

public org.activemq.message.Packet fromBytes(byte[] bytes)
                                      throws java.io.IOException
Reads the packet from the given byte[]

Specified by:
fromBytes in interface org.activemq.io.WireFormat

toBytes

public byte[] toBytes(org.activemq.message.Packet packet)
               throws java.io.IOException,
                      javax.jms.JMSException
A helper method which converts a packet into a byte array

Specified by:
toBytes in interface org.activemq.io.WireFormat

readPacket

public org.activemq.message.Packet readPacket(int firstByte,
                                              java.io.DataInput in)
                                       throws java.io.IOException
A helper method for working with sockets where the first byte is read first, then the rest of the message is read.

Its common when dealing with sockets to have different timeout semantics until the first non-zero byte is read of a message, after which time a zero timeout is used.

Specified by:
readPacket in interface org.activemq.io.WireFormat

readPacket

public org.activemq.message.Packet readPacket(java.lang.String channelID,
                                              java.net.DatagramPacket dpacket)
                                       throws java.io.IOException
Read a packet from a Datagram packet from the given channelID. If the packet is from the same channel ID as it was sent then we have a loop-back so discard the packet

Specified by:
readPacket in interface org.activemq.io.WireFormat

clearTransactionId

void clearTransactionId(java.lang.String user_tx_id)

getClientId

java.lang.String getClientId()

getSessionId

public short getSessionId()

addSubscription

public void addSubscription(Subscription s)

enqueuePacket

public void enqueuePacket(org.activemq.message.Packet ack)

getSubscriptionFor

public Subscription getSubscriptionFor(org.activemq.message.ActiveMQDestination destination)

addAckListener

public void addAckListener(AckListener listener)

getAckListeners

public java.util.List getAckListeners()

getTransactionId

public java.lang.String getTransactionId(java.lang.String key)

registerTransactionId

public void registerTransactionId(java.lang.String user_tx_id,
                                  java.lang.String tx_id)