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