KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > body > message > MessageImpl


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.core.body.message;
32
33 import org.objectweb.proactive.core.UniqueID;
34  
35 /**
36  * <p>
37  * Implements a simple message encapsulating a method call between two
38  * active objects.
39  * </p>
40  *
41  * @author ProActive Team
42  * @version 1.0, 2001/10/23
43  * @since ProActive 0.9
44  *
45  */

46 public class MessageImpl implements Message, java.io.Serializable JavaDoc {
47   
48     /** The name of the method called */
49     protected String JavaDoc methodName;
50   
51   /** The UniqueID of the body sending the message */
52   protected UniqueID sourceID;
53
54   /** The unique sequence number for the message */
55   protected long sequenceNumber;
56
57   /** the time the message has been issued or deserialized */
58   protected transient long timeStamp;
59
60   protected boolean isOneWay;
61  
62   protected long sessionID;
63   
64   protected boolean ciphered;
65   //
66
// -- CONSTRUCTORS -----------------------------------------------
67
//
68

69   /**
70    * Creates a new Message based on the given information.
71    * @param <code>sourceID</code> the id of the sender of this message
72    * @param <code>destinationID</code> the id of the receiver of this message
73    * @param <code>sequenceNumber</code> the unique sequence number of this message
74    * @param <code>methodName</code> the method name of the method call
75    */

76   public MessageImpl(UniqueID sourceID, long sequenceNumber, boolean isOneWay, String JavaDoc methodName) {
77     this.sourceID = sourceID;
78     this.sequenceNumber = sequenceNumber;
79     this.timeStamp = System.currentTimeMillis();
80     this.isOneWay = isOneWay;
81     this.methodName = methodName;
82   }
83
84   
85   //
86
// -- PUBLIC METHODS -----------------------------------------------
87
//
88

89
90   public String JavaDoc toString() {
91     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
92     sb.append("method=").append(methodName).append(", ");
93     sb.append("sender=").append(sourceID).append(", ");
94     sb.append("sequenceNumber=").append(sequenceNumber).append("\n");
95     return sb.toString();
96   }
97
98
99   //
100
// -- implements Message -----------------------------------------------
101
//
102

103   public UniqueID getSourceBodyID() {
104     return this.sourceID;
105   }
106
107
108   public String JavaDoc getMethodName() {
109     return methodName;
110   }
111
112
113   public long getSequenceNumber() {
114     return this.sequenceNumber;
115   }
116
117
118   public boolean isOneWay() {
119     return isOneWay;
120   }
121
122
123   public long getTimeStamp() {
124     return timeStamp;
125   }
126
127
128   private void readObject(java.io.ObjectInputStream JavaDoc s) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc {
129     s.defaultReadObject();
130       this.timeStamp = System.currentTimeMillis();
131   }
132
133  
134
135 }
136
Popular Tags