00001 /* 00002 * ################################################################ 00003 * 00004 * ProActive: The Java(TM) library for Parallel, Distributed, 00005 * Concurrent computing with Security and Mobility 00006 * 00007 * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis 00008 * Contact: proactive@objectweb.org 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 * USA 00024 * 00025 * Initial developer(s): The ProActive Team 00026 * http://www.inria.fr/oasis/ProActive/contacts.html 00027 * Contributor(s): 00028 * 00029 * ################################################################ 00030 */ 00031 package org.objectweb.proactive.core.body.message; 00032 00033 import org.objectweb.proactive.core.UniqueID; 00034 import org.objectweb.proactive.core.body.ft.message.MessageInfo; 00035 import org.objectweb.proactive.core.body.ft.protocols.FTManager; 00036 00037 00049 public class MessageImpl implements Message, java.io.Serializable { 00050 00052 protected String methodName; 00053 00055 protected UniqueID sourceID; 00056 00058 protected long sequenceNumber; 00059 00061 protected transient long timeStamp; 00062 protected boolean isOneWay; 00063 00064 // FAULT TOLERANCE 00065 00067 protected MessageInfo messageInfos; 00068 00070 protected boolean ignoreIt; 00071 00073 protected transient FTManager ftm; 00074 00075 // 00076 // -- CONSTRUCTORS ----------------------------------------------- 00077 // 00078 00086 public MessageImpl(UniqueID sourceID, long sequenceNumber, 00087 boolean isOneWay, String methodName) { 00088 this.sourceID = sourceID; 00089 this.sequenceNumber = sequenceNumber; 00090 this.timeStamp = System.currentTimeMillis(); 00091 this.isOneWay = isOneWay; 00092 this.methodName = methodName; 00093 } 00094 00095 // 00096 // -- PUBLIC METHODS ----------------------------------------------- 00097 // 00098 public String toString() { 00099 StringBuffer sb = new StringBuffer(); 00100 sb.append("method=").append(methodName).append(", "); 00101 sb.append("sender=").append(sourceID).append(", "); 00102 sb.append("sequenceNumber=").append(sequenceNumber).append("\n"); 00103 return sb.toString(); 00104 } 00105 00106 // 00107 // -- implements Message ----------------------------------------------- 00108 // 00109 public UniqueID getSourceBodyID() { 00110 return this.sourceID; 00111 } 00112 00113 public String getMethodName() { 00114 return methodName; 00115 } 00116 00117 public long getSequenceNumber() { 00118 return this.sequenceNumber; 00119 } 00120 00121 public boolean isOneWay() { 00122 return isOneWay; 00123 } 00124 00125 public long getTimeStamp() { 00126 return timeStamp; 00127 } 00128 00129 private void readObject(java.io.ObjectInputStream s) 00130 throws java.io.IOException, ClassNotFoundException { 00131 s.defaultReadObject(); 00132 this.timeStamp = System.currentTimeMillis(); 00133 } 00134 00135 // FAULT-TOLERANCE 00136 public MessageInfo getMessageInfo() { 00137 return this.messageInfos; 00138 } 00139 00140 public void setMessageInfo(MessageInfo mi) { 00141 this.messageInfos = mi; 00142 } 00143 00144 public boolean ignoreIt() { 00145 return this.ignoreIt; 00146 } 00147 00148 public void setIgnoreIt(boolean ignore) { 00149 this.ignoreIt = ignore; 00150 } 00151 00152 public void setFTManager(FTManager ft) { 00153 this.ftm = ft; 00154 } 00155 00156 public FTManager getFTManager() { 00157 return this.ftm; 00158 } 00159 }