org.objectweb.tribe.messages
Class ChannelMessage

java.lang.Object
  extended byorg.objectweb.tribe.messages.ChannelMessage
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GroupMembershipMessage, GroupMessage, PingMessage

public abstract class ChannelMessage
extends java.lang.Object
implements java.io.Serializable

This class defines a ChannelMessage.

A ChannelMessage is made of chunks, the last chunk of the message containing the destination key to be used for message routing at reception.

Version:
1.0
Author:
Emmanuel Cecchet
See Also:
Serialized Form

Constructor Summary
ChannelMessage(java.lang.Object destinationKey)
          Creates a new ChannelMessage object
ChannelMessage(java.lang.Object destinationKey, int numberOfChunks)
          Creates a new ChannelMessage object
 
Method Summary
 void addChunk(java.io.Serializable chunk)
          Adds a chunk to this message
 void deliverMessage(java.util.HashMap receiveBuffers)
          Delivers the message to all receive buffers that are registered to the message destination key.
 byte[] getByteArray()
          Get a byte array representation of the message.
 java.util.ArrayList getChunks()
          Get the whole list of chunks.
 java.lang.Object getDestinationKey()
          Defines the destination key used for message delivery at the receiving host.
 java.lang.Object removeChunk()
          Remove the last chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelMessage

public ChannelMessage(java.lang.Object destinationKey)
Creates a new ChannelMessage object

Parameters:
destinationKey - receive buffer key for message delivery

ChannelMessage

public ChannelMessage(java.lang.Object destinationKey,
                      int numberOfChunks)
Creates a new ChannelMessage object

Parameters:
destinationKey - receive buffer key for message delivery
numberOfChunks - number of chunks in the message if known in advance
Method Detail

addChunk

public void addChunk(java.io.Serializable chunk)
Adds a chunk to this message

Parameters:
chunk - the message chunk to add

getChunks

public java.util.ArrayList getChunks()
Get the whole list of chunks. Warning this is not a copy but the real message content.

Returns:
an ArrayList of chunks (Objects).

removeChunk

public java.lang.Object removeChunk()
Remove the last chunk.

Returns:
the last chunk of the chunk list or null if no more chunks are available.

getDestinationKey

public java.lang.Object getDestinationKey()
Defines the destination key used for message delivery at the receiving host. A ReceiveBuffer must has been registered with this destination key at the receiver end for the message to be delivered.

Returns:
the destination key

deliverMessage

public void deliverMessage(java.util.HashMap receiveBuffers)
                    throws NoReceiverException
Delivers the message to all receive buffers that are registered to the message destination key.

Parameters:
receiveBuffers - list of destination receive buffers
Throws:
NoReceiverException - if no receive buffer has been registered for the destination key found in the message

getByteArray

public byte[] getByteArray()
Get a byte array representation of the message. This representation is computed only once (which means that the message is serialized only once) but calls to add/remove chunks will force a recompute of the message representation.

Returns:
this message as a byte array


Copyright © 2004 - ObjectWeb Consortium - All Rights Reserved.