1/* 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package java.rmi.activation; 27 28import java.rmi.server.UID; 29 30/** 31 * The identifier for a registered activation group serves several 32 * purposes: <ul> 33 * <li>identifies the group uniquely within the activation system, and 34 * <li>contains a reference to the group's activation system so that the 35 * group can contact its activation system when necessary.</ul><p> 36 * 37 * The <code>ActivationGroupID</code> is returned from the call to 38 * <code>ActivationSystem.registerGroup</code> and is used to identify 39 * the group within the activation system. This group id is passed 40 * as one of the arguments to the activation group's special constructor 41 * when an activation group is created/recreated. 42 * 43 * @author Ann Wollrath 44 * @see ActivationGroup 45 * @see ActivationGroupDesc 46 * @since 1.2 47 */ 48public class ActivationGroupID implements java.io.Serializable { 49 /** 50 * @serial The group's activation system. 51 */ 52 private ActivationSystem system; 53 54 /** 55 * @serial The group's unique id. 56 */ 57 private UID uid = new UID(); 58 59 /** indicate compatibility with the Java 2 SDK v1.2 version of class */ 60 private static final long serialVersionUID = -1648432278909740833L; 61 62 /** 63 * Constructs a unique group id. 64 * 65 * @param system the group's activation system 66 * @throws UnsupportedOperationException if and only if activation is 67 * not supported by this implementation 68 * @since 1.2 69 */ 70 public ActivationGroupID(ActivationSystem system) { 71 this.system = system; 72 } 73 74 /** 75 * Returns the group's activation system. 76 * @return the group's activation system 77 * @since 1.2 78 */ 79 public ActivationSystem getSystem() { 80 return system; 81 } 82 83 /** 84 * Returns a hashcode for the group's identifier. Two group 85 * identifiers that refer to the same remote group will have the 86 * same hash code. 87 * 88 * @see java.util.Hashtable 89 * @since 1.2 90 */ 91 public int hashCode() { 92 return uid.hashCode(); 93 } 94 95 /** 96 * Compares two group identifiers for content equality. 97 * Returns true if both of the following conditions are true: 98 * 1) the unique identifiers are equivalent (by content), and 99 * 2) the activation system specified in each 100 * refers to the same remote object. 101 * 102 * @param obj the Object to compare with 103 * @return true if these Objects are equal; false otherwise. 104 * @see java.util.Hashtable 105 * @since 1.2 106 */ 107 public boolean equals(Object obj) { 108 if (this == obj) { 109 return true; 110 } else if (obj instanceof ActivationGroupID) { 111 ActivationGroupID id = (ActivationGroupID)obj; 112 return (uid.equals(id.uid) && system.equals(id.system)); 113 } else { 114 return false; 115 } 116 } 117} 118