author | rriggs |
Wed, 03 May 2017 12:56:02 -0400 | |
changeset 45989 | e4f526fd8e09 |
parent 43494 | 11801b2ff456 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
/* |
|
27 |
* @author Sun Microsystems, Inc. |
|
28 |
* @build @BUILD_TAG_PLACEHOLDER@ |
|
29 |
* |
|
30 |
* @COPYRIGHT_MINI_LEGAL_NOTICE_PLACEHOLDER@ |
|
31 |
*/ |
|
32 |
||
33 |
package sun.management.jmxremote; |
|
34 |
||
45989 | 35 |
import java.io.ObjectInputFilter; |
2 | 36 |
import java.rmi.AccessException; |
37 |
import java.rmi.NotBoundException; |
|
38 |
import java.rmi.Remote; |
|
39 |
import java.rmi.RemoteException; |
|
40 |
import java.rmi.server.RMIClientSocketFactory; |
|
41 |
import java.rmi.server.RMIServerSocketFactory; |
|
42 |
||
43 |
import sun.rmi.registry.RegistryImpl; |
|
44 |
||
45 |
/** A Registry that consists of a single entry that never changes. */ |
|
46 |
public class SingleEntryRegistry extends RegistryImpl { |
|
47 |
SingleEntryRegistry(int port, String name, Remote object) |
|
48 |
throws RemoteException { |
|
49 |
super(port); |
|
50 |
this.name = name; |
|
51 |
this.object = object; |
|
52 |
} |
|
53 |
||
54 |
SingleEntryRegistry(int port, |
|
55 |
RMIClientSocketFactory csf, |
|
56 |
RMIServerSocketFactory ssf, |
|
57 |
String name, |
|
58 |
Remote object) |
|
59 |
throws RemoteException { |
|
45989 | 60 |
super(port, csf, ssf, SingleEntryRegistry::singleRegistryFilter); |
2 | 61 |
this.name = name; |
62 |
this.object = object; |
|
63 |
} |
|
64 |
||
65 |
public String[] list() { |
|
66 |
return new String[] {name}; |
|
67 |
} |
|
68 |
||
69 |
public Remote lookup(String name) throws NotBoundException { |
|
70 |
if (name.equals(this.name)) |
|
71 |
return object; |
|
72 |
throw new NotBoundException("Not bound: \"" + name + "\" (only " + |
|
73 |
"bound name is \"" + this.name + "\")"); |
|
74 |
} |
|
75 |
||
76 |
public void bind(String name, Remote obj) throws AccessException { |
|
77 |
throw new AccessException("Cannot modify this registry"); |
|
78 |
} |
|
79 |
||
80 |
public void rebind(String name, Remote obj) throws AccessException { |
|
81 |
throw new AccessException("Cannot modify this registry"); |
|
82 |
} |
|
83 |
||
84 |
public void unbind(String name) throws AccessException { |
|
85 |
throw new AccessException("Cannot modify this registry"); |
|
86 |
} |
|
87 |
||
45989 | 88 |
/** |
89 |
* ObjectInputFilter to check parameters to SingleEntryRegistry. |
|
90 |
* Since it is a read-only Registry, no classes are accepted. |
|
91 |
* String arguments are accepted without passing them to the serialFilter. |
|
92 |
* |
|
93 |
* @param info a reference to the serialization filter information |
|
94 |
* @return Status.REJECTED if parameters are out of range |
|
95 |
*/ |
|
96 |
private static ObjectInputFilter.Status singleRegistryFilter(ObjectInputFilter.FilterInfo info) { |
|
97 |
return (info.serialClass() != null || |
|
98 |
info.depth() > 2 || |
|
99 |
info.references() > 4 || |
|
100 |
info.arrayLength() >= 0) |
|
101 |
? ObjectInputFilter.Status.REJECTED |
|
102 |
: ObjectInputFilter.Status.ALLOWED; |
|
103 |
} |
|
104 |
||
2 | 105 |
private final String name; |
106 |
private final Remote object; |
|
4173
d01972926813
6895875: Missing serialVersionUID in sun.management classes
mchung
parents:
2
diff
changeset
|
107 |
|
d01972926813
6895875: Missing serialVersionUID in sun.management classes
mchung
parents:
2
diff
changeset
|
108 |
private static final long serialVersionUID = -4897238949499730950L; |
2 | 109 |
} |