FileDocCategorySizeDatePackage
ByteMessage.javaAPI DocApache Tomcat 6.0.143461Fri Jul 20 04:20:36 BST 2007org.apache.catalina.tribes

ByteMessage

public class ByteMessage extends Object implements Serializable, Externalizable
A byte message is not serialized and deserialized by the channel instead it is sent as a byte array
By default Tribes uses java serialization when it receives an object to be sent over the wire. Java serialization is not the most efficient of serializing data, and Tribes might not even have access to the correct class loaders to deserialize the object properly.
The ByteMessage class is a class where the channel when it receives it will not attempt to perform serialization, instead it will simply stream the getMessage() bytes.
If you are using multiple applications on top of Tribes you should add some sort of header so that you can decide with the ChannelListener.accept() whether this message was intended for you.
author
Filip Hanik
version
$Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
private byte[]
message
Storage for the message to be sent
Constructors Summary
public ByteMessage()
Creates an empty byte message Constructor also for deserialization

    
public ByteMessage(byte[] data)
Creates a byte message wit h

param
data byte[] - the message contents

        message = data;
    
Methods Summary
public byte[]getMessage()
Returns the message contents of this byte message

return
byte[] - message contents, can be null

        return message;
    
public voidreadExternal(java.io.ObjectInput in)

see
java.io.Externalizable#readExternal
param
in ObjectInput
throws
IOException

        int length = in.readInt();
        message = new byte[length];
        in.read(message,0,length);
    
public voidsetMessage(byte[] message)
Sets the message contents of this byte message

param
message byte[]

        this.message = message;
    
public voidwriteExternal(java.io.ObjectOutput out)

see
java.io.Externalizable#writeExternal
param
out ObjectOutput
throws
IOException

        out.writeInt(message!=null?message.length:0);
        if ( message!=null ) out.write(message,0,message.length);