Package org.apache.catalina.tribes.io
Class ChannelData
- java.lang.Object
- 
- org.apache.catalina.tribes.io.ChannelData
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- ChannelMessage
 
 public class ChannelData extends java.lang.Object implements ChannelMessage TheChannelDataobject 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.- Author:
- Peter Rossbach
- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static ChannelData[]EMPTY_DATA_ARRAYstatic booleanUSE_SECURE_RANDOM_FOR_UUID
 - 
Constructor SummaryConstructors Constructor Description ChannelData()Creates an empty channel data with a new unique IdChannelData(boolean generateUUID)Create an empty channel data objectChannelData(byte[] uniqueId, XByteBuffer message, long timestamp)Creates a new channel data object with data
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringbToS(byte[] data)ChannelDataclone()Create a shallow clone, only the data gets recreatedjava.lang.Objectdeepclone()Complete clonebooleanequals(java.lang.Object o)Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())voidgenerateUUID()Generates a UUID and invokes setUniqueIdMembergetAddress()Returns the source or reply-to addressstatic ChannelDatagetDataFromPackage(byte[] b)static ChannelDatagetDataFromPackage(XByteBuffer xbuf)Deserializes a ChannelData object from a byte arraybyte[]getDataPackage()Serializes the ChannelData object into a byte[] arraybyte[]getDataPackage(byte[] data, int offset)intgetDataPackageLength()XByteBuffergetMessage()returns the byte buffer that contains the actual message payloadintgetOptions()The message options is a 32 bit flag set that triggers interceptors and message behavior.longgetTimestamp()Timestamp of when the message was created.byte[]getUniqueId()Each message must have a globally unique Id.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 processedstatic 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 processedvoidsetAddress(Member address)Sets the source or reply-to addressvoidsetMessage(XByteBuffer message)The byte buffer that contains the actual message payloadvoidsetOptions(int options)Sets the message options.voidsetTimestamp(long timestamp)Sets the timestamp of this message.voidsetUniqueId(byte[] uniqueId)java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
EMPTY_DATA_ARRAYpublic static final ChannelData[] EMPTY_DATA_ARRAY 
 - 
USE_SECURE_RANDOM_FOR_UUIDpublic static volatile boolean USE_SECURE_RANDOM_FOR_UUID 
 
- 
 - 
Constructor Detail- 
ChannelDatapublic ChannelData() Creates an empty channel data with a new unique Id- See Also:
- ChannelData(boolean)
 
 - 
ChannelDatapublic ChannelData(boolean generateUUID) Create an empty channel data object- Parameters:
- generateUUID- boolean - if true, a unique Id will be generated
 
 - 
ChannelDatapublic 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- 
getMessagepublic XByteBuffer getMessage() Description copied from interface:ChannelMessagereturns the byte buffer that contains the actual message payload- Specified by:
- getMessagein interface- ChannelMessage
- Returns:
- Returns the message byte buffer
 
 - 
setMessagepublic void setMessage(XByteBuffer message) Description copied from interface:ChannelMessageThe byte buffer that contains the actual message payload- Specified by:
- setMessagein interface- ChannelMessage
- Parameters:
- message- The message to send.
 
 - 
getTimestamppublic long getTimestamp() Description copied from interface:ChannelMessageTimestamp of when the message was created.- Specified by:
- getTimestampin interface- ChannelMessage
- Returns:
- Returns the timestamp.
 
 - 
setTimestamppublic void setTimestamp(long timestamp) Description copied from interface:ChannelMessageSets the timestamp of this message.- Specified by:
- setTimestampin interface- ChannelMessage
- Parameters:
- timestamp- The timestamp to send
 
 - 
getUniqueIdpublic byte[] getUniqueId() Description copied from interface:ChannelMessageEach message must have a globally unique Id. interceptors heavily depend on this id for message processing- Specified by:
- getUniqueIdin interface- ChannelMessage
- Returns:
- Returns the uniqueId.
 
 - 
setUniqueIdpublic void setUniqueId(byte[] uniqueId) - Parameters:
- uniqueId- The uniqueId to send.
 
 - 
getOptionspublic int getOptions() Description copied from interface:ChannelMessageThe message options is a 32 bit flag set that triggers interceptors and message behavior.- Specified by:
- getOptionsin interface- ChannelMessage
- Returns:
- returns the message options see org.apache.catalina.tribes.Channel#sendMessage(org.apache.catalina.tribes.Member[], java.io.Serializable, int)
- See Also:
- Channel.send(Member[], Serializable, int),- ChannelInterceptor.getOptionFlag()
 
 - 
setOptionspublic void setOptions(int options) Sets the message options.- Specified by:
- setOptionsin interface- ChannelMessage
- Parameters:
- options- the message options
- See Also:
- ChannelMessage.getOptions()
 
 - 
getAddresspublic Member getAddress() Returns the source or reply-to address- Specified by:
- getAddressin interface- ChannelMessage
- Returns:
- Member
 
 - 
setAddresspublic void setAddress(Member address) Sets the source or reply-to address- Specified by:
- setAddressin interface- ChannelMessage
- Parameters:
- address- Member
 
 - 
generateUUIDpublic void generateUUID() Generates a UUID and invokes setUniqueId
 - 
getDataPackageLengthpublic int getDataPackageLength() 
 - 
getDataPackagepublic byte[] getDataPackage() Serializes the ChannelData object into a byte[] array- Returns:
- byte[]
 
 - 
getDataPackagepublic byte[] getDataPackage(byte[] data, int offset)
 - 
getDataFromPackagepublic static ChannelData getDataFromPackage(XByteBuffer xbuf) Deserializes a ChannelData object from a byte array- Parameters:
- xbuf- byte[]
- Returns:
- ChannelData
 
 - 
getDataFromPackagepublic static ChannelData getDataFromPackage(byte[] b) 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object o) Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- Object
- Returns:
- boolean
 
 - 
clonepublic ChannelData clone() Create a shallow clone, only the data gets recreated- Specified by:
- clonein interface- ChannelMessage
- Overrides:
- clonein class- java.lang.Object
- Returns:
- ClusterData
 
 - 
deepclonepublic java.lang.Object deepclone() Complete clone- Specified by:
- deepclonein interface- ChannelMessage
- Returns:
- ClusterData
 
 - 
sendAckSyncpublic 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:
- Channel.SEND_OPTIONS_USE_ACK,- Channel.SEND_OPTIONS_SYNCHRONIZED_ACK
 
 - 
sendAckAsyncpublic 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:
- Channel.SEND_OPTIONS_USE_ACK,- Channel.SEND_OPTIONS_SYNCHRONIZED_ACK
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
bToSpublic static java.lang.String bToS(byte[] data) 
 
- 
 
-