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