org.apache.jk.core

Class Msg

Known Direct Subclasses:
MsgAjp

public abstract class Msg
extends java.lang.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.

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

Method Summary

void
appendByte(int val)
void
appendByteChunk(ByteChunk bc)
void
appendBytes(b[] , int off, int numBytes)
Copy a chunk of bytes into the packet, starting at the current write position.
void
appendBytes(MessageBytes mb)
void
appendInt(int val)
void
appendLongInt(int val)
void
dump(String msg)
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.
byte[]
getBuffer()
byte
getByte()
int
getBytes(dest[] )
Copy a chunk of bytes from the packet into an array and advance the read position past the chunk.
void
getBytes(MessageBytes mb)
int
getHeaderLength()
int
getInt()
Read an integer from packet, and advance the read position past it.
int
getLen()
int
getLongInt()
Read a 32 bits integer from packet, and advance the read position past it.
static String
hexLine(buf[] , int start, int len)
byte
peekByte()
int
peekInt()
int
processHeader()
void
reset()
Prepare this packet for accumulating a message from the container to the web server.

Method Details

appendByte

public void appendByte(int val)


appendByteChunk

public void appendByteChunk(ByteChunk bc)
            throws IOException


appendBytes

public void appendBytes(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:
off - The offset into the array at which to start copying


appendBytes

public void appendBytes(MessageBytes mb)
            throws IOException


appendInt

public void appendInt(int val)


appendLongInt

public void appendLongInt(int val)


dump

public void dump(String msg)


end

public 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 byte[] getBuffer()


getByte

public byte getByte()


getBytes

public int getBytes(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.


getBytes

public void getBytes(MessageBytes mb)


getHeaderLength

public int getHeaderLength()


getInt

public 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 int getLen()


getLongInt

public 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(buf[] ,
                             int start,
                             int len)


peekByte

public byte peekByte()


peekInt

public int peekInt()


processHeader

public int processHeader()


reset

public 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 B) 2000-2003 Apache Software Foundation. All Rights Reserved.