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