You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/05/06 02:06:58 UTC

svn commit: r400215 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java

Author: fhanik
Date: Fri May  5 17:06:56 2006
New Revision: 400215

URL: http://svn.apache.org/viewcvs?rev=400215&view=rev
Log:
added javadoc

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java?rev=400215&r1=400214&r2=400215&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ChannelData.java Fri May  5 17:06:56 2006
@@ -25,10 +25,10 @@
 import java.sql.Timestamp;
 
 /**
- * The object is used to transfer a message through the 
+ * The <code>ChannelData</code> object is used to transfer a message through the 
  * channel interceptor stack and eventually out on a transport to be sent 
- * to another node.
- * The 
+ * 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
  * @author Filip Hanik
  * @version $Revision: 377484 $ $Date: 2006-02-13 15:00:05 -0600 (Mon, 13 Feb 2006) $
@@ -37,16 +37,39 @@
 public class ChannelData implements ChannelMessage {
     public static boolean USE_SECURE_RANDOM_FOR_UUID = false;
     
+    /**
+     * The options this message was sent with
+     */
     private int options = 0 ;
+    /**
+     * The message data, stored in a dynamic buffer
+     */
     private XByteBuffer message ;
+    /**
+     * The timestamp that goes with this message
+     */
     private long timestamp ;
+    /**
+     * A unique message id
+     */
     private byte[] uniqueId ;
+    /**
+     * The source or reply-to address for this message
+     */
     private Member address;
 
+    /**
+     * Creates an empty channel data with a new unique Id
+     * @see #ChannelData(boolean)
+     */
     public ChannelData() {
         this(true);
     }
     
+    /**
+     * Create an empty channel data object
+     * @param generateUUID boolean - if true, a unique Id will be generated
+     */
     public ChannelData(boolean generateUUID) {
         if ( generateUUID ) generateUUID();
     }
@@ -54,10 +77,10 @@
     
     
     /**
-     * @param type message type (class)
-     * @param uniqueId unique message id
-     * @param message message data
-     * @param timestamp message creation date
+     * Creates a new channel data object with data
+     * @param uniqueId - unique message id
+     * @param message - message data
+     * @param timestamp - message timestamp
      */
     public ChannelData(byte[] uniqueId, XByteBuffer message, long timestamp) {
         this.uniqueId = uniqueId;
@@ -66,13 +89,13 @@
     }
     
     /**
-     * @return Returns the message.
+     * @return Returns the message byte buffer
      */
     public XByteBuffer getMessage() {
         return message;
     }
     /**
-     * @param message The message to set.
+     * @param message The message to send.
      */
     public void setMessage(XByteBuffer message) {
         this.message = message;
@@ -84,7 +107,7 @@
         return timestamp;
     }
     /**
-     * @param timestamp The timestamp to set.
+     * @param timestamp The timestamp to send
      */
     public void setTimestamp(long timestamp) {
         this.timestamp = timestamp;
@@ -96,37 +119,45 @@
         return uniqueId;
     }
     /**
-     * @param uniqueId The uniqueId to set.
+     * @param uniqueId The uniqueId to send.
      */
     public void setUniqueId(byte[] uniqueId) {
         this.uniqueId = uniqueId;
     }
     /**
-     * @return Returns the compress.
+     * @return returns the message options 
+     * see org.apache.catalina.tribes.Channel#sendMessage(org.apache.catalina.tribes.Member[], java.io.Serializable, int)
+     *                                                 
      */
     public int getOptions() {
-
         return options;
     }
     /**
-     * @param compress The compress to set.
+     * @param sets the message options
      */
     public void setOptions(int options) {
-
         this.options = options;
     }
     
+    /**
+     * Returns the source or reply-to address
+     * @return Member
+     */
     public Member getAddress() {
-
         return address;
     }
 
-
+    /**
+     * Sets the source or reply-to address
+     * @param address Member
+     */
     public void setAddress(Member address) {
-
         this.address = address;
     }
     
+    /**
+     * Generates a UUID and invokes setUniqueId
+     */
     public void generateUUID() {
         byte[] data = new byte[16];
         UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID,data,0);
@@ -134,15 +165,8 @@
     }
 
     
-    
     /**
-     * 
-    private int options = 0 ;
-    private long timestamp ;
-    private String uniqueId ;
-    private Member address;
-    private byte[] message ;
-
+     * Serializes the ChannelData object into a byte[] array
      * @return byte[]
      */
     public byte[] getDataPackage()  {
@@ -177,6 +201,11 @@
         return data;
     }
     
+    /**
+     * Deserializes a ChannelData object from a byte array
+     * @param b byte[]
+     * @return ChannelData
+     */
     public static ChannelData getDataFromPackage(byte[] b)  {
         ChannelData data = new ChannelData(false);
         int offset = 0;
@@ -204,6 +233,11 @@
         return XByteBuffer.toInt(getUniqueId(),0);
     }
     
+    /**
+     * Compares to ChannelData objects, only compares on getUniqueId().equals(o.getUniqueId())
+     * @param o Object
+     * @return boolean
+     */
     public boolean equals(Object o) {
         if ( o instanceof ChannelData ) {
             return Arrays.equals(getUniqueId(),((ChannelData)o).getUniqueId());
@@ -235,12 +269,28 @@
         return ChannelData.getDataFromPackage(d);
     }
     
+    /**
+     * Utility method, returns true if the options flag indicates that an ack
+     * is to be sent after the message has been received and processed
+     * @param options int - the options for the message
+     * @return boolean 
+     * @see org.apache.catalina.tribes.Channel#SEND_OPTIONS_USE_ACK
+     * @see org.apache.catalina.tribes.Channel#SEND_OPTIONS_SYNCHRONIZED_ACK
+     */
     public static boolean sendAckSync(int options) {
         return ( (Channel.SEND_OPTIONS_USE_ACK & options) == Channel.SEND_OPTIONS_USE_ACK) &&
             ( (Channel.SEND_OPTIONS_SYNCHRONIZED_ACK & options) == Channel.SEND_OPTIONS_SYNCHRONIZED_ACK);
     }
 
 
+    /**
+     * 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
+     * @param options int - the options for the message
+     * @return boolean 
+     * @see org.apache.catalina.tribes.Channel#SEND_OPTIONS_USE_ACK
+     * @see org.apache.catalina.tribes.Channel#SEND_OPTIONS_SYNCHRONIZED_ACK
+     */
     public static boolean sendAckAsync(int options) {
         return ( (Channel.SEND_OPTIONS_USE_ACK & options) == Channel.SEND_OPTIONS_USE_ACK) &&
             ( (Channel.SEND_OPTIONS_SYNCHRONIZED_ACK & options) != Channel.SEND_OPTIONS_SYNCHRONIZED_ACK);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org