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

Quick Search    Search Deep

org.activemq.io.impl
Class DefaultWireFormat  view DefaultWireFormat download DefaultWireFormat.java

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

public class DefaultWireFormat
extends AbstractDefaultWireFormat
implements java.io.Serializable

This is a stateful AbstractDefaultWireFormat which implements value caching. Not optimal for use by many concurrent threads. One DefaultWireFormat is typically allocated per client connection.

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  org.activemq.io.util.WireByteArrayOutputStream cachedBytesOut
           
protected  java.io.DataOutputStream cachedDataOut
           
protected  short cachedKeyGenerator
           
(package private) static short CLEAR_CACHE
           
protected  org.activemq.io.util.WireByteArrayInputStream internalBytesIn
           
protected  org.activemq.io.util.WireByteArrayOutputStream internalBytesOut
           
protected  java.io.DataInputStream internalDataIn
           
protected  java.io.DataOutputStream internalDataOut
           
protected  short lastWriteValueCacheEvictionPosition
           
private static int MAX_CACHE_SIZE
           
(package private) static short NULL_VALUE
           
protected  java.lang.Object readMutex
           
private  java.lang.Object[] readValueCacheArray
           
private static long serialVersionUID
           
protected  java.lang.Object writeMutex
           
private  java.util.Map writeValueCache
           
private  java.lang.Object[] writeValueCacheArray
           
 
Fields inherited from class org.activemq.io.impl.AbstractDefaultWireFormat
brokerAdminCommandReader, brokerAdminCommandWriter, brokerInfoReader, brokerInfoWriter, bytesMessageReader, bytesMessageWriter, cachedValueReader, cachedValueWriter, capacityInfoReader, capacityInfoRequestReader, capacityInfoRequestWriter, capacityInfoWriter, cleanupConnectionAndSessionInfoReader, cleanupConnectionAndSessionInfoWriter, connectionInfoReader, connectionInfoWriter, consumerInfoReader, consumerInfoWriter, currentWireFormatVersion, durableUnsubscribeReader, durableUnsubscribeWriter, intReponseReceiptReader, intReponseReceiptWriter, keepAliveReader, keepAliveWriter, mapMessageReader, mapMessageWriter, messageAckReader, messageAckWriter, messageReader, messageWriter, objectMessageReader, objectMessageWriter, producerInfoReader, producerInfoWriter, receiptReader, receiptWriter, reponseReceiptReader, reponseReceiptWriter, sessionInfoReader, sessionInfoWriter, streamMessageReader, streamMessageWriter, textMessageReader, textMessageWriter, transactionInfoReader, transactionInfoWriter, WIRE_FORMAT_VERSION, wireFormatInfoReader, wireFormatInfoWriter, xaTransactionInfoReader, xaTransactionInfoWriter
 
Fields inherited from class org.activemq.io.AbstractWireFormat
cachingEnabled, transportDataIn, transportDataOut
 
Fields inherited from interface org.activemq.io.WireFormat
DEFAULT_MAXIMUM_MESSAGE_SIZE
 
Constructor Summary
DefaultWireFormat()
          Default Constructor
 
Method Summary
 org.activemq.io.WireFormat copy()
          Creates a new copy of this wire format so it can be used in another thread/context
private  java.lang.Short getNextCacheId()
           
 java.lang.Object getValueFromReadCache(short key)
           
protected  short getWriteCachedKey(java.lang.Object key)
           
protected  void handleCachedValue(org.activemq.message.CachedValue cv)
           
protected  org.activemq.message.Packet readPacket(java.io.DataInput dataIn, PacketReader reader)
           
private  java.lang.Object readResolve()
           
 byte[] toBytes(org.activemq.message.Packet packet)
          A helper method which converts a packet into a byte array Overrides the WireFormat to make use of the internal BytesOutputStream
private  void updateCachedValue(short key, java.lang.Object value)
           
protected  void validateWriteCache()
           
 org.activemq.message.Packet writePacket(org.activemq.message.Packet packet, java.io.DataOutput dataOut)
          Writes the packet to the given output stream
 
Methods inherited from class org.activemq.io.impl.AbstractDefaultWireFormat
canProcessWireFormatVersion, getCurrentWireFormatVersion, getWriter, initiateClientSideProtocol, initiateServerSideProtocol, readPacket, setCurrentWireFormatVersion
 
Methods inherited from class org.activemq.io.AbstractWireFormat
doesSupportMessageCompression, doesSupportMessageFragmentation, fromBytes, fromBytes, getTransportDataIn, getTransportDataOut, initiateClientSideProtocol, initiateServerSideProtocol, isCachingEnabled, readPacket, readPacket, registerTransportStreams, setCachingEnabled, setTransportDataIn, setTransportDataOut, writePacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

MAX_CACHE_SIZE

private static final int MAX_CACHE_SIZE
See Also:
Constant Field Values

NULL_VALUE

static final short NULL_VALUE
See Also:
Constant Field Values

CLEAR_CACHE

static final short CLEAR_CACHE
See Also:
Constant Field Values

writeMutex

protected final transient java.lang.Object writeMutex

internalBytesOut

protected transient org.activemq.io.util.WireByteArrayOutputStream internalBytesOut

internalDataOut

protected transient java.io.DataOutputStream internalDataOut

cachedBytesOut

protected transient org.activemq.io.util.WireByteArrayOutputStream cachedBytesOut

cachedDataOut

protected transient java.io.DataOutputStream cachedDataOut

writeValueCache

private java.util.Map writeValueCache

cachedKeyGenerator

protected transient short cachedKeyGenerator

lastWriteValueCacheEvictionPosition

protected transient short lastWriteValueCacheEvictionPosition

readMutex

protected final transient java.lang.Object readMutex

internalBytesIn

protected transient org.activemq.io.util.WireByteArrayInputStream internalBytesIn

internalDataIn

protected transient java.io.DataInputStream internalDataIn

writeValueCacheArray

private java.lang.Object[] writeValueCacheArray

readValueCacheArray

private java.lang.Object[] readValueCacheArray
Constructor Detail

DefaultWireFormat

public DefaultWireFormat()
Default Constructor

Method Detail

copy

public org.activemq.io.WireFormat copy()
Description copied from interface: org.activemq.io.WireFormat
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
Specified by:
copy in class AbstractDefaultWireFormat

readResolve

private java.lang.Object readResolve()
                              throws java.io.ObjectStreamException

writePacket

public org.activemq.message.Packet writePacket(org.activemq.message.Packet packet,
                                               java.io.DataOutput dataOut)
                                        throws java.io.IOException
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
Specified by:
writePacket in class AbstractDefaultWireFormat

readPacket

protected final org.activemq.message.Packet readPacket(java.io.DataInput dataIn,
                                                       PacketReader reader)
                                                throws java.io.IOException
Specified by:
readPacket in class AbstractDefaultWireFormat

toBytes

public byte[] toBytes(org.activemq.message.Packet packet)
               throws java.io.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 org.activemq.io.WireFormat
Specified by:
toBytes in class AbstractDefaultWireFormat

getValueFromReadCache

public java.lang.Object getValueFromReadCache(short key)
Specified by:
getValueFromReadCache in class AbstractDefaultWireFormat

getWriteCachedKey

protected short getWriteCachedKey(java.lang.Object key)
                           throws java.io.IOException
Specified by:
getWriteCachedKey in class AbstractDefaultWireFormat

getNextCacheId

private java.lang.Short getNextCacheId()

validateWriteCache

protected void validateWriteCache()
                           throws java.io.IOException

handleCachedValue

protected void handleCachedValue(org.activemq.message.CachedValue cv)
Specified by:
handleCachedValue in class AbstractDefaultWireFormat

updateCachedValue

private void updateCachedValue(short key,
                               java.lang.Object value)
                        throws java.io.IOException