Apache Tomcat 7.0.28

org.apache.catalina.tribes
Class ByteMessage

java.lang.Object
  extended by org.apache.catalina.tribes.ByteMessage
All Implemented Interfaces:
Externalizable, Serializable

public class ByteMessage
extends Object
implements 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.

Version:
$Id: ByteMessage.java 1063816 2011-01-26 18:28:31Z markt $
Author:
Filip Hanik
See Also:
Serialized Form

Constructor Summary
ByteMessage()
          Creates an empty byte message Constructor also for deserialization
ByteMessage(byte[] data)
          Creates a byte message wit h
 
Method Summary
 byte[] getMessage()
          Returns the message contents of this byte message
 void readExternal(ObjectInput in)
           
 void setMessage(byte[] message)
          Sets the message contents of this byte message
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteMessage

public ByteMessage()
Creates an empty byte message Constructor also for deserialization


ByteMessage

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

Parameters:
data - byte[] - the message contents
Method Detail

getMessage

public byte[] getMessage()
Returns the message contents of this byte message

Returns:
byte[] - message contents, can be null

setMessage

public void setMessage(byte[] message)
Sets the message contents of this byte message

Parameters:
message - byte[]

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Specified by:
readExternal in interface Externalizable
Parameters:
in - ObjectInput
Throws:
IOException
See Also:
Externalizable.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Parameters:
out - ObjectOutput
Throws:
IOException
See Also:
Externalizable.writeExternal(java.io.ObjectOutput)

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.