jdk/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 4173 d01972926813
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4173
diff changeset
     2
 * Copyright (c) 2003, 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: 4173
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: 4173
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: 4173
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4173
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4173
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @author    Sun Microsystems, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @build        @BUILD_TAG_PLACEHOLDER@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @COPYRIGHT_MINI_LEGAL_NOTICE_PLACEHOLDER@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
package sun.management.jmxremote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.rmi.AccessException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.rmi.NotBoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.rmi.RemoteException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.rmi.server.RMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.rmi.server.RMIServerSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.rmi.registry.RegistryImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/** A Registry that consists of a single entry that never changes. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class SingleEntryRegistry extends RegistryImpl {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    SingleEntryRegistry(int port, String name, Remote object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
            throws RemoteException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        super(port);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        this.object = object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    SingleEntryRegistry(int port,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                        RMIClientSocketFactory csf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                        RMIServerSocketFactory ssf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                        String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                        Remote object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            throws RemoteException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        super(port, csf, ssf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        this.object = object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public String[] list() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return new String[] {name};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public Remote lookup(String name) throws NotBoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        if (name.equals(this.name))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            return object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        throw new NotBoundException("Not bound: \"" + name + "\" (only " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                    "bound name is \"" + this.name + "\")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public void bind(String name, Remote obj) throws AccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        throw new AccessException("Cannot modify this registry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public void rebind(String name, Remote obj) throws AccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        throw new AccessException("Cannot modify this registry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public void unbind(String name) throws AccessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        throw new AccessException("Cannot modify this registry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private final String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private final Remote object;
4173
d01972926813 6895875: Missing serialVersionUID in sun.management classes
mchung
parents: 2
diff changeset
    89
d01972926813 6895875: Missing serialVersionUID in sun.management classes
mchung
parents: 2
diff changeset
    90
    private static final long serialVersionUID = -4897238949499730950L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}