History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/java/rmi/registry (8 of 18352 files). Show all

Unified · Split

8 files
  1. java/pkg/java/rmi/registry/LocateRegistry.class +0 −0
  2. java/pkg/java/rmi/registry/LocateRegistry.java +241 −0
  3. java/pkg/java/rmi/registry/Registry.class +0 −0
  4. java/pkg/java/rmi/registry/Registry.java +192 −0
  5. java/pkg/java/rmi/registry/RegistryHandler.class +0 −0
  6. java/pkg/java/rmi/registry/RegistryHandler.java +73 −0
  7. java/pkg/java/rmi/registry/mkfile +10 −0
  8. java/pkg/java/rmi/registry/package.html +57 −0
java/pkg/java/rmi/registry/LocateRegistry.class+0−0

Binary file not shown.

java/pkg/java/rmi/registry/LocateRegistry.java+241−0
@@ -0,0 +1,241 @@
1/*
2 * Copyright (c) 1996, 2003, 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.registry;
27
28import java.rmi.RemoteException;
29import java.rmi.server.ObjID;
30import java.rmi.server.RMIClientSocketFactory;
31import java.rmi.server.RMIServerSocketFactory;
32import java.rmi.server.RemoteRef;
33import java.rmi.server.UnicastRemoteObject;
34import sun.rmi.registry.RegistryImpl;
35import sun.rmi.server.UnicastRef2;
36import sun.rmi.server.UnicastRef;
37import sun.rmi.server.Util;
38import sun.rmi.transport.LiveRef;
39import sun.rmi.transport.tcp.TCPEndpoint;
40
41/**
42 * <code>LocateRegistry</code> is used to obtain a reference to a bootstrap
43 * remote object registry on a particular host (including the local host), or
44 * to create a remote object registry that accepts calls on a specific port.
45 *
46 * <p> Note that a <code>getRegistry</code> call does not actually make a
47 * connection to the remote host. It simply creates a local reference to
48 * the remote registry and will succeed even if no registry is running on
49 * the remote host. Therefore, a subsequent method invocation to a remote
50 * registry returned as a result of this method may fail.
51 *
52 * @author Ann Wollrath
53 * @author Peter Jones
54 * @since JDK1.1
55 * @see java.rmi.registry.Registry
56 */
57public final class LocateRegistry {
58
59 /**
60 * Private constructor to disable public construction.
61 */
62 private LocateRegistry() {}
63
64 /**
65 * Returns a reference to the the remote object <code>Registry</code> for
66 * the local host on the default registry port of 1099.
67 *
68 * @return reference (a stub) to the remote object registry
69 * @exception RemoteException if the reference could not be created
70 * @since JDK1.1
71 */
72 public static Registry getRegistry()
73 throws RemoteException
74 {
75 return getRegistry(null, Registry.REGISTRY_PORT);
76 }
77
78 /**
79 * Returns a reference to the the remote object <code>Registry</code> for
80 * the local host on the specified <code>port</code>.
81 *
82 * @param port port on which the registry accepts requests
83 * @return reference (a stub) to the remote object registry
84 * @exception RemoteException if the reference could not be created
85 * @since JDK1.1
86 */
87 public static Registry getRegistry(int port)
88 throws RemoteException
89 {
90 return getRegistry(null, port);
91 }
92
93 /**
94 * Returns a reference to the remote object <code>Registry</code> on the
95 * specified <code>host</code> on the default registry port of 1099. If
96 * <code>host</code> is <code>null</code>, the local host is used.
97 *
98 * @param host host for the remote registry
99 * @return reference (a stub) to the remote object registry
100 * @exception RemoteException if the reference could not be created
101 * @since JDK1.1
102 */
103 public static Registry getRegistry(String host)
104 throws RemoteException
105 {
106 return getRegistry(host, Registry.REGISTRY_PORT);
107 }
108
109 /**
110 * Returns a reference to the remote object <code>Registry</code> on the
111 * specified <code>host</code> and <code>port</code>. If <code>host</code>
112 * is <code>null</code>, the local host is used.
113 *
114 * @param host host for the remote registry
115 * @param port port on which the registry accepts requests
116 * @return reference (a stub) to the remote object registry
117 * @exception RemoteException if the reference could not be created
118 * @since JDK1.1
119 */
120 public static Registry getRegistry(String host, int port)
121 throws RemoteException
122 {
123 return getRegistry(host, port, null);
124 }
125
126 /**
127 * Returns a locally created remote reference to the remote object
128 * <code>Registry</code> on the specified <code>host</code> and
129 * <code>port</code>. Communication with this remote registry will
130 * use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
131 * to create <code>Socket</code> connections to the registry on the
132 * remote <code>host</code> and <code>port</code>.
133 *
134 * @param host host for the remote registry
135 * @param port port on which the registry accepts requests
136 * @param csf client-side <code>Socket</code> factory used to
137 * make connections to the registry. If <code>csf</code>
138 * is null, then the default client-side <code>Socket</code>
139 * factory will be used in the registry stub.
140 * @return reference (a stub) to the remote registry
141 * @exception RemoteException if the reference could not be created
142 * @since 1.2
143 */
144 public static Registry getRegistry(String host, int port,
145 RMIClientSocketFactory csf)
146 throws RemoteException
147 {
148 Registry registry = null;
149
150 if (port <= 0)
151 port = Registry.REGISTRY_PORT;
152
153 if (host == null || host.length() == 0) {
154 // If host is blank (as returned by "file:" URL in 1.0.2 used in
155 // java.rmi.Naming), try to convert to real local host name so
156 // that the RegistryImpl's checkAccess will not fail.
157 try {
158 host = java.net.InetAddress.getLocalHost().getHostAddress();
159 } catch (Exception e) {
160 // If that failed, at least try "" (localhost) anyway...
161 host = "";
162 }
163 }
164
165 /*
166 * Create a proxy for the registry with the given host, port, and
167 * client socket factory. If the supplied client socket factory is
168 * null, then the ref type is a UnicastRef, otherwise the ref type
169 * is a UnicastRef2. If the property
170 * java.rmi.server.ignoreStubClasses is true, then the proxy
171 * returned is an instance of a dynamic proxy class that implements
172 * the Registry interface; otherwise the proxy returned is an
173 * instance of the pregenerated stub class for RegistryImpl.
174 **/
175 LiveRef liveRef =
176 new LiveRef(new ObjID(ObjID.REGISTRY_ID),
177 new TCPEndpoint(host, port, csf, null),
178 false);
179 RemoteRef ref =
180 (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);
181
182 return (Registry) Util.createProxy(RegistryImpl.class, ref, false);
183 }
184
185 /**
186 * Creates and exports a <code>Registry</code> instance on the local
187 * host that accepts requests on the specified <code>port</code>.
188 *
189 * <p>The <code>Registry</code> instance is exported as if the static
190 * {@link UnicastRemoteObject#exportObject(Remote,int)
191 * UnicastRemoteObject.exportObject} method is invoked, passing the
192 * <code>Registry</code> instance and the specified <code>port</code> as
193 * arguments, except that the <code>Registry</code> instance is
194 * exported with a well-known object identifier, an {@link ObjID}
195 * instance constructed with the value {@link ObjID#REGISTRY_ID}.
196 *
197 * @param port the port on which the registry accepts requests
198 * @return the registry
199 * @exception RemoteException if the registry could not be exported
200 * @since JDK1.1
201 **/
202 public static Registry createRegistry(int port) throws RemoteException {
203 return new RegistryImpl(port);
204 }
205
206 /**
207 * Creates and exports a <code>Registry</code> instance on the local
208 * host that uses custom socket factories for communication with that
209 * instance. The registry that is created listens for incoming
210 * requests on the given <code>port</code> using a
211 * <code>ServerSocket</code> created from the supplied
212 * <code>RMIServerSocketFactory</code>.
213 *
214 * <p>The <code>Registry</code> instance is exported as if
215 * the static {@link
216 * UnicastRemoteObject#exportObject(Remote,int,RMIClientSocketFactory,RMIServerSocketFactory)
217 * UnicastRemoteObject.exportObject} method is invoked, passing the
218 * <code>Registry</code> instance, the specified <code>port</code>, the
219 * specified <code>RMIClientSocketFactory</code>, and the specified
220 * <code>RMIServerSocketFactory</code> as arguments, except that the
221 * <code>Registry</code> instance is exported with a well-known object
222 * identifier, an {@link ObjID} instance constructed with the value
223 * {@link ObjID#REGISTRY_ID}.
224 *
225 * @param port port on which the registry accepts requests
226 * @param csf client-side <code>Socket</code> factory used to
227 * make connections to the registry
228 * @param ssf server-side <code>ServerSocket</code> factory
229 * used to accept connections to the registry
230 * @return the registry
231 * @exception RemoteException if the registry could not be exported
232 * @since 1.2
233 **/
234 public static Registry createRegistry(int port,
235 RMIClientSocketFactory csf,
236 RMIServerSocketFactory ssf)
237 throws RemoteException
238 {
239 return new RegistryImpl(port, csf, ssf);
240 }
241}
java/pkg/java/rmi/registry/Registry.class+0−0

Binary file not shown.

java/pkg/java/rmi/registry/Registry.java+192−0
@@ -0,0 +1,192 @@
1/*
2 * Copyright (c) 1996, 2001, 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 */
25package java.rmi.registry;
26
27import java.rmi.AccessException;
28import java.rmi.AlreadyBoundException;
29import java.rmi.NotBoundException;
30import java.rmi.Remote;
31import java.rmi.RemoteException;
32
33/**
34 * <code>Registry</code> is a remote interface to a simple remote
35 * object registry that provides methods for storing and retrieving
36 * remote object references bound with arbitrary string names. The
37 * <code>bind</code>, <code>unbind</code>, and <code>rebind</code>
38 * methods are used to alter the name bindings in the registry, and
39 * the <code>lookup</code> and <code>list</code> methods are used to
40 * query the current name bindings.
41 *
42 * <p>In its typical usage, a <code>Registry</code> enables RMI client
43 * bootstrapping: it provides a simple means for a client to obtain an
44 * initial reference to a remote object. Therefore, a registry's
45 * remote object implementation is typically exported with a
46 * well-known address, such as with a well-known {@link
47 * java.rmi.server.ObjID#REGISTRY_ID ObjID} and TCP port number
48 * (default is {@link #REGISTRY_PORT 1099}).
49 *
50 * <p>The {@link LocateRegistry} class provides a programmatic API for
51 * constructing a bootstrap reference to a <code>Registry</code> at a
52 * remote address (see the static <code>getRegistry</code> methods)
53 * and for creating and exporting a <code>Registry</code> in the
54 * current VM on a particular local address (see the static
55 * <code>createRegistry</code> methods).
56 *
57 * <p>A <code>Registry</code> implementation may choose to restrict
58 * access to some or all of its methods (for example, methods that
59 * mutate the registry's bindings may be restricted to calls
60 * originating from the local host). If a <code>Registry</code>
61 * method chooses to deny access for a given invocation, its
62 * implementation may throw {@link java.rmi.AccessException}, which
63 * (because it extends {@link java.rmi.RemoteException}) will be
64 * wrapped in a {@link java.rmi.ServerException} when caught by a
65 * remote client.
66 *
67 * <p>The names used for bindings in a <code>Registry</code> are pure
68 * strings, not parsed. A service which stores its remote reference
69 * in a <code>Registry</code> may wish to use a package name as a
70 * prefix in the name binding to reduce the likelihood of name
71 * collisions in the registry.
72 *
73 * @author Ann Wollrath
74 * @author Peter Jones
75 * @since JDK1.1
76 * @see LocateRegistry
77 */
78public interface Registry extends Remote {
79
80 /** Well known port for registry. */
81 public static final int REGISTRY_PORT = 1099;
82
83 /**
84 * Returns the remote reference bound to the specified
85 * <code>name</code> in this registry.
86 *
87 * @param name the name for the remote reference to look up
88 *
89 * @return a reference to a remote object
90 *
91 * @throws NotBoundException if <code>name</code> is not currently bound
92 *
93 * @throws RemoteException if remote communication with the
94 * registry failed; if exception is a <code>ServerException</code>
95 * containing an <code>AccessException</code>, then the registry
96 * denies the caller access to perform this operation
97 *
98 * @throws AccessException if this registry is local and it denies
99 * the caller access to perform this operation
100 *
101 * @throws NullPointerException if <code>name</code> is <code>null</code>
102 */
103 public Remote lookup(String name)
104 throws RemoteException, NotBoundException, AccessException;
105
106 /**
107 * Binds a remote reference to the specified <code>name</code> in
108 * this registry.
109 *
110 * @param name the name to associate with the remote reference
111 * @param obj a reference to a remote object (usually a stub)
112 *
113 * @throws AlreadyBoundException if <code>name</code> is already bound
114 *
115 * @throws RemoteException if remote communication with the
116 * registry failed; if exception is a <code>ServerException</code>
117 * containing an <code>AccessException</code>, then the registry
118 * denies the caller access to perform this operation (if
119 * originating from a non-local host, for example)
120 *
121 * @throws AccessException if this registry is local and it denies
122 * the caller access to perform this operation
123 *
124 * @throws NullPointerException if <code>name</code> is
125 * <code>null</code>, or if <code>obj</code> is <code>null</code>
126 */
127 public void bind(String name, Remote obj)
128 throws RemoteException, AlreadyBoundException, AccessException;
129
130 /**
131 * Removes the binding for the specified <code>name</code> in
132 * this registry.
133 *
134 * @param name the name of the binding to remove
135 *
136 * @throws NotBoundException if <code>name</code> is not currently bound
137 *
138 * @throws RemoteException if remote communication with the
139 * registry failed; if exception is a <code>ServerException</code>
140 * containing an <code>AccessException</code>, then the registry
141 * denies the caller access to perform this operation (if
142 * originating from a non-local host, for example)
143 *
144 * @throws AccessException if this registry is local and it denies
145 * the caller access to perform this operation
146 *
147 * @throws NullPointerException if <code>name</code> is <code>null</code>
148 */
149 public void unbind(String name)
150 throws RemoteException, NotBoundException, AccessException;
151
152 /**
153 * Replaces the binding for the specified <code>name</code> in
154 * this registry with the supplied remote reference. If there is
155 * an existing binding for the specified <code>name</code>, it is
156 * discarded.
157 *
158 * @param name the name to associate with the remote reference
159 * @param obj a reference to a remote object (usually a stub)
160 *
161 * @throws RemoteException if remote communication with the
162 * registry failed; if exception is a <code>ServerException</code>
163 * containing an <code>AccessException</code>, then the registry
164 * denies the caller access to perform this operation (if
165 * originating from a non-local host, for example)
166 *
167 * @throws AccessException if this registry is local and it denies
168 * the caller access to perform this operation
169 *
170 * @throws NullPointerException if <code>name</code> is
171 * <code>null</code>, or if <code>obj</code> is <code>null</code>
172 */
173 public void rebind(String name, Remote obj)
174 throws RemoteException, AccessException;
175
176 /**
177 * Returns an array of the names bound in this registry. The
178 * array will contain a snapshot of the names bound in this
179 * registry at the time of the given invocation of this method.
180 *
181 * @return an array of the names bound in this registry
182 *
183 * @throws RemoteException if remote communication with the
184 * registry failed; if exception is a <code>ServerException</code>
185 * containing an <code>AccessException</code>, then the registry
186 * denies the caller access to perform this operation
187 *
188 * @throws AccessException if this registry is local and it denies
189 * the caller access to perform this operation
190 */
191 public String[] list() throws RemoteException, AccessException;
192}
java/pkg/java/rmi/registry/RegistryHandler.class+0−0

Binary file not shown.

java/pkg/java/rmi/registry/RegistryHandler.java+73−0
@@ -0,0 +1,73 @@
1/*
2 * Copyright (c) 1997, 2004, 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.registry;
27
28import java.rmi.RemoteException;
29import java.rmi.UnknownHostException;
30
31/**
32 * <code>RegistryHandler</code> is an interface used internally by the RMI
33 * runtime in previous implementation versions. It should never be accessed
34 * by application code.
35 *
36 * @author Ann Wollrath
37 * @since JDK1.1
38 * @deprecated no replacement
39 */
40@Deprecated
41public interface RegistryHandler {
42
43 /**
44 * Returns a "stub" for contacting a remote registry
45 * on the specified host and port.
46 *
47 * @deprecated no replacement. As of the Java 2 platform v1.2, RMI no
48 * longer uses the <code>RegistryHandler</code> to obtain the registry's
49 * stub.
50 * @param host name of remote registry host
51 * @param port remote registry port
52 * @return remote registry stub
53 * @throws RemoteException if a remote error occurs
54 * @throws UnknownHostException if unable to resolve given hostname
55 */
56 @Deprecated
57 Registry registryStub(String host, int port)
58 throws RemoteException, UnknownHostException;
59
60 /**
61 * Constructs and exports a Registry on the specified port.
62 * The port must be non-zero.
63 *
64 * @deprecated no replacement. As of the Java 2 platform v1.2, RMI no
65 * longer uses the <code>RegistryHandler</code> to obtain the registry's
66 * implementation.
67 * @param port port to export registry on
68 * @return registry stub
69 * @throws RemoteException if a remote error occurs
70 */
71 @Deprecated
72 Registry registryImpl(int port) throws RemoteException;
73}
java/pkg/java/rmi/registry/mkfile+10−0
@@ -0,0 +1,10 @@
1<../../../../../mkconfig
2
3TARG=\
4 LocateRegistry.dis\
5 Registry.dis\
6 RegistryHandler.dis\
7
8DISBIN=$ROOT/java/dis/java/java/java/rmi/registry
9
10<$ROOT/mkfiles/mkjava
java/pkg/java/rmi/registry/package.html+57−0
@@ -0,0 +1,57 @@
1<!--
2 Copyright (c) 1998, 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
26<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
27<html>
28</head>
29<body bgcolor="white">
30
31Provides a class and two interfaces for the RMI registry.
32A registry is a remote object that maps names to remote objects. A
33server registers its remote objects with the registry so that they can
34be looked up. When an object wants to invoke a method on a remote
35object, it must first lookup the remote object using its name. The
36registry returns to the calling object a reference to the remote
37object, using which a remote method can be invoked.
38
39<!--
40<h2>Package Specification</h2>
41
42##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
43<ul>
44 <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
45</ul>
46
47<h2>Related Documentation</h2>
48
49For overviews, tutorials, examples, guides, and tool documentation, please see:
50<ul>
51 <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
52</ul>
53-->
54
55@since JDK1.1
56</body>
57</html>