org/objectweb/proactive/core/UniqueID.java

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;
00032 
00033 import org.apache.log4j.Logger;
00034 import org.objectweb.proactive.core.util.log.Loggers;
00035 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00036 
00037 
00050 public class UniqueID implements java.io.Serializable {
00051     private java.rmi.server.UID id;
00052     private java.rmi.dgc.VMID vmID;
00053 
00054     //the Unique ID of the JVM
00055     private static java.rmi.dgc.VMID uniqueVMID = new java.rmi.dgc.VMID();
00056     protected static Logger logger = ProActiveLogger.getLogger(Loggers.CORE);
00057 
00058     //
00059     // -- CONSTRUCTORS -----------------------------------------------
00060     //
00061 
00065     public UniqueID() {
00066         this.id = new java.rmi.server.UID();
00067         this.vmID = uniqueVMID;
00068     }
00069 
00070     //
00071     // -- PUBLIC STATIC METHODS -----------------------------------------------
00072     //
00073 
00078     public static java.rmi.dgc.VMID getCurrentVMID() {
00079         return uniqueVMID;
00080     }
00081 
00082     //
00083     // -- PUBLIC METHODS -----------------------------------------------
00084     //
00085 
00092     public java.rmi.dgc.VMID getVMID() {
00093         return vmID;
00094     }
00095 
00100     public java.rmi.server.UID getUID() {
00101         return id;
00102     }
00103 
00108     public String toString() {
00109         if (logger.isDebugEnabled()) {
00110             return "<" +
00111             vmID.toString().substring(vmID.toString().length() - 9,
00112                 vmID.toString().length() - 6) + ">";
00113         } else {
00114             return "" + id + " " + vmID;
00115         }
00116     }
00117 
00122     public int hashCode() {
00123         return id.hashCode() + vmID.hashCode();
00124     }
00125 
00130     public boolean equals(Object o) {
00131         //System.out.println("Now checking for equality");
00132         if (o instanceof UniqueID) {
00133             return ((id.equals(((UniqueID) o).id)) &&
00134             (vmID.equals(((UniqueID) o).vmID)));
00135         } else {
00136             return false;
00137         }
00138     }
00139 
00143     public void echo() {
00144         logger.info("UniqueID The Id is " + id + " and the address is " + vmID);
00145     }
00146 }

Generated on Mon Jan 22 15:16:09 2007 for ProActive by  doxygen 1.5.1