home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / rmi / activation / ActivationGroupID.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.0 KB  |  101 lines

  1. /*
  2.  * @(#)ActivationGroupID.java    1.5 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.rmi.activation;
  16.  
  17. import java.rmi.server.UID;
  18.  
  19. /**
  20.  * The identifier for a registered activation group serves several
  21.  * purposes: <ul>
  22.  * <li>identifies the group uniquely within the activation system, and
  23.  * <li>contains a reference to the group's activation system so that the
  24.  * group can contact its activation system when necessary.</ul><p>
  25.  *
  26.  * The <code>ActivationGroupID</code> is returned from the call to
  27.  * <code>ActivationSystem.registerGroup</code> and is used to identify
  28.  * the group within the activation system. This group id is passed
  29.  * as one of the arguments to the activation group's special constructor
  30.  * when an activation group is created/recreated.
  31.  *
  32.  * @author     Ann Wollrath
  33.  * @version    1.5, 03/18/98
  34.  * @see     ActivationGroup
  35.  * @see        ActivationGroupDesc
  36.  * @since    JDK1.2
  37.  */
  38. public class ActivationGroupID implements java.io.Serializable
  39. {
  40.     /** the group's activation system */
  41.     private ActivationSystem system;
  42.     /** the group's unique id */
  43.     private UID uid = new UID();
  44.     /** indicate compatibility with JDK 1.2 version of class */
  45.     private  static final long serialVersionUID = -1648432278909740833L;
  46.  
  47.     /**
  48.      * Constructs a unique group id.
  49.      *
  50.      * @param system the group's activation system
  51.      */
  52.     public ActivationGroupID(ActivationSystem system)
  53.     {
  54.     this.system = system;
  55.     }
  56.  
  57.     /**
  58.      * Returns the group's activation system.
  59.      * @return the group's activation system
  60.      */
  61.     public ActivationSystem getSystem() 
  62.     {
  63.     return system;
  64.     }
  65.     
  66.     /**
  67.      * Returns a hashcode for the group's identifier.  Two group
  68.      * identifiers that refer to the same remote group will have the
  69.      * same hash code.
  70.      *
  71.      * @see java.util.Hashtable
  72.      */
  73.     public int hashCode() 
  74.     {
  75.     return uid.hashCode();
  76.     }
  77.  
  78.     /**
  79.      * Compares two group identifiers for content equality.
  80.      * Returns true if both of the following conditions are true:
  81.      * 1) the unique identifiers are equivalent (by content), and
  82.      * 2) the activation system specified in each
  83.      *    refers to the same remote object.
  84.      *
  85.      * @param    obj    the Object to compare with
  86.      * @return    true if these Objects are equal; false otherwise.
  87.      * @see        java.util.Hashtable
  88.      */
  89.     public boolean equals(Object obj) 
  90.     {
  91.     if (this == obj) {
  92.         return true;
  93.     } else if (obj instanceof ActivationGroupID) {
  94.         ActivationGroupID id = (ActivationGroupID)obj;
  95.         return (uid.equals(id.uid) && system.equals(id.system));
  96.     } else {
  97.         return false;
  98.     }
  99.     }
  100. }
  101.