org.apache.catalina.tribes.io

Class ChannelData

public class ChannelData extends Object implements ChannelMessage

The ChannelData object is used to transfer a message through the channel interceptor stack and eventually out on a transport to be sent to another node. While the message is being processed by the different interceptors, the message data can be manipulated as each interceptor seems appropriate.

Version: $Revision: 538977 $ $Date: 2007-05-17 17:43:49 +0200 (Thu, 17 May 2007) $

Author: Peter Rossbach Filip Hanik

Field Summary
static ChannelData[]EMPTY_DATA_ARRAY
static booleanUSE_SECURE_RANDOM_FOR_UUID
Constructor Summary
ChannelData()
Creates an empty channel data with a new unique Id
ChannelData(boolean generateUUID)
Create an empty channel data object
ChannelData(byte[] uniqueId, XByteBuffer message, long timestamp)
Creates a new channel data object with data
Method Summary
static StringbToS(byte[] data)
Objectclone()
Create a shallow clone, only the data gets recreated
Objectdeepclone()
Complete clone
booleanequals(Object o)
Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())
voidgenerateUUID()
Generates a UUID and invokes setUniqueId
MembergetAddress()
Returns the source or reply-to address
static ChannelDatagetDataFromPackage(XByteBuffer xbuf)
Deserializes a ChannelData object from a byte array
static ChannelDatagetDataFromPackage(byte[] b)
byte[]getDataPackage()
Serializes the ChannelData object into a byte[] array
byte[]getDataPackage(byte[] data, int offset)
intgetDataPackageLength()
XByteBuffergetMessage()
intgetOptions()
longgetTimestamp()
byte[]getUniqueId()
inthashCode()
static booleansendAckAsync(int options)
Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received but not yet processed
static booleansendAckSync(int options)
Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received and processed
voidsetAddress(Member address)
Sets the source or reply-to address
voidsetMessage(XByteBuffer message)
voidsetOptions(int options)
voidsetTimestamp(long timestamp)
voidsetUniqueId(byte[] uniqueId)
StringtoString()

Field Detail

EMPTY_DATA_ARRAY

public static ChannelData[] EMPTY_DATA_ARRAY

USE_SECURE_RANDOM_FOR_UUID

public static boolean USE_SECURE_RANDOM_FOR_UUID

Constructor Detail

ChannelData

public ChannelData()
Creates an empty channel data with a new unique Id

See Also: ChannelData

ChannelData

public ChannelData(boolean generateUUID)
Create an empty channel data object

Parameters: generateUUID boolean - if true, a unique Id will be generated

ChannelData

public ChannelData(byte[] uniqueId, XByteBuffer message, long timestamp)
Creates a new channel data object with data

Parameters: uniqueId - unique message id message - message data timestamp - message timestamp

Method Detail

bToS

public static String bToS(byte[] data)

clone

public Object clone()
Create a shallow clone, only the data gets recreated

Returns: ClusterData

deepclone

public Object deepclone()
Complete clone

Returns: ClusterData

equals

public boolean equals(Object o)
Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())

Parameters: o Object

Returns: boolean

generateUUID

public void generateUUID()
Generates a UUID and invokes setUniqueId

getAddress

public Member getAddress()
Returns the source or reply-to address

Returns: Member

getDataFromPackage

public static ChannelData getDataFromPackage(XByteBuffer xbuf)
Deserializes a ChannelData object from a byte array

Parameters: b byte[]

Returns: ChannelData

getDataFromPackage

public static ChannelData getDataFromPackage(byte[] b)

getDataPackage

public byte[] getDataPackage()
Serializes the ChannelData object into a byte[] array

Returns: byte[]

getDataPackage

public byte[] getDataPackage(byte[] data, int offset)

getDataPackageLength

public int getDataPackageLength()

getMessage

public XByteBuffer getMessage()

Returns: Returns the message byte buffer

getOptions

public int getOptions()

Returns: returns the message options see org.apache.catalina.tribes.Channel#sendMessage(org.apache.catalina.tribes.Member[], java.io.Serializable, int)

getTimestamp

public long getTimestamp()

Returns: Returns the timestamp.

getUniqueId

public byte[] getUniqueId()

Returns: Returns the uniqueId.

hashCode

public int hashCode()

sendAckAsync

public static boolean sendAckAsync(int options)
Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received but not yet processed

Parameters: options int - the options for the message

Returns: boolean

See Also: SEND_OPTIONS_USE_ACK SEND_OPTIONS_SYNCHRONIZED_ACK

sendAckSync

public static boolean sendAckSync(int options)
Utility method, returns true if the options flag indicates that an ack is to be sent after the message has been received and processed

Parameters: options int - the options for the message

Returns: boolean

See Also: SEND_OPTIONS_USE_ACK SEND_OPTIONS_SYNCHRONIZED_ACK

setAddress

public void setAddress(Member address)
Sets the source or reply-to address

Parameters: address Member

setMessage

public void setMessage(XByteBuffer message)

Parameters: message The message to send.

setOptions

public void setOptions(int options)

Parameters: sets the message options

setTimestamp

public void setTimestamp(long timestamp)

Parameters: timestamp The timestamp to send

setUniqueId

public void setUniqueId(byte[] uniqueId)

Parameters: uniqueId The uniqueId to send.

toString

public String toString()
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.