org.apache.jk.core

Class Msg

public abstract class Msg extends Object

A single packet for communication between the web server and the container. In a more generic sense, it's the event that drives the processing chain. XXX Use Event, make Msg a particular case.

Author: Henri Gomez [hgomez@apache.org] Dan Milstein [danmil@shore.net] Keith Wannamaker [Keith@Wannamaker.org] Kevin Seguin Costin Manolache

Method Summary
abstract voidappendByte(int val)
abstract voidappendByteChunk(ByteChunk bc)
abstract voidappendBytes(MessageBytes mb)
abstract voidappendBytes(byte[] b, int off, int numBytes)
Copy a chunk of bytes into the packet, starting at the current write position.
abstract voidappendInt(int val)
abstract voidappendLongInt(int val)
abstract voiddump(String msg)
abstract voidend()
For a packet to be sent to the web server, finish the process of accumulating data and write the length of the data payload into the header.
abstract byte[]getBuffer()
abstract bytegetByte()
abstract voidgetBytes(MessageBytes mb)
abstract intgetBytes(byte[] dest)
Copy a chunk of bytes from the packet into an array and advance the read position past the chunk.
abstract intgetHeaderLength()
abstract intgetInt()
Read an integer from packet, and advance the read position past it.
abstract intgetLen()
abstract intgetLongInt()
Read a 32 bits integer from packet, and advance the read position past it.
static StringhexLine(byte[] buf, int start, int len)
abstract bytepeekByte()
abstract intpeekInt()
abstract intprocessHeader()
abstract voidreset()
Prepare this packet for accumulating a message from the container to the web server.

Method Detail

appendByte

public abstract void appendByte(int val)

appendByteChunk

public abstract void appendByteChunk(ByteChunk bc)

appendBytes

public abstract void appendBytes(MessageBytes mb)

appendBytes

public abstract void appendBytes(byte[] b, int off, int numBytes)
Copy a chunk of bytes into the packet, starting at the current write position. The chunk of bytes is encoded with the length in two bytes first, then the data itself, and finally a terminating \0 (which is not included in the encoded length).

Parameters: b The array from which to copy bytes. off The offset into the array at which to start copying numBytes The number of bytes to copy.

appendInt

public abstract void appendInt(int val)

appendLongInt

public abstract void appendLongInt(int val)

dump

public abstract void dump(String msg)

end

public abstract void end()
For a packet to be sent to the web server, finish the process of accumulating data and write the length of the data payload into the header.

getBuffer

public abstract byte[] getBuffer()

getByte

public abstract byte getByte()

getBytes

public abstract void getBytes(MessageBytes mb)

getBytes

public abstract int getBytes(byte[] dest)
Copy a chunk of bytes from the packet into an array and advance the read position past the chunk. See appendBytes() for details on the encoding.

Returns: The number of bytes copied.

getHeaderLength

public abstract int getHeaderLength()

getInt

public abstract int getInt()
Read an integer from packet, and advance the read position past it. Integers are encoded as two unsigned bytes with the high-order byte first, and, as far as I can tell, in little-endian order within each byte.

getLen

public abstract int getLen()

getLongInt

public abstract int getLongInt()
Read a 32 bits integer from packet, and advance the read position past it. Integers are encoded as four unsigned bytes with the high-order byte first, and, as far as I can tell, in little-endian order within each byte.

hexLine

public static String hexLine(byte[] buf, int start, int len)

peekByte

public abstract byte peekByte()

peekInt

public abstract int peekInt()

processHeader

public abstract int processHeader()

reset

public abstract void reset()
Prepare this packet for accumulating a message from the container to the web server. Set the write position to just after the header (but leave the length unwritten, because it is as yet unknown).
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.