org.codehaus.activemq.io.impl
Class DefaultWireFormat

java.lang.Object
  extended byorg.codehaus.activemq.io.AbstractWireFormat
      extended byorg.codehaus.activemq.io.impl.DefaultWireFormat
All Implemented Interfaces:
Serializable, WireFormat

public class DefaultWireFormat
extends AbstractWireFormat
implements Serializable

Default implementation used for Java-Java protocols. When talking to non-Java nodes we may use a different wire format.

Version:
$Revision: 1.4 $
See Also:
Serialized Form

Field Summary
static int WIRE_FORMAT_VERSION
          Current wire format version for this implementation
 
Constructor Summary
DefaultWireFormat()
          Default Constructor
 
Method Summary
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
 WireFormat copy()
          Creates a new copy of this wire format so it can be used in another thread/context
 int getCurrentWireFormatVersion()
           
 Packet readPacket(DataInput in)
          Reads a packet from the given input stream
protected  Packet readPacket(DataInput dataIn, PacketReader reader)
           
 Packet readPacket(int firstByte, DataInput dataIn)
          A helper method for working with sockets where the first byte is read first, then the rest of the message is read.
 void setCurrentWireFormatVersion(int version)
          set the current version
 byte[] toBytes(Packet packet)
          A helper method which converts a packet into a byte array Overrides the WireFormat to make use of the internal BytesOutputStream
 void writePacket(Packet packet, DataOutput dataOut)
          Write a Packet to a DataOutput
protected  void writePacket(Packet packet, DataOutput dataOut, PacketWriter writer)
           
 
Methods inherited from class org.codehaus.activemq.io.AbstractWireFormat
fromBytes, fromBytes, initiateProtocol, readPacket, writePacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIRE_FORMAT_VERSION

public static final int WIRE_FORMAT_VERSION
Current wire format version for this implementation

See Also:
Constant Field Values
Constructor Detail

DefaultWireFormat

public DefaultWireFormat()
Default Constructor

Method Detail

copy

public WireFormat copy()
Description copied from interface: WireFormat
Creates a new copy of this wire format so it can be used in another thread/context

Specified by:
copy in interface WireFormat
Returns:
new WireFormat

readPacket

public Packet readPacket(DataInput in)
                  throws IOException
Description copied from interface: WireFormat
Reads a packet from the given input stream

Specified by:
readPacket in interface WireFormat
Parameters:
in -
Returns:
Throws:
IOException

readPacket

public Packet readPacket(int firstByte,
                         DataInput dataIn)
                  throws IOException
Description copied from interface: WireFormat
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 WireFormat
Parameters:
firstByte -
dataIn -
Returns:
Throws:
IOException

writePacket

public void writePacket(Packet packet,
                        DataOutput dataOut)
                 throws IOException
Write a Packet to a DataOutput

Specified by:
writePacket in interface WireFormat
Parameters:
packet -
dataOut -
Throws:
IOException

toBytes

public byte[] toBytes(Packet packet)
               throws IOException
A helper method which converts a packet into a byte array Overrides the WireFormat to make use of the internal BytesOutputStream

Specified by:
toBytes in interface WireFormat
Overrides:
toBytes in class AbstractWireFormat
Parameters:
packet -
Returns:
a byte array representing the packet using some wire protocol
Throws:
IOException

canProcessWireFormatVersion

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

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

getCurrentWireFormatVersion

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

setCurrentWireFormatVersion

public void setCurrentWireFormatVersion(int version)
set the current version

Parameters:
version -

writePacket

protected final void writePacket(Packet packet,
                                 DataOutput dataOut,
                                 PacketWriter writer)
                          throws IOException
Throws:
IOException

readPacket

protected final Packet readPacket(DataInput dataIn,
                                  PacketReader reader)
                           throws IOException
Throws:
IOException


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