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 (153 of 18352 files). Show all

Unified · Split

153 files
  1. java/pkg/java/rmi/AccessException.class +0 −0
  2. java/pkg/java/rmi/AccessException.java +70 −0
  3. java/pkg/java/rmi/AlreadyBoundException.class +0 −0
  4. java/pkg/java/rmi/AlreadyBoundException.java +62 −0
  5. java/pkg/java/rmi/ConnectException.class +0 −0
  6. java/pkg/java/rmi/ConnectException.java +62 −0
  7. java/pkg/java/rmi/ConnectIOException.class +0 −0
  8. java/pkg/java/rmi/ConnectIOException.java +64 −0
  9. java/pkg/java/rmi/MarshalException.class +0 −0
  10. java/pkg/java/rmi/MarshalException.java +71 −0
  11. java/pkg/java/rmi/MarshalledObject$MarshalledObjectInputStream.class +0 −0
  12. java/pkg/java/rmi/MarshalledObject$MarshalledObjectOutputStream.class +0 −0
  13. java/pkg/java/rmi/MarshalledObject.class +0 −0
  14. java/pkg/java/rmi/MarshalledObject.java +316 −0
  15. java/pkg/java/rmi/Naming$ParsedNamingURL.class +0 −0
  16. java/pkg/java/rmi/Naming.class +0 −0
  17. java/pkg/java/rmi/Naming.java +356 −0
  18. java/pkg/java/rmi/NoSuchObjectException.class +0 −0
  19. java/pkg/java/rmi/NoSuchObjectException.java +62 −0
  20. java/pkg/java/rmi/NotBoundException.class +0 −0
  21. java/pkg/java/rmi/NotBoundException.java +64 −0
  22. java/pkg/java/rmi/RMISecurityException.class +0 −0
  23. java/pkg/java/rmi/RMISecurityException.java +67 −0
  24. java/pkg/java/rmi/RMISecurityManager.class +0 −0
  25. java/pkg/java/rmi/RMISecurityManager.java +64 −0
  26. java/pkg/java/rmi/Remote.class +0 −0
  27. java/pkg/java/rmi/Remote.java +50 −0
  28. java/pkg/java/rmi/RemoteException.class +0 −0
  29. java/pkg/java/rmi/RemoteException.java +122 −0
  30. java/pkg/java/rmi/ServerError.class +0 −0
  31. java/pkg/java/rmi/ServerError.java +56 −0
  32. java/pkg/java/rmi/ServerException.class +0 −0
  33. java/pkg/java/rmi/ServerException.java +67 −0
  34. java/pkg/java/rmi/ServerRuntimeException.class +0 −0
  35. java/pkg/java/rmi/ServerRuntimeException.java +65 −0
  36. java/pkg/java/rmi/StubNotFoundException.class +0 −0
  37. java/pkg/java/rmi/StubNotFoundException.java +67 −0
  38. java/pkg/java/rmi/UnexpectedException.class +0 −0
  39. java/pkg/java/rmi/UnexpectedException.java +64 −0
  40. java/pkg/java/rmi/UnknownHostException.class +0 −0
  41. java/pkg/java/rmi/UnknownHostException.java +62 −0
  42. java/pkg/java/rmi/UnmarshalException.class +0 −0
  43. java/pkg/java/rmi/UnmarshalException.java +76 −0
  44. java/pkg/java/rmi/activation/Activatable.class +0 −0
  45. java/pkg/java/rmi/activation/Activatable.java +555 −0
  46. java/pkg/java/rmi/activation/ActivateFailedException.class +0 −0
  47. java/pkg/java/rmi/activation/ActivateFailedException.java +62 −0
  48. java/pkg/java/rmi/activation/ActivationDesc.class +0 −0
  49. java/pkg/java/rmi/activation/ActivationDesc.java +339 −0
  50. java/pkg/java/rmi/activation/ActivationException.class +0 −0
  51. java/pkg/java/rmi/activation/ActivationException.java +118 −0
  52. java/pkg/java/rmi/activation/ActivationGroup.class +0 −0
  53. java/pkg/java/rmi/activation/ActivationGroup.java +528 −0
  54. java/pkg/java/rmi/activation/ActivationGroupDesc$CommandEnvironment.class +0 −0
  55. java/pkg/java/rmi/activation/ActivationGroupDesc.class +0 −0
  56. java/pkg/java/rmi/activation/ActivationGroupDesc.java +370 −0
  57. java/pkg/java/rmi/activation/ActivationGroupID.class +0 −0
  58. java/pkg/java/rmi/activation/ActivationGroupID.java +115 −0
  59. java/pkg/java/rmi/activation/ActivationID.class +0 −0
  60. java/pkg/java/rmi/activation/ActivationID.java +290 −0
  61. java/pkg/java/rmi/activation/ActivationInstantiator.class +0 −0
  62. java/pkg/java/rmi/activation/ActivationInstantiator.java +76 −0
  63. java/pkg/java/rmi/activation/ActivationMonitor.class +0 −0
  64. java/pkg/java/rmi/activation/ActivationMonitor.java +108 −0
  65. java/pkg/java/rmi/activation/ActivationSystem.class +0 −0
  66. java/pkg/java/rmi/activation/ActivationSystem.java +229 −0
  67. java/pkg/java/rmi/activation/Activator.class +0 −0
  68. java/pkg/java/rmi/activation/Activator.java +114 −0
  69. java/pkg/java/rmi/activation/UnknownGroupException.class +0 −0
  70. java/pkg/java/rmi/activation/UnknownGroupException.java +60 −0
  71. java/pkg/java/rmi/activation/UnknownObjectException.class +0 −0
  72. java/pkg/java/rmi/activation/UnknownObjectException.java +62 −0
  73. java/pkg/java/rmi/activation/mkfile +21 −0
  74. java/pkg/java/rmi/activation/package.html +52 −0
  75. java/pkg/java/rmi/dgc/DGC.class +0 −0
  76. java/pkg/java/rmi/dgc/DGC.java +115 −0
  77. java/pkg/java/rmi/dgc/Lease.class +0 −0
  78. java/pkg/java/rmi/dgc/Lease.java +77 −0
  79. java/pkg/java/rmi/dgc/VMID$1.class +0 −0
  80. java/pkg/java/rmi/dgc/VMID.class +0 −0
  81. java/pkg/java/rmi/dgc/VMID.java +177 −0
  82. java/pkg/java/rmi/dgc/mkfile +10 −0
  83. java/pkg/java/rmi/dgc/package.html +55 −0
  84. java/pkg/java/rmi/mkfile +34 −0
  85. java/pkg/java/rmi/package.html +59 −0
  86. java/pkg/java/rmi/registry/LocateRegistry.class +0 −0
  87. java/pkg/java/rmi/registry/LocateRegistry.java +241 −0
  88. java/pkg/java/rmi/registry/Registry.class +0 −0
  89. java/pkg/java/rmi/registry/Registry.java +192 −0
  90. java/pkg/java/rmi/registry/RegistryHandler.class +0 −0
  91. java/pkg/java/rmi/registry/RegistryHandler.java +73 −0
  92. java/pkg/java/rmi/registry/mkfile +10 −0
  93. java/pkg/java/rmi/registry/package.html +57 −0
  94. java/pkg/java/rmi/server/ExportException.class +0 −0
  95. java/pkg/java/rmi/server/ExportException.java +68 −0
  96. java/pkg/java/rmi/server/LoaderHandler.class +0 −0
  97. java/pkg/java/rmi/server/LoaderHandler.java +95 −0
  98. java/pkg/java/rmi/server/LogStream.class +0 −0
  99. java/pkg/java/rmi/server/LogStream.java +265 −0
  100. java/pkg/java/rmi/server/ObjID.class +0 −0
  101. java/pkg/java/rmi/server/ObjID.java +248 −0
  102. java/pkg/java/rmi/server/Operation.class +0 −0
  103. java/pkg/java/rmi/server/Operation.java +73 −0
  104. java/pkg/java/rmi/server/RMIClassLoader$1.class +0 −0
  105. java/pkg/java/rmi/server/RMIClassLoader$2.class +0 −0
  106. java/pkg/java/rmi/server/RMIClassLoader.class +0 −0
  107. java/pkg/java/rmi/server/RMIClassLoader.java +722 −0
  108. java/pkg/java/rmi/server/RMIClassLoaderSpi.class +0 −0
  109. java/pkg/java/rmi/server/RMIClassLoaderSpi.java +192 −0
  110. java/pkg/java/rmi/server/RMIClientSocketFactory.class +0 −0
  111. java/pkg/java/rmi/server/RMIClientSocketFactory.java +74 −0
  112. java/pkg/java/rmi/server/RMIFailureHandler.class +0 −0
  113. java/pkg/java/rmi/server/RMIFailureHandler.java +60 −0
  114. java/pkg/java/rmi/server/RMIServerSocketFactory.class +0 −0
  115. java/pkg/java/rmi/server/RMIServerSocketFactory.java +74 −0
  116. java/pkg/java/rmi/server/RMISocketFactory.class +0 −0
  117. java/pkg/java/rmi/server/RMISocketFactory.java +188 −0
  118. java/pkg/java/rmi/server/RemoteCall.class +0 −0
  119. java/pkg/java/rmi/server/RemoteCall.java +132 −0
  120. java/pkg/java/rmi/server/RemoteObject.class +0 −0
  121. java/pkg/java/rmi/server/RemoteObject.java +458 −0
  122. java/pkg/java/rmi/server/RemoteObjectInvocationHandler$MethodToHash_Maps$1.class +0 −0
  123. java/pkg/java/rmi/server/RemoteObjectInvocationHandler$MethodToHash_Maps.class +0 −0
  124. java/pkg/java/rmi/server/RemoteObjectInvocationHandler.class +0 −0
  125. java/pkg/java/rmi/server/RemoteObjectInvocationHandler.java +283 −0
  126. java/pkg/java/rmi/server/RemoteRef.class +0 −0
  127. java/pkg/java/rmi/server/RemoteRef.java +195 −0
  128. java/pkg/java/rmi/server/RemoteServer.class +0 −0
  129. java/pkg/java/rmi/server/RemoteServer.java +115 −0
  130. java/pkg/java/rmi/server/RemoteStub.class +0 −0
  131. java/pkg/java/rmi/server/RemoteStub.java +74 −0
  132. java/pkg/java/rmi/server/ServerCloneException.class +0 −0
  133. java/pkg/java/rmi/server/ServerCloneException.java +112 −0
  134. java/pkg/java/rmi/server/ServerNotActiveException.class +0 −0
  135. java/pkg/java/rmi/server/ServerNotActiveException.java +61 −0
  136. java/pkg/java/rmi/server/ServerRef.class +0 −0
  137. java/pkg/java/rmi/server/ServerRef.java +66 −0
  138. java/pkg/java/rmi/server/Skeleton.class +0 −0
  139. java/pkg/java/rmi/server/Skeleton.java +70 −0
  140. java/pkg/java/rmi/server/SkeletonMismatchException.class +0 −0
  141. java/pkg/java/rmi/server/SkeletonMismatchException.java +62 −0
  142. java/pkg/java/rmi/server/SkeletonNotFoundException.class +0 −0
  143. java/pkg/java/rmi/server/SkeletonNotFoundException.java +68 −0
  144. java/pkg/java/rmi/server/SocketSecurityException.class +0 −0
  145. java/pkg/java/rmi/server/SocketSecurityException.java +62 −0
  146. java/pkg/java/rmi/server/UID.class +0 −0
  147. java/pkg/java/rmi/server/UID.java +267 −0
  148. java/pkg/java/rmi/server/UnicastRemoteObject.class +0 −0
  149. java/pkg/java/rmi/server/UnicastRemoteObject.java +312 −0
  150. java/pkg/java/rmi/server/Unreferenced.class +0 −0
  151. java/pkg/java/rmi/server/Unreferenced.java +45 −0
  152. java/pkg/java/rmi/server/mkfile +34 −0
  153. java/pkg/java/rmi/server/package.html +53 −0
java/pkg/java/rmi/AccessException.class+0−0

Binary file not shown.

java/pkg/java/rmi/AccessException.java+70−0
@@ -0,0 +1,70 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * An <code>AccessException</code> is thrown by certain methods of the
30 * <code>java.rmi.Naming</code> class (specifically <code>bind</code>,
31 * <code>rebind</code>, and <code>unbind</code>) and methods of the
32 * <code>java.rmi.activation.ActivationSystem</code> interface to
33 * indicate that the caller does not have permission to perform the action
34 * requested by the method call. If the method was invoked from a non-local
35 * host, then an <code>AccessException</code> is thrown.
36 *
37 * @author Ann Wollrath
38 * @author Roger Riggs
39 * @since JDK1.1
40 * @see java.rmi.Naming
41 * @see java.rmi.activation.ActivationSystem
42 */
43public class AccessException extends java.rmi.RemoteException {
44
45 /* indicate compatibility with JDK 1.1.x version of class */
46 private static final long serialVersionUID = 6314925228044966088L;
47
48 /**
49 * Constructs an <code>AccessException</code> with the specified
50 * detail message.
51 *
52 * @param s the detail message
53 * @since JDK1.1
54 */
55 public AccessException(String s) {
56 super(s);
57 }
58
59 /**
60 * Constructs an <code>AccessException</code> with the specified
61 * detail message and nested exception.
62 *
63 * @param s the detail message
64 * @param ex the nested exception
65 * @since JDK1.1
66 */
67 public AccessException(String s, Exception ex) {
68 super(s, ex);
69 }
70}
java/pkg/java/rmi/AlreadyBoundException.class+0−0

Binary file not shown.

java/pkg/java/rmi/AlreadyBoundException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi;
26
27/**
28 * An <code>AlreadyBoundException</code> is thrown if an attempt
29 * is made to bind an object in the registry to a name that already
30 * has an associated binding.
31 *
32 * @since JDK1.1
33 * @author Ann Wollrath
34 * @author Roger Riggs
35 * @see java.rmi.Naming#bind(String, java.rmi.Remote)
36 * @see java.rmi.registry.Registry#bind(String, java.rmi.Remote)
37 */
38public class AlreadyBoundException extends java.lang.Exception {
39
40 /* indicate compatibility with JDK 1.1.x version of class */
41 private static final long serialVersionUID = 9218657361741657110L;
42
43 /**
44 * Constructs an <code>AlreadyBoundException</code> with no
45 * specified detail message.
46 * @since JDK1.1
47 */
48 public AlreadyBoundException() {
49 super();
50 }
51
52 /**
53 * Constructs an <code>AlreadyBoundException</code> with the specified
54 * detail message.
55 *
56 * @param s the detail message
57 * @since JDK1.1
58 */
59 public AlreadyBoundException(String s) {
60 super(s);
61 }
62}
java/pkg/java/rmi/ConnectException.class+0−0

Binary file not shown.

java/pkg/java/rmi/ConnectException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * A <code>ConnectException</code> is thrown if a connection is refused
30 * to the remote host for a remote method call.
31 *
32 * @author Ann Wollrath
33 * @since JDK1.1
34 */
35public class ConnectException extends RemoteException {
36
37 /* indicate compatibility with JDK 1.1.x version of class */
38 private static final long serialVersionUID = 4863550261346652506L;
39
40 /**
41 * Constructs a <code>ConnectException</code> with the specified
42 * detail message.
43 *
44 * @param s the detail message
45 * @since JDK1.1
46 */
47 public ConnectException(String s) {
48 super(s);
49 }
50
51 /**
52 * Constructs a <code>ConnectException</code> with the specified
53 * detail message and nested exception.
54 *
55 * @param s the detail message
56 * @param ex the nested exception
57 * @since JDK1.1
58 */
59 public ConnectException(String s, Exception ex) {
60 super(s, ex);
61 }
62}
java/pkg/java/rmi/ConnectIOException.class+0−0

Binary file not shown.

java/pkg/java/rmi/ConnectIOException.java+64−0
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * A <code>ConnectIOException</code> is thrown if an
30 * <code>IOException</code> occurs while making a connection
31 * to the remote host for a remote method call.
32 *
33 * @author Ann Wollrath
34 * @since JDK1.1
35 */
36public class ConnectIOException extends RemoteException {
37
38 /* indicate compatibility with JDK 1.1.x version of class */
39 private static final long serialVersionUID = -8087809532704668744L;
40
41 /**
42 * Constructs a <code>ConnectIOException</code> with the specified
43 * detail message.
44 *
45 * @param s the detail message
46 * @since JDK1.1
47 */
48 public ConnectIOException(String s) {
49 super(s);
50 }
51
52
53 /**
54 * Constructs a <code>ConnectIOException</code> with the specified
55 * detail message and nested exception.
56 *
57 * @param s the detail message
58 * @param ex the nested exception
59 * @since JDK1.1
60 */
61 public ConnectIOException(String s, Exception ex) {
62 super(s, ex);
63 }
64}
java/pkg/java/rmi/MarshalException.class+0−0

Binary file not shown.

java/pkg/java/rmi/MarshalException.java+71−0
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * A <code>MarshalException</code> is thrown if a
30 * <code>java.io.IOException</code> occurs while marshalling the remote call
31 * header, arguments or return value for a remote method call. A
32 * <code>MarshalException</code> is also thrown if the receiver does not
33 * support the protocol version of the sender.
34 *
35 * <p>If a <code>MarshalException</code> occurs during a remote method call,
36 * the call may or may not have reached the server. If the call did reach the
37 * server, parameters may have been deserialized. A call may not be
38 * retransmitted after a <code>MarshalException</code> and reliably preserve
39 * "at most once" call semantics.
40 *
41 * @author Ann Wollrath
42 * @since JDK1.1
43 */
44public class MarshalException extends RemoteException {
45
46 /* indicate compatibility with JDK 1.1.x version of class */
47 private static final long serialVersionUID = 6223554758134037936L;
48
49 /**
50 * Constructs a <code>MarshalException</code> with the specified
51 * detail message.
52 *
53 * @param s the detail message
54 * @since JDK1.1
55 */
56 public MarshalException(String s) {
57 super(s);
58 }
59
60 /**
61 * Constructs a <code>MarshalException</code> with the specified
62 * detail message and nested exception.
63 *
64 * @param s the detail message
65 * @param ex the nested exception
66 * @since JDK1.1
67 */
68 public MarshalException(String s, Exception ex) {
69 super(s, ex);
70 }
71}
java/pkg/java/rmi/MarshalledObject$MarshalledObjectInputStream.class+0−0

Binary file not shown.

java/pkg/java/rmi/MarshalledObject$MarshalledObjectOutputStream.class+0−0

Binary file not shown.

java/pkg/java/rmi/MarshalledObject.class+0−0

Binary file not shown.

java/pkg/java/rmi/MarshalledObject.java+316−0
@@ -0,0 +1,316 @@
1/*
2 * Copyright (c) 1997, 2005, 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;
27
28import java.io.ByteArrayInputStream;
29import java.io.ByteArrayOutputStream;
30import java.io.IOException;
31import java.io.InputStream;
32import java.io.ObjectInputStream;
33import java.io.ObjectOutputStream;
34import java.io.ObjectStreamConstants;
35import java.io.OutputStream;
36import java.io.Serializable;
37import sun.rmi.server.MarshalInputStream;
38import sun.rmi.server.MarshalOutputStream;
39
40/**
41 * A <code>MarshalledObject</code> contains a byte stream with the serialized
42 * representation of an object given to its constructor. The <code>get</code>
43 * method returns a new copy of the original object, as deserialized from
44 * the contained byte stream. The contained object is serialized and
45 * deserialized with the same serialization semantics used for marshaling
46 * and unmarshaling parameters and return values of RMI calls: When the
47 * serialized form is created:
48 *
49 * <ul>
50 * <li> classes are annotated with a codebase URL from where the class
51 * can be loaded (if available), and
52 * <li> any remote object in the <code>MarshalledObject</code> is
53 * represented by a serialized instance of its stub.
54 * </ul>
55 *
56 * <p>When copy of the object is retrieved (via the <code>get</code> method),
57 * if the class is not available locally, it will be loaded from the
58 * appropriate location (specified the URL annotated with the class descriptor
59 * when the class was serialized.
60 *
61 * <p><code>MarshalledObject</code> facilitates passing objects in RMI calls
62 * that are not automatically deserialized immediately by the remote peer.
63 *
64 * @param <T> the type of the object contained in this
65 * <code>MarshalledObject</code>
66 *
67 * @author Ann Wollrath
68 * @author Peter Jones
69 * @since 1.2
70 */
71public final class MarshalledObject<T> implements Serializable {
72 /**
73 * @serial Bytes of serialized representation. If <code>objBytes</code> is
74 * <code>null</code> then the object marshalled was a <code>null</code>
75 * reference.
76 */
77 private byte[] objBytes = null;
78
79 /**
80 * @serial Bytes of location annotations, which are ignored by
81 * <code>equals</code>. If <code>locBytes</code> is null, there were no
82 * non-<code>null</code> annotations during marshalling.
83 */
84 private byte[] locBytes = null;
85
86 /**
87 * @serial Stored hash code of contained object.
88 *
89 * @see #hashCode
90 */
91 private int hash;
92
93 /** Indicate compatibility with 1.2 version of class. */
94 private static final long serialVersionUID = 8988374069173025854L;
95
96 /**
97 * Creates a new <code>MarshalledObject</code> that contains the
98 * serialized representation of the current state of the supplied object.
99 * The object is serialized with the semantics used for marshaling
100 * parameters for RMI calls.
101 *
102 * @param obj the object to be serialized (must be serializable)
103 * @exception IOException if an <code>IOException</code> occurs; an
104 * <code>IOException</code> may occur if <code>obj</code> is not
105 * serializable.
106 * @since 1.2
107 */
108 public MarshalledObject(T obj) throws IOException {
109 if (obj == null) {
110 hash = 13;
111 return;
112 }
113
114 ByteArrayOutputStream bout = new ByteArrayOutputStream();
115 ByteArrayOutputStream lout = new ByteArrayOutputStream();
116 MarshalledObjectOutputStream out =
117 new MarshalledObjectOutputStream(bout, lout);
118 out.writeObject(obj);
119 out.flush();
120 objBytes = bout.toByteArray();
121 // locBytes is null if no annotations
122 locBytes = (out.hadAnnotations() ? lout.toByteArray() : null);
123
124 /*
125 * Calculate hash from the marshalled representation of object
126 * so the hashcode will be comparable when sent between VMs.
127 */
128 int h = 0;
129 for (int i = 0; i < objBytes.length; i++) {
130 h = 31 * h + objBytes[i];
131 }
132 hash = h;
133 }
134
135 /**
136 * Returns a new copy of the contained marshalledobject. The internal
137 * representation is deserialized with the semantics used for
138 * unmarshaling paramters for RMI calls.
139 *
140 * @return a copy of the contained object
141 * @exception IOException if an <code>IOException</code> occurs while
142 * deserializing the object from its internal representation.
143 * @exception ClassNotFoundException if a
144 * <code>ClassNotFoundException</code> occurs while deserializing the
145 * object from its internal representation.
146 * could not be found
147 * @since 1.2
148 */
149 public T get() throws IOException, ClassNotFoundException {
150 if (objBytes == null) // must have been a null object
151 return null;
152
153 ByteArrayInputStream bin = new ByteArrayInputStream(objBytes);
154 // locBytes is null if no annotations
155 ByteArrayInputStream lin =
156 (locBytes == null ? null : new ByteArrayInputStream(locBytes));
157 MarshalledObjectInputStream in =
158 new MarshalledObjectInputStream(bin, lin);
159 T obj = (T) in.readObject();
160 in.close();
161 return obj;
162 }
163
164 /**
165 * Return a hash code for this <code>MarshalledObject</code>.
166 *
167 * @return a hash code
168 */
169 public int hashCode() {
170 return hash;
171 }
172
173 /**
174 * Compares this <code>MarshalledObject</code> to another object.
175 * Returns true if and only if the argument refers to a
176 * <code>MarshalledObject</code> that contains exactly the same
177 * serialized representation of an object as this one does. The
178 * comparison ignores any class codebase annotation, meaning that
179 * two objects are equivalent if they have the same serialized
180 * representation <i>except</i> for the codebase of each class
181 * in the serialized representation.
182 *
183 * @param obj the object to compare with this <code>MarshalledObject</code>
184 * @return <code>true</code> if the argument contains an equaivalent
185 * serialized object; <code>false</code> otherwise
186 * @since 1.2
187 */
188 public boolean equals(Object obj) {
189 if (obj == this)
190 return true;
191
192 if (obj != null && obj instanceof MarshalledObject) {
193 MarshalledObject other = (MarshalledObject) obj;
194
195 // if either is a ref to null, both must be
196 if (objBytes == null || other.objBytes == null)
197 return objBytes == other.objBytes;
198
199 // quick, easy test
200 if (objBytes.length != other.objBytes.length)
201 return false;
202
203 //!! There is talk about adding an array comparision method
204 //!! at 1.2 -- if so, this should be rewritten. -arnold
205 for (int i = 0; i < objBytes.length; ++i) {
206 if (objBytes[i] != other.objBytes[i])
207 return false;
208 }
209 return true;
210 } else {
211 return false;
212 }
213 }
214
215 /**
216 * This class is used to marshal objects for
217 * <code>MarshalledObject</code>. It places the location annotations
218 * to one side so that two <code>MarshalledObject</code>s can be
219 * compared for equality if they differ only in location
220 * annotations. Objects written using this stream should be read back
221 * from a <code>MarshalledObjectInputStream</code>.
222 *
223 * @see java.rmi.MarshalledObject
224 * @see MarshalledObjectInputStream
225 */
226 private static class MarshalledObjectOutputStream
227 extends MarshalOutputStream
228 {
229 /** The stream on which location objects are written. */
230 private ObjectOutputStream locOut;
231
232 /** <code>true</code> if non-<code>null</code> annotations are
233 * written.
234 */
235 private boolean hadAnnotations;
236
237 /**
238 * Creates a new <code>MarshalledObjectOutputStream</code> whose
239 * non-location bytes will be written to <code>objOut</code> and whose
240 * location annotations (if any) will be written to
241 * <code>locOut</code>.
242 */
243 MarshalledObjectOutputStream(OutputStream objOut, OutputStream locOut)
244 throws IOException
245 {
246 super(objOut);
247 this.useProtocolVersion(ObjectStreamConstants.PROTOCOL_VERSION_2);
248 this.locOut = new ObjectOutputStream(locOut);
249 hadAnnotations = false;
250 }
251
252 /**
253 * Returns <code>true</code> if any non-<code>null</code> location
254 * annotations have been written to this stream.
255 */
256 boolean hadAnnotations() {
257 return hadAnnotations;
258 }
259
260 /**
261 * Overrides MarshalOutputStream.writeLocation implementation to write
262 * annotations to the location stream.
263 */
264 protected void writeLocation(String loc) throws IOException {
265 hadAnnotations |= (loc != null);
266 locOut.writeObject(loc);
267 }
268
269
270 public void flush() throws IOException {
271 super.flush();
272 locOut.flush();
273 }
274 }
275
276 /**
277 * The counterpart to <code>MarshalledObjectOutputStream</code>.
278 *
279 * @see MarshalledObjectOutputStream
280 */
281 private static class MarshalledObjectInputStream
282 extends MarshalInputStream
283 {
284 /**
285 * The stream from which annotations will be read. If this is
286 * <code>null</code>, then all annotations were <code>null</code>.
287 */
288 private ObjectInputStream locIn;
289
290 /**
291 * Creates a new <code>MarshalledObjectInputStream</code> that
292 * reads its objects from <code>objIn</code> and annotations
293 * from <code>locIn</code>. If <code>locIn</code> is
294 * <code>null</code>, then all annotations will be
295 * <code>null</code>.
296 */
297 MarshalledObjectInputStream(InputStream objIn, InputStream locIn)
298 throws IOException
299 {
300 super(objIn);
301 this.locIn = (locIn == null ? null : new ObjectInputStream(locIn));
302 }
303
304 /**
305 * Overrides MarshalInputStream.readLocation to return locations from
306 * the stream we were given, or <code>null</code> if we were given a
307 * <code>null</code> location stream.
308 */
309 protected Object readLocation()
310 throws IOException, ClassNotFoundException
311 {
312 return (locIn == null ? null : locIn.readObject());
313 }
314 }
315
316}
java/pkg/java/rmi/Naming$ParsedNamingURL.class+0−0

Binary file not shown.

java/pkg/java/rmi/Naming.class+0−0

Binary file not shown.

java/pkg/java/rmi/Naming.java+356−0
@@ -0,0 +1,356 @@
1/*
2 * Copyright (c) 1996, 2005, 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;
26
27import java.rmi.registry.*;
28import java.net.MalformedURLException;
29import java.net.URI;
30import java.net.URISyntaxException;
31
32/**
33 * The <code>Naming</code> class provides methods for storing and obtaining
34 * references to remote objects in a remote object registry. Each method of
35 * the <code>Naming</code> class takes as one of its arguments a name that
36 * is a <code>java.lang.String</code> in URL format (without the
37 * scheme component) of the form:
38 *
39 * <PRE>
40 * //host:port/name
41 * </PRE>
42 *
43 * <P>where <code>host</code> is the host (remote or local) where the registry
44 * is located, <code>port</code> is the port number on which the registry
45 * accepts calls, and where <code>name</code> is a simple string uninterpreted
46 * by the registry. Both <code>host</code> and <code>port</code> are optional.
47 * If <code>host</code> is omitted, the host defaults to the local host. If
48 * <code>port</code> is omitted, then the port defaults to 1099, the
49 * "well-known" port that RMI's registry, <code>rmiregistry</code>, uses.
50 *
51 * <P><em>Binding</em> a name for a remote object is associating or
52 * registering a name for a remote object that can be used at a later time to
53 * look up that remote object. A remote object can be associated with a name
54 * using the <code>Naming</code> class's <code>bind</code> or
55 * <code>rebind</code> methods.
56 *
57 * <P>Once a remote object is registered (bound) with the RMI registry on the
58 * local host, callers on a remote (or local) host can lookup the remote
59 * object by name, obtain its reference, and then invoke remote methods on the
60 * object. A registry may be shared by all servers running on a host or an
61 * individual server process may create and use its own registry if desired
62 * (see <code>java.rmi.registry.LocateRegistry.createRegistry</code> method
63 * for details).
64 *
65 * @author Ann Wollrath
66 * @author Roger Riggs
67 * @since JDK1.1
68 * @see java.rmi.registry.Registry
69 * @see java.rmi.registry.LocateRegistry
70 * @see java.rmi.registry.LocateRegistry#createRegistry(int)
71 */
72public final class Naming {
73 /**
74 * Disallow anyone from creating one of these
75 */
76 private Naming() {}
77
78 /**
79 * Returns a reference, a stub, for the remote object associated
80 * with the specified <code>name</code>.
81 *
82 * @param name a name in URL format (without the scheme component)
83 * @return a reference for a remote object
84 * @exception NotBoundException if name is not currently bound
85 * @exception RemoteException if registry could not be contacted
86 * @exception AccessException if this operation is not permitted
87 * @exception MalformedURLException if the name is not an appropriately
88 * formatted URL
89 * @since JDK1.1
90 */
91 public static Remote lookup(String name)
92 throws NotBoundException,
93 java.net.MalformedURLException,
94 RemoteException
95 {
96 ParsedNamingURL parsed = parseURL(name);
97 Registry registry = getRegistry(parsed);
98
99 if (parsed.name == null)
100 return registry;
101 return registry.lookup(parsed.name);
102 }
103
104 /**
105 * Binds the specified <code>name</code> to a remote object.
106 *
107 * @param name a name in URL format (without the scheme component)
108 * @param obj a reference for the remote object (usually a stub)
109 * @exception AlreadyBoundException if name is already bound
110 * @exception MalformedURLException if the name is not an appropriately
111 * formatted URL
112 * @exception RemoteException if registry could not be contacted
113 * @exception AccessException if this operation is not permitted (if
114 * originating from a non-local host, for example)
115 * @since JDK1.1
116 */
117 public static void bind(String name, Remote obj)
118 throws AlreadyBoundException,
119 java.net.MalformedURLException,
120 RemoteException
121 {
122 ParsedNamingURL parsed = parseURL(name);
123 Registry registry = getRegistry(parsed);
124
125 if (obj == null)
126 throw new NullPointerException("cannot bind to null");
127
128 registry.bind(parsed.name, obj);
129 }
130
131 /**
132 * Destroys the binding for the specified name that is associated
133 * with a remote object.
134 *
135 * @param name a name in URL format (without the scheme component)
136 * @exception NotBoundException if name is not currently bound
137 * @exception MalformedURLException if the name is not an appropriately
138 * formatted URL
139 * @exception RemoteException if registry could not be contacted
140 * @exception AccessException if this operation is not permitted (if
141 * originating from a non-local host, for example)
142 * @since JDK1.1
143 */
144 public static void unbind(String name)
145 throws RemoteException,
146 NotBoundException,
147 java.net.MalformedURLException
148 {
149 ParsedNamingURL parsed = parseURL(name);
150 Registry registry = getRegistry(parsed);
151
152 registry.unbind(parsed.name);
153 }
154
155 /**
156 * Rebinds the specified name to a new remote object. Any existing
157 * binding for the name is replaced.
158 *
159 * @param name a name in URL format (without the scheme component)
160 * @param obj new remote object to associate with the name
161 * @exception MalformedURLException if the name is not an appropriately
162 * formatted URL
163 * @exception RemoteException if registry could not be contacted
164 * @exception AccessException if this operation is not permitted (if
165 * originating from a non-local host, for example)
166 * @since JDK1.1
167 */
168 public static void rebind(String name, Remote obj)
169 throws RemoteException, java.net.MalformedURLException
170 {
171 ParsedNamingURL parsed = parseURL(name);
172 Registry registry = getRegistry(parsed);
173
174 if (obj == null)
175 throw new NullPointerException("cannot bind to null");
176
177 registry.rebind(parsed.name, obj);
178 }
179
180 /**
181 * Returns an array of the names bound in the registry. The names are
182 * URL-formatted (without the scheme component) strings. The array contains
183 * a snapshot of the names present in the registry at the time of the
184 * call.
185 *
186 * @param name a registry name in URL format (without the scheme
187 * component)
188 * @return an array of names (in the appropriate format) bound
189 * in the registry
190 * @exception MalformedURLException if the name is not an appropriately
191 * formatted URL
192 * @exception RemoteException if registry could not be contacted.
193 * @since JDK1.1
194 */
195 public static String[] list(String name)
196 throws RemoteException, java.net.MalformedURLException
197 {
198 ParsedNamingURL parsed = parseURL(name);
199 Registry registry = getRegistry(parsed);
200
201 String prefix = "";
202 if (parsed.port > 0 || !parsed.host.equals(""))
203 prefix += "//" + parsed.host;
204 if (parsed.port > 0)
205 prefix += ":" + parsed.port;
206 prefix += "/";
207
208 String[] names = registry.list();
209 for (int i = 0; i < names.length; i++) {
210 names[i] = prefix + names[i];
211 }
212 return names;
213 }
214
215 /**
216 * Returns a registry reference obtained from information in the URL.
217 */
218 private static Registry getRegistry(ParsedNamingURL parsed)
219 throws RemoteException
220 {
221 return LocateRegistry.getRegistry(parsed.host, parsed.port);
222 }
223
224 /**
225 * Dissect Naming URL strings to obtain referenced host, port and
226 * object name.
227 *
228 * @return an object which contains each of the above
229 * components.
230 *
231 * @exception MalformedURLException if given url string is malformed
232 */
233 private static ParsedNamingURL parseURL(String str)
234 throws MalformedURLException
235 {
236 try {
237 return intParseURL(str);
238 } catch (URISyntaxException ex) {
239 /* With RFC 3986 URI handling, 'rmi://:<port>' and
240 * '//:<port>' forms will result in a URI syntax exception
241 * Convert the authority to a localhost:<port> form
242 */
243 MalformedURLException mue = new MalformedURLException(
244 "invalid URL String: " + str);
245 mue.initCause(ex);
246 int indexSchemeEnd = str.indexOf(':');
247 int indexAuthorityBegin = str.indexOf("//:");
248 if (indexAuthorityBegin < 0) {
249 throw mue;
250 }
251 if ((indexAuthorityBegin == 0) ||
252 ((indexSchemeEnd > 0) &&
253 (indexAuthorityBegin == indexSchemeEnd + 1))) {
254 int indexHostBegin = indexAuthorityBegin + 2;
255 String newStr = str.substring(0, indexHostBegin) +
256 "localhost" +
257 str.substring(indexHostBegin);
258 try {
259 return intParseURL(newStr);
260 } catch (URISyntaxException inte) {
261 throw mue;
262 } catch (MalformedURLException inte) {
263 throw inte;
264 }
265 }
266 throw mue;
267 }
268 }
269
270 private static ParsedNamingURL intParseURL(String str)
271 throws MalformedURLException, URISyntaxException
272 {
273 URI uri = new URI(str);
274 if (uri.isOpaque()) {
275 throw new MalformedURLException(
276 "not a hierarchical URL: " + str);
277 }
278 if (uri.getFragment() != null) {
279 throw new MalformedURLException(
280 "invalid character, '#', in URL name: " + str);
281 } else if (uri.getQuery() != null) {
282 throw new MalformedURLException(
283 "invalid character, '?', in URL name: " + str);
284 } else if (uri.getUserInfo() != null) {
285 throw new MalformedURLException(
286 "invalid character, '@', in URL host: " + str);
287 }
288 String scheme = uri.getScheme();
289 if (scheme != null && !scheme.equals("rmi")) {
290 throw new MalformedURLException("invalid URL scheme: " + str);
291 }
292
293 String name = uri.getPath();
294 if (name != null) {
295 if (name.startsWith("/")) {
296 name = name.substring(1);
297 }
298 if (name.length() == 0) {
299 name = null;
300 }
301 }
302
303 String host = uri.getHost();
304 if (host == null) {
305 host = "";
306 try {
307 /*
308 * With 2396 URI handling, forms such as 'rmi://host:bar'
309 * or 'rmi://:<port>' are parsed into a registry based
310 * authority. We only want to allow server based naming
311 * authorities.
312 */
313 uri.parseServerAuthority();
314 } catch (URISyntaxException use) {
315 // Check if the authority is of form ':<port>'
316 String authority = uri.getAuthority();
317 if (authority != null && authority.startsWith(":")) {
318 // Convert the authority to 'localhost:<port>' form
319 authority = "localhost" + authority;
320 try {
321 uri = new URI(null, authority, null, null, null);
322 // Make sure it now parses to a valid server based
323 // naming authority
324 uri.parseServerAuthority();
325 } catch (URISyntaxException use2) {
326 throw new
327 MalformedURLException("invalid authority: " + str);
328 }
329 } else {
330 throw new
331 MalformedURLException("invalid authority: " + str);
332 }
333 }
334 }
335 int port = uri.getPort();
336 if (port == -1) {
337 port = Registry.REGISTRY_PORT;
338 }
339 return new ParsedNamingURL(host, port, name);
340 }
341
342 /**
343 * Simple class to enable multiple URL return values.
344 */
345 private static class ParsedNamingURL {
346 String host;
347 int port;
348 String name;
349
350 ParsedNamingURL(String host, int port, String name) {
351 this.host = host;
352 this.port = port;
353 this.name = name;
354 }
355 }
356}
java/pkg/java/rmi/NoSuchObjectException.class+0−0

Binary file not shown.

java/pkg/java/rmi/NoSuchObjectException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * A <code>NoSuchObjectException</code> is thrown if an attempt is made to
30 * invoke a method on an object that no longer exists in the remote virtual
31 * machine. If a <code>NoSuchObjectException</code> occurs attempting to
32 * invoke a method on a remote object, the call may be retransmitted and still
33 * preserve RMI's "at most once" call semantics.
34 *
35 * A <code>NoSuchObjectException</code> is also thrown by the method
36 * <code>java.rmi.server.RemoteObject.toStub</code> and by the
37 * <code>unexportObject</code> methods of
38 * <code>java.rmi.server.UnicastRemoteObject</code> and
39 * <code>java.rmi.activation.Activatable</code> and
40 *
41 * @author Ann Wollrath
42 * @since JDK1.1
43 * @see java.rmi.server.RemoteObject#toStub(Remote)
44 * @see java.rmi.server.UnicastRemoteObject#unexportObject(Remote,boolean)
45 * @see java.rmi.activation.Activatable#unexportObject(Remote,boolean)
46 */
47public class NoSuchObjectException extends RemoteException {
48
49 /* indicate compatibility with JDK 1.1.x version of class */
50 private static final long serialVersionUID = 6619395951570472985L;
51
52 /**
53 * Constructs a <code>NoSuchObjectException</code> with the specified
54 * detail message.
55 *
56 * @param s the detail message
57 * @since JDK1.1
58 */
59 public NoSuchObjectException(String s) {
60 super(s);
61 }
62}
java/pkg/java/rmi/NotBoundException.class+0−0

Binary file not shown.

java/pkg/java/rmi/NotBoundException.java+64−0
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi;
26
27/**
28 * A <code>NotBoundException</code> is thrown if an attempt
29 * is made to lookup or unbind in the registry a name that has
30 * no associated binding.
31 *
32 * @since JDK1.1
33 * @author Ann Wollrath
34 * @author Roger Riggs
35 * @see java.rmi.Naming#lookup(String)
36 * @see java.rmi.Naming#unbind(String)
37 * @see java.rmi.registry.Registry#lookup(String)
38 * @see java.rmi.registry.Registry#unbind(String)
39 */
40public class NotBoundException extends java.lang.Exception {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = -1857741824849069317L;
44
45 /**
46 * Constructs a <code>NotBoundException</code> with no
47 * specified detail message.
48 * @since JDK1.1
49 */
50 public NotBoundException() {
51 super();
52 }
53
54 /**
55 * Constructs a <code>NotBoundException</code> with the specified
56 * detail message.
57 *
58 * @param s the detail message
59 * @since JDK1.1
60 */
61 public NotBoundException(String s) {
62 super(s);
63 }
64}
java/pkg/java/rmi/RMISecurityException.class+0−0

Binary file not shown.

java/pkg/java/rmi/RMISecurityException.java+67−0
@@ -0,0 +1,67 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi;
26
27/**
28 * An <code>RMISecurityException</code> signals that a security exception
29 * has occurred during the execution of one of
30 * <code>java.rmi.RMISecurityManager</code>'s methods.
31 *
32 * @author Roger Riggs
33 * @since JDK1.1
34 * @deprecated Use {@link java.lang.SecurityException} instead.
35 * Application code should never directly reference this class, and
36 * <code>RMISecurityManager</code> no longer throws this subclass of
37 * <code>java.lang.SecurityException</code>.
38 */
39@Deprecated
40public class RMISecurityException extends java.lang.SecurityException {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = -8433406075740433514L;
44
45 /**
46 * Construct an <code>RMISecurityException</code> with a detail message.
47 * @param name the detail message
48 * @since JDK1.1
49 * @deprecated no replacement
50 */
51 @Deprecated
52 public RMISecurityException(String name) {
53 super(name);
54 }
55
56 /**
57 * Construct an <code>RMISecurityException</code> with a detail message.
58 * @param name the detail message
59 * @param arg ignored
60 * @since JDK1.1
61 * @deprecated no replacement
62 */
63 @Deprecated
64 public RMISecurityException(String name, String arg) {
65 this(name);
66 }
67}
java/pkg/java/rmi/RMISecurityManager.class+0−0

Binary file not shown.

java/pkg/java/rmi/RMISecurityManager.java+64−0
@@ -0,0 +1,64 @@
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;
27
28import java.security.*;
29
30/**
31 * A subclass of {@link SecurityManager} used by RMI applications that use
32 * downloaded code. RMI's class loader will not download any classes from
33 * remote locations if no security manager has been set.
34 * <code>RMISecurityManager</code> does not apply to applets, which run
35 * under the protection of their browser's security manager.
36 *
37 * <code>RMISecurityManager</code> implements a policy that
38 * is no different than the policy implemented by {@link SecurityManager}.
39 * Therefore an RMI application should use the <code>SecurityManager</code>
40 * class or another application-specific <code>SecurityManager</code>
41 * implementation instead of this class.
42 *
43 * <p>To use a <code>SecurityManager</code> in your application, add
44 * the following statement to your code (it needs to be executed before RMI
45 * can download code from remote hosts, so it most likely needs to appear
46 * in the <code>main</code> method of your application):
47 *
48 * <pre>
49 * System.setSecurityManager(new SecurityManager());
50 * </pre>
51 *
52 * @author Roger Riggs
53 * @author Peter Jones
54 * @since JDK1.1
55 **/
56public class RMISecurityManager extends SecurityManager {
57
58 /**
59 * Constructs a new <code>RMISecurityManager</code>.
60 * @since JDK1.1
61 */
62 public RMISecurityManager() {
63 }
64}
java/pkg/java/rmi/Remote.class+0−0

Binary file not shown.

java/pkg/java/rmi/Remote.java+50−0
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 1996, 2006, 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;
27
28/**
29 * The <code>Remote</code> interface serves to identify interfaces whose
30 * methods may be invoked from a non-local virtual machine. Any object that
31 * is a remote object must directly or indirectly implement this interface.
32 * Only those methods specified in a "remote interface", an interface that
33 * extends <code>java.rmi.Remote</code> are available remotely.
34 *
35 * <p>Implementation classes can implement any number of remote interfaces and
36 * can extend other remote implementation classes. RMI provides some
37 * convenience classes that remote object implementations can extend which
38 * facilitate remote object creation. These classes are
39 * <code>java.rmi.server.UnicastRemoteObject</code> and
40 * <code>java.rmi.activation.Activatable</code>.
41 *
42 * <p>For complete details on RMI, see the <a
43 href=../../../platform/rmi/spec/rmiTOC.html>RMI Specification</a> which describes the RMI API and system.
44 *
45 * @since JDK1.1
46 * @author Ann Wollrath
47 * @see java.rmi.server.UnicastRemoteObject
48 * @see java.rmi.activation.Activatable
49 */
50public interface Remote {}
java/pkg/java/rmi/RemoteException.class+0−0

Binary file not shown.

java/pkg/java/rmi/RemoteException.java+122−0
@@ -0,0 +1,122 @@
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;
27
28/**
29 * A <code>RemoteException</code> is the common superclass for a number of
30 * communication-related exceptions that may occur during the execution of a
31 * remote method call. Each method of a remote interface, an interface that
32 * extends <code>java.rmi.Remote</code>, must list
33 * <code>RemoteException</code> in its throws clause.
34 *
35 * <p>As of release 1.4, this exception has been retrofitted to conform to
36 * the general purpose exception-chaining mechanism. The "wrapped remote
37 * exception" that may be provided at construction time and accessed via
38 * the public {@link #detail} field is now known as the <i>cause</i>, and
39 * may be accessed via the {@link Throwable#getCause()} method, as well as
40 * the aforementioned "legacy field."
41 *
42 * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
43 * instance of <code>RemoteException</code> always throws {@link
44 * IllegalStateException}.
45 *
46 * @author Ann Wollrath
47 * @since JDK1.1
48 */
49public class RemoteException extends java.io.IOException {
50
51 /* indicate compatibility with JDK 1.1.x version of class */
52 private static final long serialVersionUID = -5148567311918794206L;
53
54 /**
55 * The cause of the remote exception.
56 *
57 * <p>This field predates the general-purpose exception chaining facility.
58 * The {@link Throwable#getCause()} method is now the preferred means of
59 * obtaining this information.
60 *
61 * @serial
62 */
63 public Throwable detail;
64
65 /**
66 * Constructs a <code>RemoteException</code>.
67 */
68 public RemoteException() {
69 initCause(null); // Disallow subsequent initCause
70 }
71
72 /**
73 * Constructs a <code>RemoteException</code> with the specified
74 * detail message.
75 *
76 * @param s the detail message
77 */
78 public RemoteException(String s) {
79 super(s);
80 initCause(null); // Disallow subsequent initCause
81 }
82
83 /**
84 * Constructs a <code>RemoteException</code> with the specified detail
85 * message and cause. This constructor sets the {@link #detail}
86 * field to the specified <code>Throwable</code>.
87 *
88 * @param s the detail message
89 * @param cause the cause
90 */
91 public RemoteException(String s, Throwable cause) {
92 super(s);
93 initCause(null); // Disallow subsequent initCause
94 detail = cause;
95 }
96
97 /**
98 * Returns the detail message, including the message from the cause, if
99 * any, of this exception.
100 *
101 * @return the detail message
102 */
103 public String getMessage() {
104 if (detail == null) {
105 return super.getMessage();
106 } else {
107 return super.getMessage() + "; nested exception is: \n\t" +
108 detail.toString();
109 }
110 }
111
112 /**
113 * Returns the cause of this exception. This method returns the value
114 * of the {@link #detail} field.
115 *
116 * @return the cause, which may be <tt>null</tt>.
117 * @since 1.4
118 */
119 public Throwable getCause() {
120 return detail;
121 }
122}
java/pkg/java/rmi/ServerError.class+0−0

Binary file not shown.

java/pkg/java/rmi/ServerError.java+56−0
@@ -0,0 +1,56 @@
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 */
25
26package java.rmi;
27
28/**
29 * A <code>ServerError</code> is thrown as a result of a remote method
30 * invocation when an <code>Error</code> is thrown while processing
31 * the invocation on the server, either while unmarshalling the arguments,
32 * executing the remote method itself, or marshalling the return value.
33 *
34 * A <code>ServerError</code> instance contains the original
35 * <code>Error</code> that occurred as its cause.
36 *
37 * @author Ann Wollrath
38 * @since JDK1.1
39 */
40public class ServerError extends RemoteException {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = 8455284893909696482L;
44
45 /**
46 * Constructs a <code>ServerError</code> with the specified
47 * detail message and nested error.
48 *
49 * @param s the detail message
50 * @param err the nested error
51 * @since JDK1.1
52 */
53 public ServerError(String s, Error err) {
54 super(s, err);
55 }
56}
java/pkg/java/rmi/ServerException.class+0−0

Binary file not shown.

java/pkg/java/rmi/ServerException.java+67−0
@@ -0,0 +1,67 @@
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;
27
28/**
29 * A <code>ServerException</code> is thrown as a result of a remote method
30 * invocation when a <code>RemoteException</code> is thrown while processing
31 * the invocation on the server, either while unmarshalling the arguments or
32 * executing the remote method itself.
33 *
34 * A <code>ServerException</code> instance contains the original
35 * <code>RemoteException</code> that occurred as its cause.
36 *
37 * @author Ann Wollrath
38 * @since JDK1.1
39 */
40public class ServerException extends RemoteException {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = -4775845313121906682L;
44
45 /**
46 * Constructs a <code>ServerException</code> with the specified
47 * detail message.
48 *
49 * @param s the detail message
50 * @since JDK1.1
51 */
52 public ServerException(String s) {
53 super(s);
54 }
55
56 /**
57 * Constructs a <code>ServerException</code> with the specified
58 * detail message and nested exception.
59 *
60 * @param s the detail message
61 * @param ex the nested exception
62 * @since JDK1.1
63 */
64 public ServerException(String s, Exception ex) {
65 super(s, ex);
66 }
67}
java/pkg/java/rmi/ServerRuntimeException.class+0−0

Binary file not shown.

java/pkg/java/rmi/ServerRuntimeException.java+65−0
@@ -0,0 +1,65 @@
1/*
2 * Copyright (c) 1996, 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;
27
28/**
29 * From a server executing on JDK&nbsp;1.1, a
30 * <code>ServerRuntimeException</code> is thrown as a result of a
31 * remote method invocation when a <code>RuntimeException</code> is
32 * thrown while processing the invocation on the server, either while
33 * unmarshalling the arguments, executing the remote method itself, or
34 * marshalling the return value.
35 *
36 * A <code>ServerRuntimeException</code> instance contains the original
37 * <code>RuntimeException</code> that occurred as its cause.
38 *
39 * <p>A <code>ServerRuntimeException</code> is not thrown from servers
40 * executing on the Java 2 platform v1.2 or later versions.
41 *
42 * @author Ann Wollrath
43 * @since JDK1.1
44 * @deprecated no replacement
45 */
46@Deprecated
47public class ServerRuntimeException extends RemoteException {
48
49 /* indicate compatibility with JDK 1.1.x version of class */
50 private static final long serialVersionUID = 7054464920481467219L;
51
52 /**
53 * Constructs a <code>ServerRuntimeException</code> with the specified
54 * detail message and nested exception.
55 *
56 * @param s the detail message
57 * @param ex the nested exception
58 * @deprecated no replacement
59 * @since JDK1.1
60 */
61 @Deprecated
62 public ServerRuntimeException(String s, Exception ex) {
63 super(s, ex);
64 }
65}
java/pkg/java/rmi/StubNotFoundException.class+0−0

Binary file not shown.

java/pkg/java/rmi/StubNotFoundException.java+67−0
@@ -0,0 +1,67 @@
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;
27
28/**
29 * A <code>StubNotFoundException</code> is thrown if a valid stub class
30 * could not be found for a remote object when it is exported.
31 * A <code>StubNotFoundException</code> may also be
32 * thrown when an activatable object is registered via the
33 * <code>java.rmi.activation.Activatable.register</code> method.
34 *
35 * @author Roger Riggs
36 * @since JDK1.1
37 * @see java.rmi.server.UnicastRemoteObject
38 * @see java.rmi.activation.Activatable
39 */
40public class StubNotFoundException extends RemoteException {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = -7088199405468872373L;
44
45 /**
46 * Constructs a <code>StubNotFoundException</code> with the specified
47 * detail message.
48 *
49 * @param s the detail message
50 * @since JDK1.1
51 */
52 public StubNotFoundException(String s) {
53 super(s);
54 }
55
56 /**
57 * Constructs a <code>StubNotFoundException</code> with the specified
58 * detail message and nested exception.
59 *
60 * @param s the detail message
61 * @param ex the nested exception
62 * @since JDK1.1
63 */
64 public StubNotFoundException(String s, Exception ex) {
65 super(s, ex);
66 }
67}
java/pkg/java/rmi/UnexpectedException.class+0−0

Binary file not shown.

java/pkg/java/rmi/UnexpectedException.java+64−0
@@ -0,0 +1,64 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * An <code>UnexpectedException</code> is thrown if the client of a
30 * remote method call receives, as a result of the call, a checked
31 * exception that is not among the checked exception types declared in the
32 * <code>throws</code> clause of the method in the remote interface.
33 *
34 * @author Roger Riggs
35 * @since JDK1.1
36 */
37public class UnexpectedException extends RemoteException {
38
39 /* indicate compatibility with JDK 1.1.x version of class */
40 private static final long serialVersionUID = 1800467484195073863L;
41
42 /**
43 * Constructs an <code>UnexpectedException</code> with the specified
44 * detail message.
45 *
46 * @param s the detail message
47 * @since JDK1.1
48 */
49 public UnexpectedException(String s) {
50 super(s);
51 }
52
53 /**
54 * Constructs a <code>UnexpectedException</code> with the specified
55 * detail message and nested exception.
56 *
57 * @param s the detail message
58 * @param ex the nested exception
59 * @since JDK1.1
60 */
61 public UnexpectedException(String s, Exception ex) {
62 super(s, ex);
63 }
64}
java/pkg/java/rmi/UnknownHostException.class+0−0

Binary file not shown.

java/pkg/java/rmi/UnknownHostException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * An <code>UnknownHostException</code> is thrown if a
30 * <code>java.net.UnknownHostException</code> occurs while creating
31 * a connection to the remote host for a remote method call.
32 *
33 * @since JDK1.1
34 */
35public class UnknownHostException extends RemoteException {
36
37 /* indicate compatibility with JDK 1.1.x version of class */
38 private static final long serialVersionUID = -8152710247442114228L;
39
40 /**
41 * Constructs an <code>UnknownHostException</code> with the specified
42 * detail message.
43 *
44 * @param s the detail message
45 * @since JDK1.1
46 */
47 public UnknownHostException(String s) {
48 super(s);
49 }
50
51 /**
52 * Constructs an <code>UnknownHostException</code> with the specified
53 * detail message and nested exception.
54 *
55 * @param s the detail message
56 * @param ex the nested exception
57 * @since JDK1.1
58 */
59 public UnknownHostException(String s, Exception ex) {
60 super(s, ex);
61 }
62}
java/pkg/java/rmi/UnmarshalException.class+0−0

Binary file not shown.

java/pkg/java/rmi/UnmarshalException.java+76−0
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi;
27
28/**
29 * An <code>UnmarshalException</code> can be thrown while unmarshalling the
30 * parameters or results of a remote method call if any of the following
31 * conditions occur:
32 * <ul>
33 * <li> if an exception occurs while unmarshalling the call header
34 * <li> if the protocol for the return value is invalid
35 * <li> if a <code>java.io.IOException</code> occurs unmarshalling
36 * parameters (on the server side) or the return value (on the client side).
37 * <li> if a <code>java.lang.ClassNotFoundException</code> occurs during
38 * unmarshalling parameters or return values
39 * <li> if no skeleton can be loaded on the server-side; note that skeletons
40 * are required in the 1.1 stub protocol, but not in the 1.2 stub protocol.
41 * <li> if the method hash is invalid (i.e., missing method).
42 * <li> if there is a failure to create a remote reference object for
43 * a remote object's stub when it is unmarshalled.
44 * </ul>
45 *
46 * @author Ann Wollrath
47 * @since JDK1.1
48 */
49public class UnmarshalException extends RemoteException {
50
51 /* indicate compatibility with JDK 1.1.x version of class */
52 private static final long serialVersionUID = 594380845140740218L;
53
54 /**
55 * Constructs an <code>UnmarshalException</code> with the specified
56 * detail message.
57 *
58 * @param s the detail message
59 * @since JDK1.1
60 */
61 public UnmarshalException(String s) {
62 super(s);
63 }
64
65 /**
66 * Constructs an <code>UnmarshalException</code> with the specified
67 * detail message and nested exception.
68 *
69 * @param s the detail message
70 * @param ex the nested exception
71 * @since JDK1.1
72 */
73 public UnmarshalException(String s, Exception ex) {
74 super(s, ex);
75 }
76}
java/pkg/java/rmi/activation/Activatable.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/Activatable.java+555−0
@@ -0,0 +1,555 @@
1/*
2 * Copyright (c) 1997, 2005, 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.MarshalledObject;
29import java.rmi.NoSuchObjectException;
30import java.rmi.Remote;
31import java.rmi.RemoteException;
32import java.rmi.activation.UnknownGroupException;
33import java.rmi.activation.UnknownObjectException;
34import java.rmi.server.RMIClientSocketFactory;
35import java.rmi.server.RMIServerSocketFactory;
36import java.rmi.server.RemoteServer;
37import sun.rmi.server.ActivatableServerRef;
38
39/**
40 * The <code>Activatable</code> class provides support for remote
41 * objects that require persistent access over time and that
42 * can be activated by the system.
43 *
44 * <p>For the constructors and static <code>exportObject</code> methods,
45 * the stub for a remote object being exported is obtained as described in
46 * {@link java.rmi.server.UnicastRemoteObject}.
47 *
48 * <p>An attempt to serialize explicitly an instance of this class will
49 * fail.
50 *
51 * @author Ann Wollrath
52 * @since 1.2
53 * @serial exclude
54 */
55public abstract class Activatable extends RemoteServer {
56
57 private ActivationID id;
58 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
59 private static final long serialVersionUID = -3120617863591563455L;
60
61 /**
62 * Constructs an activatable remote object by registering
63 * an activation descriptor (with the specified location, data, and
64 * restart mode) for this object, and exporting the object with the
65 * specified port.
66 *
67 * <p><strong>Note:</strong> Using the <code>Activatable</code>
68 * constructors that both register and export an activatable remote
69 * object is strongly discouraged because the actions of registering
70 * and exporting the remote object are <i>not</i> guaranteed to be
71 * atomic. Instead, an application should register an activation
72 * descriptor and export a remote object separately, so that exceptions
73 * can be handled properly.
74 *
75 * <p>This method invokes the {@link
76 * #exportObject(Remote,String,MarshalledObject,boolean,int)
77 * exportObject} method with this object, and the specified location,
78 * data, restart mode, and port. Subsequent calls to {@link #getID}
79 * will return the activation identifier returned from the call to
80 * <code>exportObject</code>.
81 *
82 * @param location the location for classes for this object
83 * @param data the object's initialization data
84 * @param port the port on which the object is exported (an anonymous
85 * port is used if port=0)
86 * @param restart if true, the object is restarted (reactivated) when
87 * either the activator is restarted or the object's activation group
88 * is restarted after an unexpected crash; if false, the object is only
89 * activated on demand. Specifying <code>restart</code> to be
90 * <code>true</code> does not force an initial immediate activation of
91 * a newly registered object; initial activation is lazy.
92 * @exception ActivationException if object registration fails.
93 * @exception RemoteException if either of the following fails:
94 * a) registering the object with the activation system or b) exporting
95 * the object to the RMI runtime.
96 * @since 1.2
97 **/
98 protected Activatable(String location,
99 MarshalledObject<?> data,
100 boolean restart,
101 int port)
102 throws ActivationException, RemoteException
103 {
104 super();
105 id = exportObject(this, location, data, restart, port);
106 }
107
108 /**
109 * Constructs an activatable remote object by registering
110 * an activation descriptor (with the specified location, data, and
111 * restart mode) for this object, and exporting the object with the
112 * specified port, and specified client and server socket factories.
113 *
114 * <p><strong>Note:</strong> Using the <code>Activatable</code>
115 * constructors that both register and export an activatable remote
116 * object is strongly discouraged because the actions of registering
117 * and exporting the remote object are <i>not</i> guaranteed to be
118 * atomic. Instead, an application should register an activation
119 * descriptor and export a remote object separately, so that exceptions
120 * can be handled properly.
121 *
122 * <p>This method invokes the {@link
123 * #exportObject(Remote,String,MarshalledObject,boolean,int,RMIClientSocketFactory,RMIServerSocketFactory)
124 * exportObject} method with this object, and the specified location,
125 * data, restart mode, port, and client and server socket factories.
126 * Subsequent calls to {@link #getID} will return the activation
127 * identifier returned from the call to <code>exportObject</code>.
128 *
129 * @param location the location for classes for this object
130 * @param data the object's initialization data
131 * @param restart if true, the object is restarted (reactivated) when
132 * either the activator is restarted or the object's activation group
133 * is restarted after an unexpected crash; if false, the object is only
134 * activated on demand. Specifying <code>restart</code> to be
135 * <code>true</code> does not force an initial immediate activation of
136 * a newly registered object; initial activation is lazy.
137 * @param port the port on which the object is exported (an anonymous
138 * port is used if port=0)
139 * @param csf the client-side socket factory for making calls to the
140 * remote object
141 * @param ssf the server-side socket factory for receiving remote calls
142 * @exception ActivationException if object registration fails.
143 * @exception RemoteException if either of the following fails:
144 * a) registering the object with the activation system or b) exporting
145 * the object to the RMI runtime.
146 * @since 1.2
147 **/
148 protected Activatable(String location,
149 MarshalledObject<?> data,
150 boolean restart,
151 int port,
152 RMIClientSocketFactory csf,
153 RMIServerSocketFactory ssf)
154 throws ActivationException, RemoteException
155 {
156 super();
157 id = exportObject(this, location, data, restart, port, csf, ssf);
158 }
159
160 /**
161 * Constructor used to activate/export the object on a specified
162 * port. An "activatable" remote object must have a constructor that
163 * takes two arguments: <ul>
164 * <li>the object's activation identifier (<code>ActivationID</code>), and
165 * <li>the object's initialization data (a <code>MarshalledObject</code>).
166 * </ul><p>
167 *
168 * A concrete subclass of this class must call this constructor when it is
169 * <i>activated</i> via the two parameter constructor described above. As
170 * a side-effect of construction, the remote object is "exported"
171 * to the RMI runtime (on the specified <code>port</code>) and is
172 * available to accept incoming calls from clients.
173 *
174 * @param id activation identifier for the object
175 * @param port the port number on which the object is exported
176 * @exception RemoteException if exporting the object to the RMI
177 * runtime fails
178 * @since 1.2
179 */
180 protected Activatable(ActivationID id, int port)
181 throws RemoteException
182 {
183 super();
184 this.id = id;
185 exportObject(this, id, port);
186 }
187
188 /**
189 * Constructor used to activate/export the object on a specified
190 * port. An "activatable" remote object must have a constructor that
191 * takes two arguments: <ul>
192 * <li>the object's activation identifier (<code>ActivationID</code>), and
193 * <li>the object's initialization data (a <code>MarshalledObject</code>).
194 * </ul><p>
195 *
196 * A concrete subclass of this class must call this constructor when it is
197 * <i>activated</i> via the two parameter constructor described above. As
198 * a side-effect of construction, the remote object is "exported"
199 * to the RMI runtime (on the specified <code>port</code>) and is
200 * available to accept incoming calls from clients.
201 *
202 * @param id activation identifier for the object
203 * @param port the port number on which the object is exported
204 * @param csf the client-side socket factory for making calls to the
205 * remote object
206 * @param ssf the server-side socket factory for receiving remote calls
207 * @exception RemoteException if exporting the object to the RMI
208 * runtime fails
209 * @since 1.2
210 */
211 protected Activatable(ActivationID id, int port,
212 RMIClientSocketFactory csf,
213 RMIServerSocketFactory ssf)
214 throws RemoteException
215 {
216 super();
217 this.id = id;
218 exportObject(this, id, port, csf, ssf);
219 }
220
221 /**
222 * Returns the object's activation identifier. The method is
223 * protected so that only subclasses can obtain an object's
224 * identifier.
225 * @return the object's activation identifier
226 * @since 1.2
227 */
228 protected ActivationID getID() {
229 return id;
230 }
231
232 /**
233 * Register an object descriptor for an activatable remote
234 * object so that is can be activated on demand.
235 *
236 * @param desc the object's descriptor
237 * @return the stub for the activatable remote object
238 * @exception UnknownGroupException if group id in <code>desc</code>
239 * is not registered with the activation system
240 * @exception ActivationException if activation system is not running
241 * @exception RemoteException if remote call fails
242 * @since 1.2
243 */
244 public static Remote register(ActivationDesc desc)
245 throws UnknownGroupException, ActivationException, RemoteException
246 {
247 // register object with activator.
248 ActivationID id =
249 ActivationGroup.getSystem().registerObject(desc);
250 return sun.rmi.server.ActivatableRef.getStub(desc, id);
251 }
252
253 /**
254 * Informs the system that the object with the corresponding activation
255 * <code>id</code> is currently inactive. If the object is currently
256 * active, the object is "unexported" from the RMI runtime (only if
257 * there are no pending or in-progress calls)
258 * so the that it can no longer receive incoming calls. This call
259 * informs this VM's ActivationGroup that the object is inactive,
260 * that, in turn, informs its ActivationMonitor. If this call
261 * completes successfully, a subsequent activate request to the activator
262 * will cause the object to reactivate. The operation may still
263 * succeed if the object is considered active but has already
264 * unexported itself.
265 *
266 * @param id the object's activation identifier
267 * @return true if the operation succeeds (the operation will
268 * succeed if the object in currently known to be active and is
269 * either already unexported or is currently exported and has no
270 * pending/executing calls); false is returned if the object has
271 * pending/executing calls in which case it cannot be deactivated
272 * @exception UnknownObjectException if object is not known (it may
273 * already be inactive)
274 * @exception ActivationException if group is not active
275 * @exception RemoteException if call informing monitor fails
276 * @since 1.2
277 */
278 public static boolean inactive(ActivationID id)
279 throws UnknownObjectException, ActivationException, RemoteException
280 {
281 return ActivationGroup.currentGroup().inactiveObject(id);
282 }
283
284 /**
285 * Revokes previous registration for the activation descriptor
286 * associated with <code>id</code>. An object can no longer be
287 * activated via that <code>id</code>.
288 *
289 * @param id the object's activation identifier
290 * @exception UnknownObjectException if object (<code>id</code>) is unknown
291 * @exception ActivationException if activation system is not running
292 * @exception RemoteException if remote call to activation system fails
293 * @since 1.2
294 */
295 public static void unregister(ActivationID id)
296 throws UnknownObjectException, ActivationException, RemoteException
297 {
298 ActivationGroup.getSystem().unregisterObject(id);
299 }
300
301 /**
302 * Registers an activation descriptor (with the specified location,
303 * data, and restart mode) for the specified object, and exports that
304 * object with the specified port.
305 *
306 * <p><strong>Note:</strong> Using this method (as well as the
307 * <code>Activatable</code> constructors that both register and export
308 * an activatable remote object) is strongly discouraged because the
309 * actions of registering and exporting the remote object are
310 * <i>not</i> guaranteed to be atomic. Instead, an application should
311 * register an activation descriptor and export a remote object
312 * separately, so that exceptions can be handled properly.
313 *
314 * <p>This method invokes the {@link
315 * #exportObject(Remote,String,MarshalledObject,boolean,int,RMIClientSocketFactory,RMIServerSocketFactory)
316 * exportObject} method with the specified object, location, data,
317 * restart mode, and port, and <code>null</code> for both client and
318 * server socket factories, and then returns the resulting activation
319 * identifier.
320 *
321 * @param obj the object being exported
322 * @param location the object's code location
323 * @param data the object's bootstrapping data
324 * @param restart if true, the object is restarted (reactivated) when
325 * either the activator is restarted or the object's activation group
326 * is restarted after an unexpected crash; if false, the object is only
327 * activated on demand. Specifying <code>restart</code> to be
328 * <code>true</code> does not force an initial immediate activation of
329 * a newly registered object; initial activation is lazy.
330 * @param port the port on which the object is exported (an anonymous
331 * port is used if port=0)
332 * @return the activation identifier obtained from registering the
333 * descriptor, <code>desc</code>, with the activation system
334 * the wrong group
335 * @exception ActivationException if activation group is not active
336 * @exception RemoteException if object registration or export fails
337 * @since 1.2
338 **/
339 public static ActivationID exportObject(Remote obj,
340 String location,
341 MarshalledObject<?> data,
342 boolean restart,
343 int port)
344 throws ActivationException, RemoteException
345 {
346 return exportObject(obj, location, data, restart, port, null, null);
347 }
348
349 /**
350 * Registers an activation descriptor (with the specified location,
351 * data, and restart mode) for the specified object, and exports that
352 * object with the specified port, and the specified client and server
353 * socket factories.
354 *
355 * <p><strong>Note:</strong> Using this method (as well as the
356 * <code>Activatable</code> constructors that both register and export
357 * an activatable remote object) is strongly discouraged because the
358 * actions of registering and exporting the remote object are
359 * <i>not</i> guaranteed to be atomic. Instead, an application should
360 * register an activation descriptor and export a remote object
361 * separately, so that exceptions can be handled properly.
362 *
363 * <p>This method first registers an activation descriptor for the
364 * specified object as follows. It obtains the activation system by
365 * invoking the method {@link ActivationGroup#getSystem
366 * ActivationGroup.getSystem}. This method then obtains an {@link
367 * ActivationID} for the object by invoking the activation system's
368 * {@link ActivationSystem#registerObject registerObject} method with
369 * an {@link ActivationDesc} constructed with the specified object's
370 * class name, and the specified location, data, and restart mode. If
371 * an exception occurs obtaining the activation system or registering
372 * the activation descriptor, that exception is thrown to the caller.
373 *
374 * <p>Next, this method exports the object by invoking the {@link
375 * #exportObject(Remote,ActivationID,int,RMIClientSocketFactory,RMIServerSocketFactory)
376 * exportObject} method with the specified remote object, the
377 * activation identifier obtained from registration, the specified
378 * port, and the specified client and server socket factories. If an
379 * exception occurs exporting the object, this method attempts to
380 * unregister the activation identifier (obtained from registration) by
381 * invoking the activation system's {@link
382 * ActivationSystem#unregisterObject unregisterObject} method with the
383 * activation identifier. If an exception occurs unregistering the
384 * identifier, that exception is ignored, and the original exception
385 * that occurred exporting the object is thrown to the caller.
386 *
387 * <p>Finally, this method invokes the {@link
388 * ActivationGroup#activeObject activeObject} method on the activation
389 * group in this VM with the activation identifier and the specified
390 * remote object, and returns the activation identifier to the caller.
391 *
392 * @param obj the object being exported
393 * @param location the object's code location
394 * @param data the object's bootstrapping data
395 * @param restart if true, the object is restarted (reactivated) when
396 * either the activator is restarted or the object's activation group
397 * is restarted after an unexpected crash; if false, the object is only
398 * activated on demand. Specifying <code>restart</code> to be
399 * <code>true</code> does not force an initial immediate activation of
400 * a newly registered object; initial activation is lazy.
401 * @param port the port on which the object is exported (an anonymous
402 * port is used if port=0)
403 * @param csf the client-side socket factory for making calls to the
404 * remote object
405 * @param ssf the server-side socket factory for receiving remote calls
406 * @return the activation identifier obtained from registering the
407 * descriptor with the activation system
408 * @exception ActivationException if activation group is not active
409 * @exception RemoteException if object registration or export fails
410 * @since 1.2
411 **/
412 public static ActivationID exportObject(Remote obj,
413 String location,
414 MarshalledObject<?> data,
415 boolean restart,
416 int port,
417 RMIClientSocketFactory csf,
418 RMIServerSocketFactory ssf)
419 throws ActivationException, RemoteException
420 {
421 ActivationDesc desc = new ActivationDesc(obj.getClass().getName(),
422 location, data, restart);
423 /*
424 * Register descriptor.
425 */
426 ActivationSystem system = ActivationGroup.getSystem();
427 ActivationID id = system.registerObject(desc);
428
429 /*
430 * Export object.
431 */
432 try {
433 exportObject(obj, id, port, csf, ssf);
434 } catch (RemoteException e) {
435 /*
436 * Attempt to unregister activation descriptor because export
437 * failed and register/export should be atomic (see 4323621).
438 */
439 try {
440 system.unregisterObject(id);
441 } catch (Exception ex) {
442 }
443 /*
444 * Report original exception.
445 */
446 throw e;
447 }
448
449 /*
450 * This call can't fail (it is a local call, and the only possible
451 * exception, thrown if the group is inactive, will not be thrown
452 * because the group is not inactive).
453 */
454 ActivationGroup.currentGroup().activeObject(id, obj);
455
456 return id;
457 }
458
459 /**
460 * Export the activatable remote object to the RMI runtime to make
461 * the object available to receive incoming calls. The object is
462 * exported on an anonymous port, if <code>port</code> is zero. <p>
463 *
464 * During activation, this <code>exportObject</code> method should
465 * be invoked explicitly by an "activatable" object, that does not
466 * extend the <code>Activatable</code> class. There is no need for objects
467 * that do extend the <code>Activatable</code> class to invoke this
468 * method directly because the object is exported during construction.
469 *
470 * @return the stub for the activatable remote object
471 * @param obj the remote object implementation
472 * @param id the object's activation identifier
473 * @param port the port on which the object is exported (an anonymous
474 * port is used if port=0)
475 * @exception RemoteException if object export fails
476 * @since 1.2
477 */
478 public static Remote exportObject(Remote obj,
479 ActivationID id,
480 int port)
481 throws RemoteException
482 {
483 return exportObject(obj, new ActivatableServerRef(id, port));
484 }
485
486 /**
487 * Export the activatable remote object to the RMI runtime to make
488 * the object available to receive incoming calls. The object is
489 * exported on an anonymous port, if <code>port</code> is zero. <p>
490 *
491 * During activation, this <code>exportObject</code> method should
492 * be invoked explicitly by an "activatable" object, that does not
493 * extend the <code>Activatable</code> class. There is no need for objects
494 * that do extend the <code>Activatable</code> class to invoke this
495 * method directly because the object is exported during construction.
496 *
497 * @return the stub for the activatable remote object
498 * @param obj the remote object implementation
499 * @param id the object's activation identifier
500 * @param port the port on which the object is exported (an anonymous
501 * port is used if port=0)
502 * @param csf the client-side socket factory for making calls to the
503 * remote object
504 * @param ssf the server-side socket factory for receiving remote calls
505 * @exception RemoteException if object export fails
506 * @since 1.2
507 */
508 public static Remote exportObject(Remote obj,
509 ActivationID id,
510 int port,
511 RMIClientSocketFactory csf,
512 RMIServerSocketFactory ssf)
513 throws RemoteException
514 {
515 return exportObject(obj, new ActivatableServerRef(id, port, csf, ssf));
516 }
517
518 /**
519 * Remove the remote object, obj, from the RMI runtime. If
520 * successful, the object can no longer accept incoming RMI calls.
521 * If the force parameter is true, the object is forcibly unexported
522 * even if there are pending calls to the remote object or the
523 * remote object still has calls in progress. If the force
524 * parameter is false, the object is only unexported if there are
525 * no pending or in progress calls to the object.
526 *
527 * @param obj the remote object to be unexported
528 * @param force if true, unexports the object even if there are
529 * pending or in-progress calls; if false, only unexports the object
530 * if there are no pending or in-progress calls
531 * @return true if operation is successful, false otherwise
532 * @exception NoSuchObjectException if the remote object is not
533 * currently exported
534 * @since 1.2
535 */
536 public static boolean unexportObject(Remote obj, boolean force)
537 throws NoSuchObjectException
538 {
539 return sun.rmi.transport.ObjectTable.unexportObject(obj, force);
540 }
541
542 /**
543 * Exports the specified object using the specified server ref.
544 */
545 private static Remote exportObject(Remote obj, ActivatableServerRef sref)
546 throws RemoteException
547 {
548 // if obj extends Activatable, set its ref.
549 if (obj instanceof Activatable) {
550 ((Activatable) obj).ref = sref;
551
552 }
553 return sref.exportObject(obj, null, false);
554 }
555}
java/pkg/java/rmi/activation/ActivateFailedException.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivateFailedException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1998, 1999, 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
28/**
29 * This exception is thrown by the RMI runtime when activation
30 * fails during a remote call to an activatable object.
31 *
32 * @author Ann Wollrath
33 * @since 1.2
34 */
35public class ActivateFailedException extends java.rmi.RemoteException {
36
37 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
38 private static final long serialVersionUID = 4863550261346652506L;
39
40 /**
41 * Constructs an <code>ActivateFailedException</code> with the specified
42 * detail message.
43 *
44 * @param s the detail message
45 * @since 1.2
46 */
47 public ActivateFailedException(String s) {
48 super(s);
49 }
50
51 /**
52 * Constructs an <code>ActivateFailedException</code> with the specified
53 * detail message and nested exception.
54 *
55 * @param s the detail message
56 * @param ex the nested exception
57 * @since 1.2
58 */
59 public ActivateFailedException(String s, Exception ex) {
60 super(s, ex);
61 }
62}
java/pkg/java/rmi/activation/ActivationDesc.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationDesc.java+339−0
@@ -0,0 +1,339 @@
1/*
2 * Copyright (c) 1997, 2005, 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.io.Serializable;
29import java.rmi.MarshalledObject;
30
31/**
32 * An activation descriptor contains the information necessary to
33 * activate an object: <ul>
34 * <li> the object's group identifier,
35 * <li> the object's fully-qualified class name,
36 * <li> the object's code location (the location of the class), a codebase URL
37 * path,
38 * <li> the object's restart "mode", and,
39 * <li> a "marshalled" object that can contain object specific
40 * initialization data. </ul>
41 *
42 * <p>A descriptor registered with the activation system can be used to
43 * recreate/activate the object specified by the descriptor. The
44 * <code>MarshalledObject</code> in the object's descriptor is passed
45 * as the second argument to the remote object's constructor for
46 * object to use during reinitialization/activation.
47 *
48 * @author Ann Wollrath
49 * @since 1.2
50 * @see java.rmi.activation.Activatable
51 */
52public final class ActivationDesc implements Serializable {
53
54 /**
55 * @serial the group's identifier
56 */
57 private ActivationGroupID groupID;
58
59 /**
60 * @serial the object's class name
61 */
62 private String className;
63
64 /**
65 * @serial the object's code location
66 */
67 private String location;
68
69 /**
70 * @serial the object's initialization data
71 */
72 private MarshalledObject<?> data;
73
74 /**
75 * @serial indicates whether the object should be restarted
76 */
77 private boolean restart;
78
79 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
80 private static final long serialVersionUID = 7455834104417690957L;
81
82 /**
83 * Constructs an object descriptor for an object whose class name
84 * is <code>className</code>, that can be loaded from the
85 * code <code>location</code> and whose initialization
86 * information is <code>data</code>. If this form of the constructor
87 * is used, the <code>groupID</code> defaults to the current id for
88 * <code>ActivationGroup</code> for this VM. All objects with the
89 * same <code>ActivationGroupID</code> are activated in the same VM.
90 *
91 * <p>Note that objects specified by a descriptor created with this
92 * constructor will only be activated on demand (by default, the restart
93 * mode is <code>false</code>). If an activatable object requires restart
94 * services, use one of the <code>ActivationDesc</code> constructors that
95 * takes a boolean parameter, <code>restart</code>.
96 *
97 * <p> This constructor will throw <code>ActivationException</code> if
98 * there is no current activation group for this VM. To create an
99 * <code>ActivationGroup</code> use the
100 * <code>ActivationGroup.createGroup</code> method.
101 *
102 * @param className the object's fully package qualified class name
103 * @param location the object's code location (from where the class is
104 * loaded)
105 * @param data the object's initialization (activation) data contained
106 * in marshalled form.
107 * @exception ActivationException if the current group is nonexistent
108 * @since 1.2
109 */
110 public ActivationDesc(String className,
111 String location,
112 MarshalledObject<?> data)
113 throws ActivationException
114 {
115 this(ActivationGroup.internalCurrentGroupID(),
116 className, location, data, false);
117 }
118
119 /**
120 * Constructs an object descriptor for an object whose class name
121 * is <code>className</code>, that can be loaded from the
122 * code <code>location</code> and whose initialization
123 * information is <code>data</code>. If this form of the constructor
124 * is used, the <code>groupID</code> defaults to the current id for
125 * <code>ActivationGroup</code> for this VM. All objects with the
126 * same <code>ActivationGroupID</code> are activated in the same VM.
127 *
128 * <p>This constructor will throw <code>ActivationException</code> if
129 * there is no current activation group for this VM. To create an
130 * <code>ActivationGroup</code> use the
131 * <code>ActivationGroup.createGroup</code> method.
132 *
133 * @param className the object's fully package qualified class name
134 * @param location the object's code location (from where the class is
135 * loaded)
136 * @param data the object's initialization (activation) data contained
137 * in marshalled form.
138 * @param restart if true, the object is restarted (reactivated) when
139 * either the activator is restarted or the object's activation group
140 * is restarted after an unexpected crash; if false, the object is only
141 * activated on demand. Specifying <code>restart</code> to be
142 * <code>true</code> does not force an initial immediate activation of
143 * a newly registered object; initial activation is lazy.
144 * @exception ActivationException if the current group is nonexistent
145 * @since 1.2
146 */
147 public ActivationDesc(String className,
148 String location,
149 MarshalledObject<?> data,
150 boolean restart)
151 throws ActivationException
152 {
153 this(ActivationGroup.internalCurrentGroupID(),
154 className, location, data, restart);
155 }
156
157 /**
158 * Constructs an object descriptor for an object whose class name
159 * is <code>className</code> that can be loaded from the
160 * code <code>location</code> and whose initialization
161 * information is <code>data</code>. All objects with the same
162 * <code>groupID</code> are activated in the same Java VM.
163 *
164 * <p>Note that objects specified by a descriptor created with this
165 * constructor will only be activated on demand (by default, the restart
166 * mode is <code>false</code>). If an activatable object requires restart
167 * services, use one of the <code>ActivationDesc</code> constructors that
168 * takes a boolean parameter, <code>restart</code>.
169 *
170 * @param groupID the group's identifier (obtained from registering
171 * <code>ActivationSystem.registerGroup</code> method). The group
172 * indicates the VM in which the object should be activated.
173 * @param className the object's fully package-qualified class name
174 * @param location the object's code location (from where the class is
175 * loaded)
176 * @param data the object's initialization (activation) data contained
177 * in marshalled form.
178 * @exception IllegalArgumentException if <code>groupID</code> is null
179 * @since 1.2
180 */
181 public ActivationDesc(ActivationGroupID groupID,
182 String className,
183 String location,
184 MarshalledObject<?> data)
185 {
186 this(groupID, className, location, data, false);
187 }
188
189 /**
190 * Constructs an object descriptor for an object whose class name
191 * is <code>className</code> that can be loaded from the
192 * code <code>location</code> and whose initialization
193 * information is <code>data</code>. All objects with the same
194 * <code>groupID</code> are activated in the same Java VM.
195 *
196 * @param groupID the group's identifier (obtained from registering
197 * <code>ActivationSystem.registerGroup</code> method). The group
198 * indicates the VM in which the object should be activated.
199 * @param className the object's fully package-qualified class name
200 * @param location the object's code location (from where the class is
201 * loaded)
202 * @param data the object's initialization (activation) data contained
203 * in marshalled form.
204 * @param restart if true, the object is restarted (reactivated) when
205 * either the activator is restarted or the object's activation group
206 * is restarted after an unexpected crash; if false, the object is only
207 * activated on demand. Specifying <code>restart</code> to be
208 * <code>true</code> does not force an initial immediate activation of
209 * a newly registered object; initial activation is lazy.
210 * @exception IllegalArgumentException if <code>groupID</code> is null
211 * @since 1.2
212 */
213 public ActivationDesc(ActivationGroupID groupID,
214 String className,
215 String location,
216 MarshalledObject<?> data,
217 boolean restart)
218 {
219 if (groupID == null)
220 throw new IllegalArgumentException("groupID can't be null");
221 this.groupID = groupID;
222 this.className = className;
223 this.location = location;
224 this.data = data;
225 this.restart = restart;
226 }
227
228 /**
229 * Returns the group identifier for the object specified by this
230 * descriptor. A group provides a way to aggregate objects into a
231 * single Java virtual machine. RMI creates/activates objects with
232 * the same <code>groupID</code> in the same virtual machine.
233 *
234 * @return the group identifier
235 * @since 1.2
236 */
237 public ActivationGroupID getGroupID() {
238 return groupID;
239 }
240
241 /**
242 * Returns the class name for the object specified by this
243 * descriptor.
244 * @return the class name
245 * @since 1.2
246 */
247 public String getClassName() {
248 return className;
249 }
250
251 /**
252 * Returns the code location for the object specified by
253 * this descriptor.
254 * @return the code location
255 * @since 1.2
256 */
257 public String getLocation() {
258 return location;
259 }
260
261 /**
262 * Returns a "marshalled object" containing intialization/activation
263 * data for the object specified by this descriptor.
264 * @return the object specific "initialization" data
265 * @since 1.2
266 */
267 public MarshalledObject<?> getData() {
268 return data;
269 }
270
271 /**
272 * Returns the "restart" mode of the object associated with
273 * this activation descriptor.
274 *
275 * @return true if the activatable object associated with this
276 * activation descriptor is restarted via the activation
277 * daemon when either the daemon comes up or the object's group
278 * is restarted after an unexpected crash; otherwise it returns false,
279 * meaning that the object is only activated on demand via a
280 * method call. Note that if the restart mode is <code>true</code>, the
281 * activator does not force an initial immediate activation of
282 * a newly registered object; initial activation is lazy.
283 * @since 1.2
284 */
285 public boolean getRestartMode() {
286 return restart;
287 }
288
289 /**
290 * Compares two activation descriptors for content equality.
291 *
292 * @param obj the Object to compare with
293 * @return true if these Objects are equal; false otherwise.
294 * @see java.util.Hashtable
295 * @since 1.2
296 */
297 public boolean equals(Object obj) {
298
299 if (obj instanceof ActivationDesc) {
300 ActivationDesc desc = (ActivationDesc) obj;
301 return
302 ((groupID == null ? desc.groupID == null :
303 groupID.equals(desc.groupID)) &&
304 (className == null ? desc.className == null :
305 className.equals(desc.className)) &&
306 (location == null ? desc.location == null:
307 location.equals(desc.location)) &&
308 (data == null ? desc.data == null :
309 data.equals(desc.data)) &&
310 (restart == desc.restart));
311
312 } else {
313 return false;
314 }
315 }
316
317 /**
318 * Return the same hashCode for similar <code>ActivationDesc</code>s.
319 * @return an integer
320 * @see java.util.Hashtable
321 */
322 public int hashCode() {
323 return ((location == null
324 ? 0
325 : location.hashCode() << 24) ^
326 (groupID == null
327 ? 0
328 : groupID.hashCode() << 16) ^
329 (className == null
330 ? 0
331 : className.hashCode() << 9) ^
332 (data == null
333 ? 0
334 : data.hashCode() << 1) ^
335 (restart
336 ? 1
337 : 0));
338 }
339}
java/pkg/java/rmi/activation/ActivationException.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationException.java+118−0
@@ -0,0 +1,118 @@
1/*
2 * Copyright (c) 1997, 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.activation;
27
28/**
29 * General exception used by the activation interfaces.
30 *
31 * <p>As of release 1.4, this exception has been retrofitted to conform to
32 * the general purpose exception-chaining mechanism. The "detail exception"
33 * that may be provided at construction time and accessed via the public
34 * {@link #detail} field is now known as the <i>cause</i>, and may be
35 * accessed via the {@link Throwable#getCause()} method, as well as
36 * the aforementioned "legacy field."
37 *
38 * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
39 * instance of <code>ActivationException</code> always throws {@link
40 * IllegalStateException}.
41 *
42 * @author Ann Wollrath
43 * @since 1.2
44 */
45public class ActivationException extends Exception {
46
47 /**
48 * The cause of the activation exception.
49 *
50 * <p>This field predates the general-purpose exception chaining facility.
51 * The {@link Throwable#getCause()} method is now the preferred means of
52 * obtaining this information.
53 *
54 * @serial
55 */
56 public Throwable detail;
57
58 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
59 private static final long serialVersionUID = -4320118837291406071L;
60
61 /**
62 * Constructs an <code>ActivationException</code>.
63 */
64 public ActivationException() {
65 initCause(null); // Disallow subsequent initCause
66 }
67
68 /**
69 * Constructs an <code>ActivationException</code> with the specified
70 * detail message.
71 *
72 * @param s the detail message
73 */
74 public ActivationException(String s) {
75 super(s);
76 initCause(null); // Disallow subsequent initCause
77 }
78
79 /**
80 * Constructs an <code>ActivationException</code> with the specified
81 * detail message and cause. This constructor sets the {@link #detail}
82 * field to the specified <code>Throwable</code>.
83 *
84 * @param s the detail message
85 * @param cause the cause
86 */
87 public ActivationException(String s, Throwable cause) {
88 super(s);
89 initCause(null); // Disallow subsequent initCause
90 detail = cause;
91 }
92
93 /**
94 * Returns the detail message, including the message from the cause, if
95 * any, of this exception.
96 *
97 * @return the detail message
98 */
99 public String getMessage() {
100 if (detail == null)
101 return super.getMessage();
102 else
103 return super.getMessage() +
104 "; nested exception is: \n\t" +
105 detail.toString();
106 }
107
108 /**
109 * Returns the cause of this exception. This method returns the value
110 * of the {@link #detail} field.
111 *
112 * @return the cause, which may be <tt>null</tt>.
113 * @since 1.4
114 */
115 public Throwable getCause() {
116 return detail;
117 }
118}
java/pkg/java/rmi/activation/ActivationGroup.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationGroup.java+528−0
@@ -0,0 +1,528 @@
1/*
2 * Copyright (c) 1997, 2005, 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.lang.reflect.Constructor;
29import java.lang.reflect.InvocationTargetException;
30import java.rmi.MarshalledObject;
31import java.rmi.Naming;
32import java.rmi.Remote;
33import java.rmi.RemoteException;
34import java.rmi.activation.UnknownGroupException;
35import java.rmi.activation.UnknownObjectException;
36import java.rmi.server.RMIClassLoader;
37import java.rmi.server.UnicastRemoteObject;
38import java.security.AccessController;
39import sun.security.action.GetIntegerAction;
40
41/**
42 * An <code>ActivationGroup</code> is responsible for creating new
43 * instances of "activatable" objects in its group, informing its
44 * <code>ActivationMonitor</code> when either: its object's become
45 * active or inactive, or the group as a whole becomes inactive. <p>
46 *
47 * An <code>ActivationGroup</code> is <i>initially</i> created in one
48 * of several ways: <ul>
49 * <li>as a side-effect of creating an <code>ActivationDesc</code>
50 * without an explicit <code>ActivationGroupID</code> for the
51 * first activatable object in the group, or
52 * <li>via the <code>ActivationGroup.createGroup</code> method
53 * <li>as a side-effect of activating the first object in a group
54 * whose <code>ActivationGroupDesc</code> was only registered.</ul><p>
55 *
56 * Only the activator can <i>recreate</i> an
57 * <code>ActivationGroup</code>. The activator spawns, as needed, a
58 * separate VM (as a child process, for example) for each registered
59 * activation group and directs activation requests to the appropriate
60 * group. It is implementation specific how VMs are spawned. An
61 * activation group is created via the
62 * <code>ActivationGroup.createGroup</code> static method. The
63 * <code>createGroup</code> method has two requirements on the group
64 * to be created: 1) the group must be a concrete subclass of
65 * <code>ActivationGroup</code>, and 2) the group must have a
66 * constructor that takes two arguments:
67 *
68 * <ul>
69 * <li> the group's <code>ActivationGroupID</code>, and
70 * <li> the group's initialization data (in a
71 * <code>java.rmi.MarshalledObject</code>)</ul><p>
72 *
73 * When created, the default implementation of
74 * <code>ActivationGroup</code> will override the system properties
75 * with the properties requested when its
76 * <code>ActivationGroupDesc</code> was created, and will set a
77 * <code>java.rmi.RMISecurityManager</code> as the default system
78 * security manager. If your application requires specific properties
79 * to be set when objects are activated in the group, the application
80 * should create a special <code>Properties</code> object containing
81 * these properties, then create an <code>ActivationGroupDesc</code>
82 * with the <code>Properties</code> object, and use
83 * <code>ActivationGroup.createGroup</code> before creating any
84 * <code>ActivationDesc</code>s (before the default
85 * <code>ActivationGroupDesc</code> is created). If your application
86 * requires the use of a security manager other than
87 * <code>java.rmi.RMISecurityManager</code>, in the
88 * ActivativationGroupDescriptor properties list you can set
89 * <code>java.security.manager</code> property to the name of the security
90 * manager you would like to install.
91 *
92 * @author Ann Wollrath
93 * @see ActivationInstantiator
94 * @see ActivationGroupDesc
95 * @see ActivationGroupID
96 * @since 1.2
97 */
98public abstract class ActivationGroup
99 extends UnicastRemoteObject
100 implements ActivationInstantiator
101{
102 /**
103 * @serial the group's identifier
104 */
105 private ActivationGroupID groupID;
106
107 /**
108 * @serial the group's monitor
109 */
110 private ActivationMonitor monitor;
111
112 /**
113 * @serial the group's incarnation number
114 */
115 private long incarnation;
116
117 /** the current activation group for this VM */
118 private static ActivationGroup currGroup;
119 /** the current group's identifier */
120 private static ActivationGroupID currGroupID;
121 /** the current group's activation system */
122 private static ActivationSystem currSystem;
123 /** used to control a group being created only once */
124 private static boolean canCreate = true;
125
126 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
127 private static final long serialVersionUID = -7696947875314805420L;
128
129 /**
130 * Constructs an activation group with the given activation group
131 * identifier. The group is exported as a
132 * <code>java.rmi.server.UnicastRemoteObject</code>.
133 *
134 * @param groupID the group's identifier
135 * @throws RemoteException if this group could not be exported
136 * @since 1.2
137 */
138 protected ActivationGroup(ActivationGroupID groupID)
139 throws RemoteException
140 {
141 // call super constructor to export the object
142 super();
143 this.groupID = groupID;
144 }
145
146 /**
147 * The group's <code>inactiveObject</code> method is called
148 * indirectly via a call to the <code>Activatable.inactive</code>
149 * method. A remote object implementation must call
150 * <code>Activatable</code>'s <code>inactive</code> method when
151 * that object deactivates (the object deems that it is no longer
152 * active). If the object does not call
153 * <code>Activatable.inactive</code> when it deactivates, the
154 * object will never be garbage collected since the group keeps
155 * strong references to the objects it creates. <p>
156 *
157 * <p>The group's <code>inactiveObject</code> method unexports the
158 * remote object from the RMI runtime so that the object can no
159 * longer receive incoming RMI calls. An object will only be unexported
160 * if the object has no pending or executing calls.
161 * The subclass of <code>ActivationGroup</code> must override this
162 * method and unexport the object. <p>
163 *
164 * <p>After removing the object from the RMI runtime, the group
165 * must inform its <code>ActivationMonitor</code> (via the monitor's
166 * <code>inactiveObject</code> method) that the remote object is
167 * not currently active so that the remote object will be
168 * re-activated by the activator upon a subsequent activation
169 * request.<p>
170 *
171 * <p>This method simply informs the group's monitor that the object
172 * is inactive. It is up to the concrete subclass of ActivationGroup
173 * to fulfill the additional requirement of unexporting the object. <p>
174 *
175 * @param id the object's activation identifier
176 * @return true if the object was successfully deactivated; otherwise
177 * returns false.
178 * @exception UnknownObjectException if object is unknown (may already
179 * be inactive)
180 * @exception RemoteException if call informing monitor fails
181 * @exception ActivationException if group is inactive
182 * @since 1.2
183 */
184 public boolean inactiveObject(ActivationID id)
185 throws ActivationException, UnknownObjectException, RemoteException
186 {
187 getMonitor().inactiveObject(id);
188 return true;
189 }
190
191 /**
192 * The group's <code>activeObject</code> method is called when an
193 * object is exported (either by <code>Activatable</code> object
194 * construction or an explicit call to
195 * <code>Activatable.exportObject</code>. The group must inform its
196 * <code>ActivationMonitor</code> that the object is active (via
197 * the monitor's <code>activeObject</code> method) if the group
198 * hasn't already done so.
199 *
200 * @param id the object's identifier
201 * @param obj the remote object implementation
202 * @exception UnknownObjectException if object is not registered
203 * @exception RemoteException if call informing monitor fails
204 * @exception ActivationException if group is inactive
205 * @since 1.2
206 */
207 public abstract void activeObject(ActivationID id, Remote obj)
208 throws ActivationException, UnknownObjectException, RemoteException;
209
210 /**
211 * Create and set the activation group for the current VM. The
212 * activation group can only be set if it is not currently set.
213 * An activation group is set using the <code>createGroup</code>
214 * method when the <code>Activator</code> initiates the
215 * re-creation of an activation group in order to carry out
216 * incoming <code>activate</code> requests. A group must first be
217 * registered with the <code>ActivationSystem</code> before it can
218 * be created via this method.
219 *
220 * <p>The group class specified by the
221 * <code>ActivationGroupDesc</code> must be a concrete subclass of
222 * <code>ActivationGroup</code> and have a public constructor that
223 * takes two arguments: the <code>ActivationGroupID</code> for the
224 * group and the <code>MarshalledObject</code> containing the
225 * group's initialization data (obtained from the
226 * <code>ActivationGroupDesc</code>.
227 *
228 * <p>If the group class name specified in the
229 * <code>ActivationGroupDesc</code> is <code>null</code>, then
230 * this method will behave as if the group descriptor contained
231 * the name of the default activation group implementation class.
232 *
233 * <p>Note that if your application creates its own custom
234 * activation group, a security manager must be set for that
235 * group. Otherwise objects cannot be activated in the group.
236 * <code>java.rmi.RMISecurityManager</code> is set by default.
237 *
238 * <p>If a security manager is already set in the group VM, this
239 * method first calls the security manager's
240 * <code>checkSetFactory</code> method. This could result in a
241 * <code>SecurityException</code>. If your application needs to
242 * set a different security manager, you must ensure that the
243 * policy file specified by the group's
244 * <code>ActivationGroupDesc</code> grants the group the necessary
245 * permissions to set a new security manager. (Note: This will be
246 * necessary if your group downloads and sets a security manager).
247 *
248 * <p>After the group is created, the
249 * <code>ActivationSystem</code> is informed that the group is
250 * active by calling the <code>activeGroup</code> method which
251 * returns the <code>ActivationMonitor</code> for the group. The
252 * application need not call <code>activeGroup</code>
253 * independently since it is taken care of by this method.
254 *
255 * <p>Once a group is created, subsequent calls to the
256 * <code>currentGroupID</code> method will return the identifier
257 * for this group until the group becomes inactive.
258 *
259 * @param id the activation group's identifier
260 * @param desc the activation group's descriptor
261 * @param incarnation the group's incarnation number (zero on group's
262 * initial creation)
263 * @return the activation group for the VM
264 * @exception ActivationException if group already exists or if error
265 * occurs during group creation
266 * @exception SecurityException if permission to create group is denied.
267 * (Note: The default implementation of the security manager
268 * <code>checkSetFactory</code>
269 * method requires the RuntimePermission "setFactory")
270 * @see SecurityManager#checkSetFactory
271 * @since 1.2
272 */
273 public static synchronized
274 ActivationGroup createGroup(ActivationGroupID id,
275 final ActivationGroupDesc desc,
276 long incarnation)
277 throws ActivationException
278 {
279 SecurityManager security = System.getSecurityManager();
280 if (security != null)
281 security.checkSetFactory();
282
283 if (currGroup != null)
284 throw new ActivationException("group already exists");
285
286 if (canCreate == false)
287 throw new ActivationException("group deactivated and " +
288 "cannot be recreated");
289
290 try {
291 // load group's class
292 String groupClassName = desc.getClassName();
293 Class<? extends ActivationGroup> cl;
294 Class<? extends ActivationGroup> defaultGroupClass =
295 sun.rmi.server.ActivationGroupImpl.class;
296 if (groupClassName == null || // see 4252236
297 groupClassName.equals(defaultGroupClass.getName()))
298 {
299 cl = defaultGroupClass;
300 } else {
301 Class<?> cl0;
302 try {
303 cl0 = RMIClassLoader.loadClass(desc.getLocation(),
304 groupClassName);
305 } catch (Exception ex) {
306 throw new ActivationException(
307 "Could not load group implementation class", ex);
308 }
309 if (ActivationGroup.class.isAssignableFrom(cl0)) {
310 cl = cl0.asSubclass(ActivationGroup.class);
311 } else {
312 throw new ActivationException("group not correct class: " +
313 cl0.getName());
314 }
315 }
316
317 // create group
318 Constructor<? extends ActivationGroup> constructor =
319 cl.getConstructor(ActivationGroupID.class,
320 MarshalledObject.class);
321 ActivationGroup newGroup =
322 constructor.newInstance(id, desc.getData());
323 currSystem = id.getSystem();
324 newGroup.incarnation = incarnation;
325 newGroup.monitor =
326 currSystem.activeGroup(id, newGroup, incarnation);
327 currGroup = newGroup;
328 currGroupID = id;
329 canCreate = false;
330 } catch (InvocationTargetException e) {
331 e.getTargetException().printStackTrace();
332 throw new ActivationException("exception in group constructor",
333 e.getTargetException());
334
335 } catch (ActivationException e) {
336 throw e;
337
338 } catch (Exception e) {
339 throw new ActivationException("exception creating group", e);
340 }
341
342 return currGroup;
343 }
344
345 /**
346 * Returns the current activation group's identifier. Returns null
347 * if no group is currently active for this VM.
348 * @return the activation group's identifier
349 * @since 1.2
350 */
351 public static synchronized ActivationGroupID currentGroupID() {
352 return currGroupID;
353 }
354
355 /**
356 * Returns the activation group identifier for the VM. If an
357 * activation group does not exist for this VM, a default
358 * activation group is created. A group can be created only once,
359 * so if a group has already become active and deactivated.
360 *
361 * @return the activation group identifier
362 * @exception ActivationException if error occurs during group
363 * creation, if security manager is not set, or if the group
364 * has already been created and deactivated.
365 */
366 static synchronized ActivationGroupID internalCurrentGroupID()
367 throws ActivationException
368 {
369 if (currGroupID == null)
370 throw new ActivationException("nonexistent group");
371
372 return currGroupID;
373 }
374
375 /**
376 * Set the activation system for the VM. The activation system can
377 * only be set it if no group is currently active. If the activation
378 * system is not set via this call, then the <code>getSystem</code>
379 * method attempts to obtain a reference to the
380 * <code>ActivationSystem</code> by looking up the name
381 * "java.rmi.activation.ActivationSystem" in the Activator's
382 * registry. By default, the port number used to look up the
383 * activation system is defined by
384 * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be overridden
385 * by setting the property <code>java.rmi.activation.port</code>.
386 *
387 * <p>If there is a security manager, this method first
388 * calls the security manager's <code>checkSetFactory</code> method.
389 * This could result in a SecurityException.
390 *
391 * @param system remote reference to the <code>ActivationSystem</code>
392 * @exception ActivationException if activation system is already set
393 * @exception SecurityException if permission to set the activation system is denied.
394 * (Note: The default implementation of the security manager
395 * <code>checkSetFactory</code>
396 * method requires the RuntimePermission "setFactory")
397 * @see #getSystem
398 * @see SecurityManager#checkSetFactory
399 * @since 1.2
400 */
401 public static synchronized void setSystem(ActivationSystem system)
402 throws ActivationException
403 {
404 SecurityManager security = System.getSecurityManager();
405 if (security != null)
406 security.checkSetFactory();
407
408 if (currSystem != null)
409 throw new ActivationException("activation system already set");
410
411 currSystem = system;
412 }
413
414 /**
415 * Returns the activation system for the VM. The activation system
416 * may be set by the <code>setSystem</code> method. If the
417 * activation system is not set via the <code>setSystem</code>
418 * method, then the <code>getSystem</code> method attempts to
419 * obtain a reference to the <code>ActivationSystem</code> by
420 * looking up the name "java.rmi.activation.ActivationSystem" in
421 * the Activator's registry. By default, the port number used to
422 * look up the activation system is defined by
423 * <code>ActivationSystem.SYSTEM_PORT</code>. This port can be
424 * overridden by setting the property
425 * <code>java.rmi.activation.port</code>.
426 *
427 * @return the activation system for the VM/group
428 * @exception ActivationException if activation system cannot be
429 * obtained or is not bound
430 * (means that it is not running)
431 * @see #setSystem
432 * @since 1.2
433 */
434 public static synchronized ActivationSystem getSystem()
435 throws ActivationException
436 {
437 if (currSystem == null) {
438 try {
439 int port = AccessController.doPrivileged(
440 new GetIntegerAction("java.rmi.activation.port",
441 ActivationSystem.SYSTEM_PORT));
442 currSystem = (ActivationSystem)
443 Naming.lookup("//:" + port +
444 "/java.rmi.activation.ActivationSystem");
445 } catch (Exception e) {
446 throw new ActivationException(
447 "unable to obtain ActivationSystem", e);
448 }
449 }
450 return currSystem;
451 }
452
453 /**
454 * This protected method is necessary for subclasses to
455 * make the <code>activeObject</code> callback to the group's
456 * monitor. The call is simply forwarded to the group's
457 * <code>ActivationMonitor</code>.
458 *
459 * @param id the object's identifier
460 * @param mobj a marshalled object containing the remote object's stub
461 * @exception UnknownObjectException if object is not registered
462 * @exception RemoteException if call informing monitor fails
463 * @exception ActivationException if an activation error occurs
464 * @since 1.2
465 */
466 protected void activeObject(ActivationID id,
467 MarshalledObject<? extends Remote> mobj)
468 throws ActivationException, UnknownObjectException, RemoteException
469 {
470 getMonitor().activeObject(id, mobj);
471 }
472
473 /**
474 * This protected method is necessary for subclasses to
475 * make the <code>inactiveGroup</code> callback to the group's
476 * monitor. The call is simply forwarded to the group's
477 * <code>ActivationMonitor</code>. Also, the current group
478 * for the VM is set to null.
479 *
480 * @exception UnknownGroupException if group is not registered
481 * @exception RemoteException if call informing monitor fails
482 * @since 1.2
483 */
484 protected void inactiveGroup()
485 throws UnknownGroupException, RemoteException
486 {
487 try {
488 getMonitor().inactiveGroup(groupID, incarnation);
489 } finally {
490 destroyGroup();
491 }
492 }
493
494 /**
495 * Returns the monitor for the activation group.
496 */
497 private ActivationMonitor getMonitor() throws RemoteException {
498 synchronized (ActivationGroup.class) {
499 if (monitor != null) {
500 return monitor;
501 }
502 }
503 throw new RemoteException("monitor not received");
504 }
505
506 /**
507 * Destroys the current group.
508 */
509 private static synchronized void destroyGroup() {
510 currGroup = null;
511 currGroupID = null;
512 // NOTE: don't set currSystem to null since it may be needed
513 }
514
515 /**
516 * Returns the current group for the VM.
517 * @exception ActivationException if current group is null (not active)
518 */
519 static synchronized ActivationGroup currentGroup()
520 throws ActivationException
521 {
522 if (currGroup == null) {
523 throw new ActivationException("group is not active");
524 }
525 return currGroup;
526 }
527
528}
java/pkg/java/rmi/activation/ActivationGroupDesc$CommandEnvironment.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationGroupDesc.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationGroupDesc.java+370−0
@@ -0,0 +1,370 @@
1/*
2 * Copyright (c) 1997, 2008, 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.io.IOException;
29import java.io.ObjectInputStream;
30import java.io.Serializable;
31import java.rmi.MarshalledObject;
32import java.util.Arrays;
33import java.util.Properties;
34
35/**
36 * An activation group descriptor contains the information necessary to
37 * create/recreate an activation group in which to activate objects.
38 * Such a descriptor contains: <ul>
39 * <li> the group's class name,
40 * <li> the group's code location (the location of the group's class), and
41 * <li> a "marshalled" object that can contain group specific
42 * initialization data. </ul> <p>
43 *
44 * The group's class must be a concrete subclass of
45 * <code>ActivationGroup</code>. A subclass of
46 * <code>ActivationGroup</code> is created/recreated via the
47 * <code>ActivationGroup.createGroup</code> static method that invokes
48 * a special constructor that takes two arguments: <ul>
49 *
50 * <li> the group's <code>ActivationGroupID</code>, and
51 * <li> the group's initialization data (in a
52 * <code>java.rmi.MarshalledObject</code>)</ul><p>
53 *
54 * @author Ann Wollrath
55 * @since 1.2
56 * @see ActivationGroup
57 * @see ActivationGroupID
58 */
59public final class ActivationGroupDesc implements Serializable {
60
61 /**
62 * @serial The group's fully package qualified class name.
63 */
64 private String className;
65
66 /**
67 * @serial The location from where to load the group's class.
68 */
69 private String location;
70
71 /**
72 * @serial The group's initialization data.
73 */
74 private MarshalledObject<?> data;
75
76 /**
77 * @serial The controlling options for executing the VM in
78 * another process.
79 */
80 private CommandEnvironment env;
81
82 /**
83 * @serial A properties map which will override those set
84 * by default in the subprocess environment.
85 */
86 private Properties props;
87
88 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
89 private static final long serialVersionUID = -4936225423168276595L;
90
91 /**
92 * Constructs a group descriptor that uses the system defaults for group
93 * implementation and code location. Properties specify Java
94 * environment overrides (which will override system properties in
95 * the group implementation's VM). The command
96 * environment can control the exact command/options used in
97 * starting the child VM, or can be <code>null</code> to accept
98 * rmid's default.
99 *
100 * <p>This constructor will create an <code>ActivationGroupDesc</code>
101 * with a <code>null</code> group class name, which indicates the system's
102 * default <code>ActivationGroup</code> implementation.
103 *
104 * @param overrides the set of properties to set when the group is
105 * recreated.
106 * @param cmd the controlling options for executing the VM in
107 * another process (or <code>null</code>).
108 * @since 1.2
109 */
110 public ActivationGroupDesc(Properties overrides,
111 CommandEnvironment cmd)
112 {
113 this(null, null, null, overrides, cmd);
114 }
115
116 /**
117 * Specifies an alternate group implementation and execution
118 * environment to be used for the group.
119 *
120 * @param className the group's package qualified class name or
121 * <code>null</code>. A <code>null</code> group class name indicates
122 * the system's default <code>ActivationGroup</code> implementation.
123 * @param location the location from where to load the group's
124 * class
125 * @param data the group's initialization data contained in
126 * marshalled form (could contain properties, for example)
127 * @param overrides a properties map which will override those set
128 * by default in the subprocess environment (will be translated
129 * into <code>-D</code> options), or <code>null</code>.
130 * @param cmd the controlling options for executing the VM in
131 * another process (or <code>null</code>).
132 * @since 1.2
133 */
134 public ActivationGroupDesc(String className,
135 String location,
136 MarshalledObject<?> data,
137 Properties overrides,
138 CommandEnvironment cmd)
139 {
140 this.props = overrides;
141 this.env = cmd;
142 this.data = data;
143 this.location = location;
144 this.className = className;
145 }
146
147 /**
148 * Returns the group's class name (possibly <code>null</code>). A
149 * <code>null</code> group class name indicates the system's default
150 * <code>ActivationGroup</code> implementation.
151 * @return the group's class name
152 * @since 1.2
153 */
154 public String getClassName() {
155 return className;
156 }
157
158 /**
159 * Returns the group's code location.
160 * @return the group's code location
161 * @since 1.2
162 */
163 public String getLocation() {
164 return location;
165 }
166
167 /**
168 * Returns the group's initialization data.
169 * @return the group's initialization data
170 * @since 1.2
171 */
172 public MarshalledObject<?> getData() {
173 return data;
174 }
175
176 /**
177 * Returns the group's property-override list.
178 * @return the property-override list, or <code>null</code>
179 * @since 1.2
180 */
181 public Properties getPropertyOverrides() {
182 return (props != null) ? (Properties) props.clone() : null;
183 }
184
185 /**
186 * Returns the group's command-environment control object.
187 * @return the command-environment object, or <code>null</code>
188 * @since 1.2
189 */
190 public CommandEnvironment getCommandEnvironment() {
191 return this.env;
192 }
193
194
195 /**
196 * Startup options for ActivationGroup implementations.
197 *
198 * This class allows overriding default system properties and
199 * specifying implementation-defined options for ActivationGroups.
200 * @since 1.2
201 */
202 public static class CommandEnvironment implements Serializable {
203 private static final long serialVersionUID = 6165754737887770191L;
204
205 /**
206 * @serial
207 */
208 private String command;
209
210 /**
211 * @serial
212 */
213 private String[] options;
214
215 /**
216 * Create a CommandEnvironment with all the necessary
217 * information.
218 *
219 * @param cmdpath the name of the java executable, including
220 * the full path, or <code>null</code>, meaning "use rmid's default".
221 * The named program <em>must</em> be able to accept multiple
222 * <code>-Dpropname=value</code> options (as documented for the
223 * "java" tool)
224 *
225 * @param argv extra options which will be used in creating the
226 * ActivationGroup. Null has the same effect as an empty
227 * list.
228 * @since 1.2
229 */
230 public CommandEnvironment(String cmdpath,
231 String[] argv)
232 {
233 this.command = cmdpath; // might be null
234
235 // Hold a safe copy of argv in this.options
236 if (argv == null) {
237 this.options = new String[0];
238 } else {
239 this.options = new String[argv.length];
240 System.arraycopy(argv, 0, this.options, 0, argv.length);
241 }
242 }
243
244 /**
245 * Fetch the configured path-qualified java command name.
246 *
247 * @return the configured name, or <code>null</code> if configured to
248 * accept the default
249 * @since 1.2
250 */
251 public String getCommandPath() {
252 return (this.command);
253 }
254
255 /**
256 * Fetch the configured java command options.
257 *
258 * @return An array of the command options which will be passed
259 * to the new child command by rmid.
260 * Note that rmid may add other options before or after these
261 * options, or both.
262 * Never returns <code>null</code>.
263 * @since 1.2
264 */
265 public String[] getCommandOptions() {
266 return options.clone();
267 }
268
269 /**
270 * Compares two command environments for content equality.
271 *
272 * @param obj the Object to compare with
273 * @return true if these Objects are equal; false otherwise.
274 * @see java.util.Hashtable
275 * @since 1.2
276 */
277 public boolean equals(Object obj) {
278
279 if (obj instanceof CommandEnvironment) {
280 CommandEnvironment env = (CommandEnvironment) obj;
281 return
282 ((command == null ? env.command == null :
283 command.equals(env.command)) &&
284 Arrays.equals(options, env.options));
285 } else {
286 return false;
287 }
288 }
289
290 /**
291 * Return identical values for similar
292 * <code>CommandEnvironment</code>s.
293 * @return an integer
294 * @see java.util.Hashtable
295 */
296 public int hashCode()
297 {
298 // hash command and ignore possibly expensive options
299 return (command == null ? 0 : command.hashCode());
300 }
301
302 /**
303 * <code>readObject</code> for custom serialization.
304 *
305 * <p>This method reads this object's serialized form for this
306 * class as follows:
307 *
308 * <p>This method first invokes <code>defaultReadObject</code> on
309 * the specified object input stream, and if <code>options</code>
310 * is <code>null</code>, then <code>options</code> is set to a
311 * zero-length array of <code>String</code>.
312 */
313 private void readObject(ObjectInputStream in)
314 throws IOException, ClassNotFoundException
315 {
316 in.defaultReadObject();
317 if (options == null) {
318 options = new String[0];
319 }
320 }
321 }
322
323 /**
324 * Compares two activation group descriptors for content equality.
325 *
326 * @param obj the Object to compare with
327 * @return true if these Objects are equal; false otherwise.
328 * @see java.util.Hashtable
329 * @since 1.2
330 */
331 public boolean equals(Object obj) {
332
333 if (obj instanceof ActivationGroupDesc) {
334 ActivationGroupDesc desc = (ActivationGroupDesc) obj;
335 return
336 ((className == null ? desc.className == null :
337 className.equals(desc.className)) &&
338 (location == null ? desc.location == null :
339 location.equals(desc.location)) &&
340 (data == null ? desc.data == null : data.equals(desc.data)) &&
341 (env == null ? desc.env == null : env.equals(desc.env)) &&
342 (props == null ? desc.props == null :
343 props.equals(desc.props)));
344 } else {
345 return false;
346 }
347 }
348
349 /**
350 * Produce identical numbers for similar <code>ActivationGroupDesc</code>s.
351 * @return an integer
352 * @see java.util.Hashtable
353 */
354 public int hashCode() {
355 // hash location, className, data, and env
356 // but omit props (may be expensive)
357 return ((location == null
358 ? 0
359 : location.hashCode() << 24) ^
360 (env == null
361 ? 0
362 : env.hashCode() << 16) ^
363 (className == null
364 ? 0
365 : className.hashCode() << 8) ^
366 (data == null
367 ? 0
368 : data.hashCode()));
369 }
370}
java/pkg/java/rmi/activation/ActivationGroupID.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationGroupID.java+115−0
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) 1997, 1999, 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 * @since 1.2
67 */
68 public ActivationGroupID(ActivationSystem system) {
69 this.system = system;
70 }
71
72 /**
73 * Returns the group's activation system.
74 * @return the group's activation system
75 * @since 1.2
76 */
77 public ActivationSystem getSystem() {
78 return system;
79 }
80
81 /**
82 * Returns a hashcode for the group's identifier. Two group
83 * identifiers that refer to the same remote group will have the
84 * same hash code.
85 *
86 * @see java.util.Hashtable
87 * @since 1.2
88 */
89 public int hashCode() {
90 return uid.hashCode();
91 }
92
93 /**
94 * Compares two group identifiers for content equality.
95 * Returns true if both of the following conditions are true:
96 * 1) the unique identifiers are equivalent (by content), and
97 * 2) the activation system specified in each
98 * refers to the same remote object.
99 *
100 * @param obj the Object to compare with
101 * @return true if these Objects are equal; false otherwise.
102 * @see java.util.Hashtable
103 * @since 1.2
104 */
105 public boolean equals(Object obj) {
106 if (this == obj) {
107 return true;
108 } else if (obj instanceof ActivationGroupID) {
109 ActivationGroupID id = (ActivationGroupID)obj;
110 return (uid.equals(id.uid) && system.equals(id.system));
111 } else {
112 return false;
113 }
114 }
115}
java/pkg/java/rmi/activation/ActivationID.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationID.java+290−0
@@ -0,0 +1,290 @@
1/*
2 * Copyright (c) 1997, 2005, 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.io.IOException;
29import java.io.InvalidObjectException;
30import java.io.ObjectInputStream;
31import java.io.ObjectOutputStream;
32import java.io.Serializable;
33import java.lang.reflect.InvocationHandler;
34import java.lang.reflect.Proxy;
35import java.rmi.MarshalledObject;
36import java.rmi.Remote;
37import java.rmi.RemoteException;
38import java.rmi.UnmarshalException;
39import java.rmi.server.RemoteObject;
40import java.rmi.server.RemoteObjectInvocationHandler;
41import java.rmi.server.RemoteRef;
42import java.rmi.server.UID;
43
44/**
45 * Activation makes use of special identifiers to denote remote
46 * objects that can be activated over time. An activation identifier
47 * (an instance of the class <code>ActivationID</code>) contains several
48 * pieces of information needed for activating an object:
49 * <ul>
50 * <li> a remote reference to the object's activator (a {@link
51 * java.rmi.server.RemoteRef RemoteRef}
52 * instance), and
53 * <li> a unique identifier (a {@link java.rmi.server.UID UID}
54 * instance) for the object. </ul> <p>
55 *
56 * An activation identifier for an object can be obtained by registering
57 * an object with the activation system. Registration is accomplished
58 * in a few ways: <ul>
59 * <li>via the <code>Activatable.register</code> method
60 * <li>via the first <code>Activatable</code> constructor (that takes
61 * three arguments and both registers and exports the object, and
62 * <li>via the first <code>Activatable.exportObject</code> method
63 * that takes the activation descriptor, object and port as arguments;
64 * this method both registers and exports the object. </ul>
65 *
66 * @author Ann Wollrath
67 * @see Activatable
68 * @since 1.2
69 */
70public class ActivationID implements Serializable {
71 /**
72 * the object's activator
73 */
74 private transient Activator activator;
75
76 /**
77 * the object's unique id
78 */
79 private transient UID uid = new UID();
80
81 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
82 private static final long serialVersionUID = -4608673054848209235L;
83
84 /**
85 * The constructor for <code>ActivationID</code> takes a single
86 * argument, activator, that specifies a remote reference to the
87 * activator responsible for activating the object associated with
88 * this identifier. An instance of <code>ActivationID</code> is globally
89 * unique.
90 *
91 * @param activator reference to the activator responsible for
92 * activating the object
93 * @since 1.2
94 */
95 public ActivationID(Activator activator) {
96 this.activator = activator;
97 }
98
99 /**
100 * Activate the object for this id.
101 *
102 * @param force if true, forces the activator to contact the group
103 * when activating the object (instead of returning a cached reference);
104 * if false, returning a cached value is acceptable.
105 * @return the reference to the active remote object
106 * @exception ActivationException if activation fails
107 * @exception UnknownObjectException if the object is unknown
108 * @exception RemoteException if remote call fails
109 * @since 1.2
110 */
111 public Remote activate(boolean force)
112 throws ActivationException, UnknownObjectException, RemoteException
113 {
114 try {
115 MarshalledObject<? extends Remote> mobj =
116 activator.activate(this, force);
117 return mobj.get();
118 } catch (RemoteException e) {
119 throw e;
120 } catch (IOException e) {
121 throw new UnmarshalException("activation failed", e);
122 } catch (ClassNotFoundException e) {
123 throw new UnmarshalException("activation failed", e);
124 }
125
126 }
127
128 /**
129 * Returns a hashcode for the activation id. Two identifiers that
130 * refer to the same remote object will have the same hash code.
131 *
132 * @see java.util.Hashtable
133 * @since 1.2
134 */
135 public int hashCode() {
136 return uid.hashCode();
137 }
138
139 /**
140 * Compares two activation ids for content equality.
141 * Returns true if both of the following conditions are true:
142 * 1) the unique identifiers equivalent (by content), and
143 * 2) the activator specified in each identifier
144 * refers to the same remote object.
145 *
146 * @param obj the Object to compare with
147 * @return true if these Objects are equal; false otherwise.
148 * @see java.util.Hashtable
149 * @since 1.2
150 */
151 public boolean equals(Object obj) {
152 if (obj instanceof ActivationID) {
153 ActivationID id = (ActivationID) obj;
154 return (uid.equals(id.uid) && activator.equals(id.activator));
155 } else {
156 return false;
157 }
158 }
159
160 /**
161 * <code>writeObject</code> for custom serialization.
162 *
163 * <p>This method writes this object's serialized form for
164 * this class as follows:
165 *
166 * <p>The <code>writeObject</code> method is invoked on
167 * <code>out</code> passing this object's unique identifier
168 * (a {@link java.rmi.server.UID UID} instance) as the argument.
169 *
170 * <p>Next, the {@link
171 * java.rmi.server.RemoteRef#getRefClass(java.io.ObjectOutput)
172 * getRefClass} method is invoked on the activator's
173 * <code>RemoteRef</code> instance to obtain its external ref
174 * type name. Next, the <code>writeUTF</code> method is
175 * invoked on <code>out</code> with the value returned by
176 * <code>getRefClass</code>, and then the
177 * <code>writeExternal</code> method is invoked on the
178 * <code>RemoteRef</code> instance passing <code>out</code>
179 * as the argument.
180 *
181 * @serialData The serialized data for this class comprises a
182 * <code>java.rmi.server.UID</code> (written with
183 * <code>ObjectOutput.writeObject</code>) followed by the
184 * external ref type name of the activator's
185 * <code>RemoteRef</code> instance (a string written with
186 * <code>ObjectOutput.writeUTF</code>), followed by the
187 * external form of the <code>RemoteRef</code> instance as
188 * written by its <code>writeExternal</code> method.
189 *
190 * <p>The external ref type name of the
191 * <code>RemoteRef</Code> instance is
192 * determined using the definitions of external ref type
193 * names specified in the {@link java.rmi.server.RemoteObject
194 * RemoteObject} <code>writeObject</code> method
195 * <b>serialData</b> specification. Similarly, the data
196 * written by the <code>writeExternal</code> method and read
197 * by the <code>readExternal</code> method of
198 * <code>RemoteRef</code> implementation classes
199 * corresponding to each of the defined external ref type
200 * names is specified in the {@link
201 * java.rmi.server.RemoteObject RemoteObject}
202 * <code>writeObject</code> method <b>serialData</b>
203 * specification.
204 **/
205 private void writeObject(ObjectOutputStream out)
206 throws IOException, ClassNotFoundException
207 {
208 out.writeObject(uid);
209
210 RemoteRef ref;
211 if (activator instanceof RemoteObject) {
212 ref = ((RemoteObject) activator).getRef();
213 } else if (Proxy.isProxyClass(activator.getClass())) {
214 InvocationHandler handler = Proxy.getInvocationHandler(activator);
215 if (!(handler instanceof RemoteObjectInvocationHandler)) {
216 throw new InvalidObjectException(
217 "unexpected invocation handler");
218 }
219 ref = ((RemoteObjectInvocationHandler) handler).getRef();
220
221 } else {
222 throw new InvalidObjectException("unexpected activator type");
223 }
224 out.writeUTF(ref.getRefClass(out));
225 ref.writeExternal(out);
226 }
227
228 /**
229 * <code>readObject</code> for custom serialization.
230 *
231 * <p>This method reads this object's serialized form for this
232 * class as follows:
233 *
234 * <p>The <code>readObject</code> method is invoked on
235 * <code>in</code> to read this object's unique identifier
236 * (a {@link java.rmi.server.UID UID} instance).
237 *
238 * <p>Next, the <code>readUTF</code> method is invoked on
239 * <code>in</code> to read the external ref type name of the
240 * <code>RemoteRef</code> instance for this object's
241 * activator. Next, the <code>RemoteRef</code>
242 * instance is created of an implementation-specific class
243 * corresponding to the external ref type name (returned by
244 * <code>readUTF</code>), and the <code>readExternal</code>
245 * method is invoked on that <code>RemoteRef</code> instance
246 * to read the external form corresponding to the external
247 * ref type name.
248 *
249 * <p>Note: If the external ref type name is
250 * <code>"UnicastRef"</code>, <code>"UnicastServerRef"</code>,
251 * <code>"UnicastRef2"</code>, <code>"UnicastServerRef2"</code>,
252 * or <code>"ActivatableRef"</code>, a corresponding
253 * implementation-specific class must be found, and its
254 * <code>readExternal</code> method must read the serial data
255 * for that external ref type name as specified to be written
256 * in the <b>serialData</b> documentation for this class.
257 * If the external ref type name is any other string (of non-zero
258 * length), a <code>ClassNotFoundException</code> will be thrown,
259 * unless the implementation provides an implementation-specific
260 * class corresponding to that external ref type name, in which
261 * case the <code>RemoteRef</code> will be an instance of
262 * that implementation-specific class.
263 */
264 private void readObject(ObjectInputStream in)
265 throws IOException, ClassNotFoundException
266 {
267 uid = (UID)in.readObject();
268
269 try {
270 Class<? extends RemoteRef> refClass =
271 Class.forName(RemoteRef.packagePrefix + "." + in.readUTF())
272 .asSubclass(RemoteRef.class);
273 RemoteRef ref = refClass.newInstance();
274 ref.readExternal(in);
275 activator = (Activator)
276 Proxy.newProxyInstance(null,
277 new Class<?>[] { Activator.class },
278 new RemoteObjectInvocationHandler(ref));
279
280 } catch (InstantiationException e) {
281 throw (IOException)
282 new InvalidObjectException(
283 "Unable to create remote reference").initCause(e);
284 } catch (IllegalAccessException e) {
285 throw (IOException)
286 new InvalidObjectException(
287 "Unable to create remote reference").initCause(e);
288 }
289 }
290}
java/pkg/java/rmi/activation/ActivationInstantiator.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationInstantiator.java+76−0
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) 1997, 2005, 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.MarshalledObject;
29import java.rmi.Remote;
30import java.rmi.RemoteException;
31
32/**
33 * An <code>ActivationInstantiator</code> is responsible for creating
34 * instances of "activatable" objects. A concrete subclass of
35 * <code>ActivationGroup</code> implements the <code>newInstance</code>
36 * method to handle creating objects within the group.
37 *
38 * @author Ann Wollrath
39 * @see ActivationGroup
40 * @since 1.2
41 */
42public interface ActivationInstantiator extends Remote {
43
44 /**
45 * The activator calls an instantiator's <code>newInstance</code>
46 * method in order to recreate in that group an object with the
47 * activation identifier, <code>id</code>, and descriptor,
48 * <code>desc</code>. The instantiator is responsible for: <ul>
49 *
50 * <li> determining the class for the object using the descriptor's
51 * <code>getClassName</code> method,
52 *
53 * <li> loading the class from the code location obtained from the
54 * descriptor (using the <code>getLocation</code> method),
55 *
56 * <li> creating an instance of the class by invoking the special
57 * "activation" constructor of the object's class that takes two
58 * arguments: the object's <code>ActivationID</code>, and the
59 * <code>MarshalledObject</code> containing object specific
60 * initialization data, and
61 *
62 * <li> returning a MarshalledObject containing the stub for the
63 * remote object it created </ul>
64 *
65 * @param id the object's activation identifier
66 * @param desc the object's descriptor
67 * @return a marshalled object containing the serialized
68 * representation of remote object's stub
69 * @exception ActivationException if object activation fails
70 * @exception RemoteException if remote call fails
71 * @since 1.2
72 */
73 public MarshalledObject<? extends Remote> newInstance(ActivationID id,
74 ActivationDesc desc)
75 throws ActivationException, RemoteException;
76}
java/pkg/java/rmi/activation/ActivationMonitor.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationMonitor.java+108−0
@@ -0,0 +1,108 @@
1/*
2 * Copyright (c) 1997, 2005, 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.MarshalledObject;
29import java.rmi.Remote;
30import java.rmi.RemoteException;
31import java.rmi.activation.UnknownGroupException;
32import java.rmi.activation.UnknownObjectException;
33
34/**
35 * An <code>ActivationMonitor</code> is specific to an
36 * <code>ActivationGroup</code> and is obtained when a group is
37 * reported active via a call to
38 * <code>ActivationSystem.activeGroup</code> (this is done
39 * internally). An activation group is responsible for informing its
40 * <code>ActivationMonitor</code> when either: its objects become active or
41 * inactive, or the group as a whole becomes inactive.
42 *
43 * @author Ann Wollrath
44 * @see Activator
45 * @see ActivationSystem
46 * @see ActivationGroup
47 * @since 1.2
48 */
49public interface ActivationMonitor extends Remote {
50
51 /**
52 * An activation group calls its monitor's
53 * <code>inactiveObject</code> method when an object in its group
54 * becomes inactive (deactivates). An activation group discovers
55 * that an object (that it participated in activating) in its VM
56 * is no longer active, via calls to the activation group's
57 * <code>inactiveObject</code> method. <p>
58 *
59 * The <code>inactiveObject</code> call informs the
60 * <code>ActivationMonitor</code> that the remote object reference
61 * it holds for the object with the activation identifier,
62 * <code>id</code>, is no longer valid. The monitor considers the
63 * reference associated with <code>id</code> as a stale reference.
64 * Since the reference is considered stale, a subsequent
65 * <code>activate</code> call for the same activation identifier
66 * results in re-activating the remote object.<p>
67 *
68 * @param id the object's activation identifier
69 * @exception UnknownObjectException if object is unknown
70 * @exception RemoteException if remote call fails
71 * @since 1.2
72 */
73 public void inactiveObject(ActivationID id)
74 throws UnknownObjectException, RemoteException;
75
76 /**
77 * Informs that an object is now active. An <code>ActivationGroup</code>
78 * informs its monitor if an object in its group becomes active by
79 * other means than being activated directly (i.e., the object
80 * is registered and "activated" itself).
81 *
82 * @param id the active object's id
83 * @param obj the marshalled form of the object's stub
84 * @exception UnknownObjectException if object is unknown
85 * @exception RemoteException if remote call fails
86 * @since 1.2
87 */
88 public void activeObject(ActivationID id,
89 MarshalledObject<? extends Remote> obj)
90 throws UnknownObjectException, RemoteException;
91
92 /**
93 * Informs that the group is now inactive. The group will be
94 * recreated upon a subsequent request to activate an object
95 * within the group. A group becomes inactive when all objects
96 * in the group report that they are inactive.
97 *
98 * @param id the group's id
99 * @param incarnation the group's incarnation number
100 * @exception UnknownGroupException if group is unknown
101 * @exception RemoteException if remote call fails
102 * @since 1.2
103 */
104 public void inactiveGroup(ActivationGroupID id,
105 long incarnation)
106 throws UnknownGroupException, RemoteException;
107
108}
java/pkg/java/rmi/activation/ActivationSystem.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/ActivationSystem.java+229−0
@@ -0,0 +1,229 @@
1/*
2 * Copyright (c) 1997, 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.activation;
27
28import java.rmi.Remote;
29import java.rmi.RemoteException;
30import java.rmi.activation.UnknownGroupException;
31import java.rmi.activation.UnknownObjectException;
32
33/**
34 * The <code>ActivationSystem</code> provides a means for registering
35 * groups and "activatable" objects to be activated within those groups.
36 * The <code>ActivationSystem</code> works closely with the
37 * <code>Activator</code>, which activates objects registered via the
38 * <code>ActivationSystem</code>, and the <code>ActivationMonitor</code>,
39 * which obtains information about active and inactive objects,
40 * and inactive groups.
41 *
42 * @author Ann Wollrath
43 * @see Activator
44 * @see ActivationMonitor
45 * @since 1.2
46 */
47public interface ActivationSystem extends Remote {
48
49 /** The port to lookup the activation system. */
50 public static final int SYSTEM_PORT = 1098;
51
52 /**
53 * The <code>registerObject</code> method is used to register an
54 * activation descriptor, <code>desc</code>, and obtain an
55 * activation identifier for a activatable remote object. The
56 * <code>ActivationSystem</code> creates an
57 * <code>ActivationID</code> (a activation identifier) for the
58 * object specified by the descriptor, <code>desc</code>, and
59 * records, in stable storage, the activation descriptor and its
60 * associated identifier for later use. When the <code>Activator</code>
61 * receives an <code>activate</code> request for a specific identifier, it
62 * looks up the activation descriptor (registered previously) for
63 * the specified identifier and uses that information to activate
64 * the object. <p>
65 *
66 * @param desc the object's activation descriptor
67 * @return the activation id that can be used to activate the object
68 * @exception ActivationException if registration fails (e.g., database
69 * update failure, etc).
70 * @exception UnknownGroupException if group referred to in
71 * <code>desc</code> is not registered with this system
72 * @exception RemoteException if remote call fails
73 * @since 1.2
74 */
75 public ActivationID registerObject(ActivationDesc desc)
76 throws ActivationException, UnknownGroupException, RemoteException;
77
78 /**
79 * Remove the activation id and associated descriptor previously
80 * registered with the <code>ActivationSystem</code>; the object
81 * can no longer be activated via the object's activation id.
82 *
83 * @param id the object's activation id (from previous registration)
84 * @exception ActivationException if unregister fails (e.g., database
85 * update failure, etc).
86 * @exception UnknownObjectException if object is unknown (not registered)
87 * @exception RemoteException if remote call fails
88 * @since 1.2
89 */
90 public void unregisterObject(ActivationID id)
91 throws ActivationException, UnknownObjectException, RemoteException;
92
93 /**
94 * Register the activation group. An activation group must be
95 * registered with the <code>ActivationSystem</code> before objects
96 * can be registered within that group.
97 *
98 * @param desc the group's descriptor
99 * @return an identifier for the group
100 * @exception ActivationException if group registration fails
101 * @exception RemoteException if remote call fails
102 * @since 1.2
103 */
104 public ActivationGroupID registerGroup(ActivationGroupDesc desc)
105 throws ActivationException, RemoteException;
106
107 /**
108 * Callback to inform activation system that group is now
109 * active. This call is made internally by the
110 * <code>ActivationGroup.createGroup</code> method to inform
111 * the <code>ActivationSystem</code> that the group is now
112 * active.
113 *
114 * @param id the activation group's identifier
115 * @param group the group's instantiator
116 * @param incarnation the group's incarnation number
117 * @return monitor for activation group
118 * @exception UnknownGroupException if group is not registered
119 * @exception ActivationException if a group for the specified
120 * <code>id</code> is already active and that group is not equal
121 * to the specified <code>group</code> or that group has a different
122 * <code>incarnation</code> than the specified <code>group</code>
123 * @exception RemoteException if remote call fails
124 * @since 1.2
125 */
126 public ActivationMonitor activeGroup(ActivationGroupID id,
127 ActivationInstantiator group,
128 long incarnation)
129 throws UnknownGroupException, ActivationException, RemoteException;
130
131 /**
132 * Remove the activation group. An activation group makes this call back
133 * to inform the activator that the group should be removed (destroyed).
134 * If this call completes successfully, objects can no longer be
135 * registered or activated within the group. All information of the
136 * group and its associated objects is removed from the system.
137 *
138 * @param id the activation group's identifier
139 * @exception ActivationException if unregister fails (e.g., database
140 * update failure, etc).
141 * @exception UnknownGroupException if group is not registered
142 * @exception RemoteException if remote call fails
143 * @since 1.2
144 */
145 public void unregisterGroup(ActivationGroupID id)
146 throws ActivationException, UnknownGroupException, RemoteException;
147
148 /**
149 * Shutdown the activation system. Destroys all groups spawned by
150 * the activation daemon and exits the activation daemon.
151 * @exception RemoteException if failed to contact/shutdown the activation
152 * daemon
153 * @since 1.2
154 */
155 public void shutdown() throws RemoteException;
156
157 /**
158 * Set the activation descriptor, <code>desc</code> for the object with
159 * the activation identifier, <code>id</code>. The change will take
160 * effect upon subsequent activation of the object.
161 *
162 * @param id the activation identifier for the activatable object
163 * @param desc the activation descriptor for the activatable object
164 * @exception UnknownGroupException the group associated with
165 * <code>desc</code> is not a registered group
166 * @exception UnknownObjectException the activation <code>id</code>
167 * is not registered
168 * @exception ActivationException for general failure (e.g., unable
169 * to update log)
170 * @exception RemoteException if remote call fails
171 * @return the previous value of the activation descriptor
172 * @see #getActivationDesc
173 * @since 1.2
174 */
175 public ActivationDesc setActivationDesc(ActivationID id,
176 ActivationDesc desc)
177 throws ActivationException, UnknownObjectException,
178 UnknownGroupException, RemoteException;
179
180 /**
181 * Set the activation group descriptor, <code>desc</code> for the object
182 * with the activation group identifier, <code>id</code>. The change will
183 * take effect upon subsequent activation of the group.
184 *
185 * @param id the activation group identifier for the activation group
186 * @param desc the activation group descriptor for the activation group
187 * @exception UnknownGroupException the group associated with
188 * <code>id</code> is not a registered group
189 * @exception ActivationException for general failure (e.g., unable
190 * to update log)
191 * @exception RemoteException if remote call fails
192 * @return the previous value of the activation group descriptor
193 * @see #getActivationGroupDesc
194 * @since 1.2
195 */
196 public ActivationGroupDesc setActivationGroupDesc(ActivationGroupID id,
197 ActivationGroupDesc desc)
198 throws ActivationException, UnknownGroupException, RemoteException;
199
200 /**
201 * Returns the activation descriptor, for the object with the activation
202 * identifier, <code>id</code>.
203 *
204 * @param id the activation identifier for the activatable object
205 * @exception UnknownObjectException if <code>id</code> is not registered
206 * @exception ActivationException for general failure
207 * @exception RemoteException if remote call fails
208 * @return the activation descriptor
209 * @see #setActivationDesc
210 * @since 1.2
211 */
212 public ActivationDesc getActivationDesc(ActivationID id)
213 throws ActivationException, UnknownObjectException, RemoteException;
214
215 /**
216 * Returns the activation group descriptor, for the group
217 * with the activation group identifier, <code>id</code>.
218 *
219 * @param id the activation group identifier for the group
220 * @exception UnknownGroupException if <code>id</code> is not registered
221 * @exception ActivationException for general failure
222 * @exception RemoteException if remote call fails
223 * @return the activation group descriptor
224 * @see #setActivationGroupDesc
225 * @since 1.2
226 */
227 public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID id)
228 throws ActivationException, UnknownGroupException, RemoteException;
229}
java/pkg/java/rmi/activation/Activator.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/Activator.java+114−0
@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) 1997, 2005, 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.MarshalledObject;
29import java.rmi.Remote;
30import java.rmi.RemoteException;
31import java.rmi.activation.UnknownObjectException;
32
33/**
34 * The <code>Activator</code> facilitates remote object activation. A
35 * "faulting" remote reference calls the activator's
36 * <code>activate</code> method to obtain a "live" reference to a
37 * "activatable" remote object. Upon receiving a request for activation,
38 * the activator looks up the activation descriptor for the activation
39 * identifier, <code>id</code>, determines the group in which the
40 * object should be activated initiates object re-creation via the
41 * group's <code>ActivationInstantiator</code> (via a call to the
42 * <code>newInstance</code> method). The activator initiates the
43 * execution of activation groups as necessary. For example, if an
44 * activation group for a specific group identifier is not already
45 * executing, the activator initiates the execution of a VM for the
46 * group. <p>
47 *
48 * The <code>Activator</code> works closely with
49 * <code>ActivationSystem</code>, which provides a means for registering
50 * groups and objects within those groups, and <code>ActivationMonitor</code>,
51 * which recives information about active and inactive objects and inactive
52 * groups. <p>
53 *
54 * The activator is responsible for monitoring and detecting when
55 * activation groups fail so that it can remove stale remote references
56 * to groups and active object's within those groups.<p>
57 *
58 * @author Ann Wollrath
59 * @see ActivationInstantiator
60 * @see ActivationGroupDesc
61 * @see ActivationGroupID
62 * @since 1.2
63 */
64public interface Activator extends Remote {
65 /**
66 * Activate the object associated with the activation identifier,
67 * <code>id</code>. If the activator knows the object to be active
68 * already, and <code>force</code> is false , the stub with a
69 * "live" reference is returned immediately to the caller;
70 * otherwise, if the activator does not know that corresponding
71 * the remote object is active, the activator uses the activation
72 * descriptor information (previously registered) to determine the
73 * group (VM) in which the object should be activated. If an
74 * <code>ActivationInstantiator</code> corresponding to the
75 * object's group descriptor already exists, the activator invokes
76 * the activation group's <code>newInstance</code> method passing
77 * it the object's id and descriptor. <p>
78 *
79 * If the activation group for the object's group descriptor does
80 * not yet exist, the activator starts an
81 * <code>ActivationInstantiator</code> executing (by spawning a
82 * child process, for example). When the activator receives the
83 * activation group's call back (via the
84 * <code>ActivationSystem</code>'s <code>activeGroup</code>
85 * method) specifying the activation group's reference, the
86 * activator can then invoke that activation instantiator's
87 * <code>newInstance</code> method to forward each pending
88 * activation request to the activation group and return the
89 * result (a marshalled remote object reference, a stub) to the
90 * caller.<p>
91 *
92 * Note that the activator receives a "marshalled" object instead of a
93 * Remote object so that the activator does not need to load the
94 * code for that object, or participate in distributed garbage
95 * collection for that object. If the activator kept a strong
96 * reference to the remote object, the activator would then
97 * prevent the object from being garbage collected under the
98 * normal distributed garbage collection mechanism. <p>
99 *
100 * @param id the activation identifier for the object being activated
101 * @param force if true, the activator contacts the group to obtain
102 * the remote object's reference; if false, returning the cached value
103 * is allowed.
104 * @return the remote object (a stub) in a marshalled form
105 * @exception ActivationException if object activation fails
106 * @exception UnknownObjectException if object is unknown (not registered)
107 * @exception RemoteException if remote call fails
108 * @since 1.2
109 */
110 public MarshalledObject<? extends Remote> activate(ActivationID id,
111 boolean force)
112 throws ActivationException, UnknownObjectException, RemoteException;
113
114}
java/pkg/java/rmi/activation/UnknownGroupException.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/UnknownGroupException.java+60−0
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1997, 1999, 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
28/**
29 * An <code>UnknownGroupException</code> is thrown by methods of classes and
30 * interfaces in the <code>java.rmi.activation</code> package when the
31 * <code>ActivationGroupID</code> parameter to the method is determined to be
32 * invalid, i.e., not known by the <code>ActivationSystem</code>. An
33 * <code>UnknownGroupException</code> is also thrown if the
34 * <code>ActivationGroupID</code> in an <code>ActivationDesc</code> refers to
35 * a group that is not registered with the <code>ActivationSystem</code>
36 *
37 * @author Ann Wollrath
38 * @since 1.2
39 * @see java.rmi.activation.Activatable
40 * @see java.rmi.activation.ActivationGroup
41 * @see java.rmi.activation.ActivationGroupID
42 * @see java.rmi.activation.ActivationMonitor
43 * @see java.rmi.activation.ActivationSystem
44 */
45public class UnknownGroupException extends ActivationException {
46
47 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
48 private static final long serialVersionUID = 7056094974750002460L;
49
50 /**
51 * Constructs an <code>UnknownGroupException</code> with the specified
52 * detail message.
53 *
54 * @param s the detail message
55 * @since 1.2
56 */
57 public UnknownGroupException(String s) {
58 super(s);
59 }
60}
java/pkg/java/rmi/activation/UnknownObjectException.class+0−0

Binary file not shown.

java/pkg/java/rmi/activation/UnknownObjectException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1997, 1999, 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
28/**
29 * An <code>UnknownObjectException</code> is thrown by methods of classes and
30 * interfaces in the <code>java.rmi.activation</code> package when the
31 * <code>ActivationID</code> parameter to the method is determined to be
32 * invalid. An <code>ActivationID</code> is invalid if it is not currently
33 * known by the <code>ActivationSystem</code>. An <code>ActivationID</code>
34 * is obtained by the <code>ActivationSystem.registerObject</code> method.
35 * An <code>ActivationID</code> is also obtained during the
36 * <code>Activatable.register</code> call.
37 *
38 * @author Ann Wollrath
39 * @since 1.2
40 * @see java.rmi.activation.Activatable
41 * @see java.rmi.activation.ActivationGroup
42 * @see java.rmi.activation.ActivationID
43 * @see java.rmi.activation.ActivationMonitor
44 * @see java.rmi.activation.ActivationSystem
45 * @see java.rmi.activation.Activator
46 */
47public class UnknownObjectException extends ActivationException {
48
49 /** indicate compatibility with the Java 2 SDK v1.2 version of class */
50 private static final long serialVersionUID = 3425547551622251430L;
51
52 /**
53 * Constructs an <code>UnknownObjectException</code> with the specified
54 * detail message.
55 *
56 * @param s the detail message
57 * @since 1.2
58 */
59 public UnknownObjectException(String s) {
60 super(s);
61 }
62}
java/pkg/java/rmi/activation/mkfile+21−0
@@ -0,0 +1,21 @@
1<../../../../../mkconfig
2
3TARG=\
4 Activatable.dis\
5 ActivateFailedException.dis\
6 ActivationDesc.dis\
7 ActivationException.dis\
8 ActivationGroup.dis\
9 ActivationGroupDesc.dis\
10 ActivationGroupID.dis\
11 ActivationID.dis\
12 ActivationInstantiator.dis\
13 ActivationMonitor.dis\
14 ActivationSystem.dis\
15 Activator.dis\
16 UnknownGroupException.dis\
17 UnknownObjectException.dis\
18
19DISBIN=$ROOT/java/dis/java/java/java/rmi/activation
20
21<$ROOT/mkfiles/mkjava
java/pkg/java/rmi/activation/package.html+52−0
@@ -0,0 +1,52 @@
1<!--
2 Copyright (c) 1998, 1999, 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<body bgcolor="white">
29
30Provides support for RMI Object Activation. A remote
31object's reference can be made ``persistent'' and later activated into a
32``live'' object using the RMI activation mechanism.
33
34<!--
35<h2>Package Specification</h2>
36
37##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
38<ul>
39 <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
40</ul>
41
42<h2>Related Documentation</h2>
43
44For overviews, tutorials, examples, guides, and tool documentation, please see:
45<ul>
46 <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
47</ul>
48-->
49
50@since 1.2
51</body>
52</html>
java/pkg/java/rmi/dgc/DGC.class+0−0

Binary file not shown.

java/pkg/java/rmi/dgc/DGC.java+115−0
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) 1996, 1999, 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.dgc;
26
27import java.rmi.*;
28import java.rmi.server.ObjID;
29
30/**
31 * The DGC abstraction is used for the server side of the distributed
32 * garbage collection algorithm. This interface contains the two
33 * methods: dirty and clean. A dirty call is made when a remote
34 * reference is unmarshaled in a client (the client is indicated by
35 * its VMID). A corresponding clean call is made when no more
36 * references to the remote reference exist in the client. A failed
37 * dirty call must schedule a strong clean call so that the call's
38 * sequence number can be retained in order to detect future calls
39 * received out of order by the distributed garbage collector.
40 *
41 * A reference to a remote object is leased for a period of time by
42 * the client holding the reference. The lease period starts when the
43 * dirty call is received. It is the client's responsibility to renew
44 * the leases, by making additional dirty calls, on the remote
45 * references it holds before such leases expire. If the client does
46 * not renew the lease before it expires, the distributed garbage
47 * collector assumes that the remote object is no longer referenced by
48 * that client.
49 *
50 * @author Ann Wollrath
51 */
52public interface DGC extends Remote {
53
54 /**
55 * The dirty call requests leases for the remote object references
56 * associated with the object identifiers contained in the array
57 * 'ids'. The 'lease' contains a client's unique VM identifier (VMID)
58 * and a requested lease period. For each remote object exported
59 * in the local VM, the garbage collector maintains a reference
60 * list-a list of clients that hold references to it. If the lease
61 * is granted, the garbage collector adds the client's VMID to the
62 * reference list for each remote object indicated in 'ids'. The
63 * 'sequenceNum' parameter is a sequence number that is used to
64 * detect and discard late calls to the garbage collector. The
65 * sequence number should always increase for each subsequent call
66 * to the garbage collector.
67 *
68 * Some clients are unable to generate a VMID, since a VMID is a
69 * universally unique identifier that contains a host address
70 * which some clients are unable to obtain due to security
71 * restrictions. In this case, a client can use a VMID of null,
72 * and the distributed garbage collector will assign a VMID for
73 * the client.
74 *
75 * The dirty call returns a Lease object that contains the VMID
76 * used and the lease period granted for the remote references (a
77 * server may decide to grant a smaller lease period than the
78 * client requests). A client must use the VMID the garbage
79 * collector uses in order to make corresponding clean calls when
80 * the client drops remote object references.
81 *
82 * A client VM need only make one initial dirty call for each
83 * remote reference referenced in the VM (even if it has multiple
84 * references to the same remote object). The client must also
85 * make a dirty call to renew leases on remote references before
86 * such leases expire. When the client no longer has any
87 * references to a specific remote object, it must schedule a
88 * clean call for the object ID associated with the reference.
89 *
90 * @param ids IDs of objects to mark as referenced by calling client
91 * @param sequenceNum sequence number
92 * @param lease requested lease
93 * @return granted lease
94 * @throws RemoteException if dirty call fails
95 */
96 Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
97 throws RemoteException;
98
99 /**
100 * The clean call removes the 'vmid' from the reference list of
101 * each remote object indicated in 'id's. The sequence number is
102 * used to detect late clean calls. If the argument 'strong' is
103 * true, then the clean call is a result of a failed dirty call,
104 * thus the sequence number for the client 'vmid' needs to be
105 * remembered.
106 *
107 * @param ids IDs of objects to mark as unreferenced by calling client
108 * @param sequenceNum sequence number
109 * @param vmid client VMID
110 * @param strong make 'strong' clean call
111 * @throws RemoteException if clean call fails
112 */
113 void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
114 throws RemoteException;
115}
java/pkg/java/rmi/dgc/Lease.class+0−0

Binary file not shown.

java/pkg/java/rmi/dgc/Lease.java+77−0
@@ -0,0 +1,77 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi.dgc;
26
27/**
28 * A lease contains a unique VM identifier and a lease duration. A
29 * Lease object is used to request and grant leases to remote object
30 * references.
31 */
32public final class Lease implements java.io.Serializable {
33
34 /**
35 * @serial Virtual Machine ID with which this Lease is associated.
36 * @see #getVMID
37 */
38 private VMID vmid;
39
40 /**
41 * @serial Duration of this lease.
42 * @see #getValue
43 */
44 private long value;
45 /** indicate compatibility with JDK 1.1.x version of class */
46 private static final long serialVersionUID = -5713411624328831948L;
47
48 /**
49 * Constructs a lease with a specific VMID and lease duration. The
50 * vmid may be null.
51 * @param id VMID associated with this lease
52 * @param duration lease duration
53 */
54 public Lease(VMID id, long duration)
55 {
56 vmid = id;
57 value = duration;
58 }
59
60 /**
61 * Returns the client VMID associated with the lease.
62 * @return client VMID
63 */
64 public VMID getVMID()
65 {
66 return vmid;
67 }
68
69 /**
70 * Returns the lease duration.
71 * @return lease duration
72 */
73 public long getValue()
74 {
75 return value;
76 }
77}
java/pkg/java/rmi/dgc/VMID$1.class+0−0

Binary file not shown.

java/pkg/java/rmi/dgc/VMID.class+0−0

Binary file not shown.

java/pkg/java/rmi/dgc/VMID.java+177−0
@@ -0,0 +1,177 @@
1/*
2 * Copyright (c) 1996, 2008, 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.dgc;
27
28import java.io.*;
29import java.net.*;
30import java.rmi.server.UID;
31import java.security.*;
32
33/**
34 * A VMID is a identifier that is unique across all Java virtual
35 * machines. VMIDs are used by the distributed garbage collector
36 * to identify client VMs.
37 *
38 * @author Ann Wollrath
39 * @author Peter Jones
40 */
41public final class VMID implements java.io.Serializable {
42
43 /** array of bytes uniquely identifying this host */
44 private static byte[] localAddr = computeAddressHash();
45
46 /**
47 * @serial array of bytes uniquely identifying host created on
48 */
49 private byte[] addr;
50
51 /**
52 * @serial unique identifier with respect to host created on
53 */
54 private UID uid;
55
56 /** indicate compatibility with JDK 1.1.x version of class */
57 private static final long serialVersionUID = -538642295484486218L;
58
59 /**
60 * Create a new VMID. Each new VMID returned from this constructor
61 * is unique for all Java virtual machines under the following
62 * conditions: a) the conditions for uniqueness for objects of
63 * the class <code>java.rmi.server.UID</code> are satisfied, and b) an
64 * address can be obtained for this host that is unique and constant
65 * for the lifetime of this object. <p>
66 */
67 public VMID() {
68 addr = localAddr;
69 uid = new UID();
70 }
71
72 /**
73 * Return true if an accurate address can be determined for this
74 * host. If false, reliable VMID cannot be generated from this host
75 * @return true if host address can be determined, false otherwise
76 * @deprecated
77 */
78 @Deprecated
79 public static boolean isUnique() {
80 return true;
81 }
82
83 /**
84 * Compute hash code for this VMID.
85 */
86 public int hashCode() {
87 return uid.hashCode();
88 }
89
90 /**
91 * Compare this VMID to another, and return true if they are the
92 * same identifier.
93 */
94 public boolean equals(Object obj) {
95 if (obj instanceof VMID) {
96 VMID vmid = (VMID) obj;
97 if (!uid.equals(vmid.uid))
98 return false;
99 if ((addr == null) ^ (vmid.addr == null))
100 return false;
101 if (addr != null) {
102 if (addr.length != vmid.addr.length)
103 return false;
104 for (int i = 0; i < addr.length; ++ i)
105 if (addr[i] != vmid.addr[i])
106 return false;
107 }
108 return true;
109 } else {
110 return false;
111 }
112 }
113
114 /**
115 * Return string representation of this VMID.
116 */
117 public String toString() {
118 StringBuffer result = new StringBuffer();
119 if (addr != null)
120 for (int i = 0; i < addr.length; ++ i) {
121 int x = (int) (addr[i] & 0xFF);
122 result.append((x < 0x10 ? "0" : "") +
123 Integer.toString(x, 16));
124 }
125 result.append(':');
126 result.append(uid.toString());
127 return result.toString();
128 }
129
130 /**
131 * Compute the hash an IP address. The hash is the first 8 bytes
132 * of the SHA digest of the IP address.
133 */
134 private static byte[] computeAddressHash() {
135
136 /*
137 * Get the local host's IP address.
138 */
139 byte[] addr = java.security.AccessController.doPrivileged(
140 new PrivilegedAction<byte[]>() {
141 public byte[] run() {
142 try {
143 return InetAddress.getLocalHost().getAddress();
144 } catch (Exception e) {
145 }
146 return new byte[] { 0, 0, 0, 0 };
147 }
148 });
149
150 byte[] addrHash;
151 final int ADDR_HASH_LENGTH = 8;
152
153 try {
154 /*
155 * Calculate message digest of IP address using SHA.
156 */
157 MessageDigest md = MessageDigest.getInstance("SHA");
158 ByteArrayOutputStream sink = new ByteArrayOutputStream(64);
159 DataOutputStream out = new DataOutputStream(
160 new DigestOutputStream(sink, md));
161 out.write(addr, 0, addr.length);
162 out.flush();
163
164 byte digest[] = md.digest();
165 int hashlength = Math.min(ADDR_HASH_LENGTH, digest.length);
166 addrHash = new byte[hashlength];
167 System.arraycopy(digest, 0, addrHash, 0, hashlength);
168
169 } catch (IOException ignore) {
170 /* can't happen, but be deterministic anyway. */
171 addrHash = new byte[0];
172 } catch (NoSuchAlgorithmException complain) {
173 throw new InternalError(complain.toString());
174 }
175 return addrHash;
176 }
177}
java/pkg/java/rmi/dgc/mkfile+10−0
@@ -0,0 +1,10 @@
1<../../../../../mkconfig
2
3TARG=\
4 DGC.dis\
5 Lease.dis\
6 VMID.dis\
7
8DISBIN=$ROOT/java/dis/java/java/java/rmi/dgc
9
10<$ROOT/mkfiles/mkjava
java/pkg/java/rmi/dgc/package.html+55−0
@@ -0,0 +1,55 @@
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<body bgcolor="white">
29
30Provides classes and interface for RMI distributed
31garbage-collection (DGC). When the RMI server returns an object to
32its client (caller of the remote method), it tracks the remote
33object's usage in the client. When there are no more references to the
34remote object on the client, or if the reference's ``lease'' expires and
35not renewed, the server garbage-collects the remote object.
36
37<!--
38<h2>Package Specification</h2>
39
40##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
41<ul>
42 <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
43</ul>
44
45<h2>Related Documentation</h2>
46
47For overviews, tutorials, examples, guides, and tool documentation, please see:
48<ul>
49 <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
50</ul>
51-->
52
53@since JDK1.1
54</body>
55</html>
java/pkg/java/rmi/mkfile+34−0
@@ -0,0 +1,34 @@
1<../../../../mkconfig
2
3DIRS=\
4 activation\
5 dgc\
6 registry\
7 server\
8
9TARG=\
10 AccessException.dis\
11 AlreadyBoundException.dis\
12 ConnectException.dis\
13 ConnectIOException.dis\
14 MarshalException.dis\
15 MarshalledObject.dis\
16 Naming.dis\
17 NoSuchObjectException.dis\
18 NotBoundException.dis\
19 Remote.dis\
20 RemoteException.dis\
21 RMISecurityException.dis\
22 RMISecurityManager.dis\
23 ServerError.dis\
24 ServerException.dis\
25 ServerRuntimeException.dis\
26 StubNotFoundException.dis\
27 UnexpectedException.dis\
28 UnknownHostException.dis\
29 UnmarshalException.dis\
30
31DISBIN=$ROOT/java/dis/java/java/java/rmi
32
33<$ROOT/mkfiles/mkjava
34<$ROOT/mkfiles/mksubdirs
java/pkg/java/rmi/package.html+59−0
@@ -0,0 +1,59 @@
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<body bgcolor="white">
29
30Provides the RMI package. RMI is Remote Method Invocation. It is a
31mechanism that enables an object on one Java virtual machine to invoke
32methods on an object in another Java virtual machine. Any object that
33can be invoked this way must implement the Remote interface. When such
34an object is invoked, its arguments are ``marshalled'' and sent from the
35local virtual machine to the remote one, where the arguments are
36``unmarshalled.'' When the method terminates, the results are
37marshalled from the remote machine and sent to the caller's virtual
38machine. If the method invocation results in an exception being
39thrown, the exception is indicated to caller.
40
41<!--
42<h2>Package Specification</h2>
43
44##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
45<ul>
46 <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
47</ul>
48
49<h2>Related Documentation</h2>
50
51For overviews, tutorials, examples, guides, and tool documentation, please see:
52<ul>
53 <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
54</ul>
55-->
56
57@since JDK1.1
58</body>
59</html>
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>
java/pkg/java/rmi/server/ExportException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/ExportException.java+68−0
@@ -0,0 +1,68 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi.server;
27
28/**
29 * An <code>ExportException</code> is a <code>RemoteException</code>
30 * thrown if an attempt to export a remote object fails. A remote object is
31 * exported via the constructors and <code>exportObject</code> methods of
32 * <code>java.rmi.server.UnicastRemoteObject</code> and
33 * <code>java.rmi.activation.Activatable</code>.
34 *
35 * @author Ann Wollrath
36 * @since JDK1.1
37 * @see java.rmi.server.UnicastRemoteObject
38 * @see java.rmi.activation.Activatable
39 */
40public class ExportException extends java.rmi.RemoteException {
41
42 /* indicate compatibility with JDK 1.1.x version of class */
43 private static final long serialVersionUID = -9155485338494060170L;
44
45 /**
46 * Constructs an <code>ExportException</code> with the specified
47 * detail message.
48 *
49 * @param s the detail message
50 * @since JDK1.1
51 */
52 public ExportException(String s) {
53 super(s);
54 }
55
56 /**
57 * Constructs an <code>ExportException</code> with the specified
58 * detail message and nested exception.
59 *
60 * @param s the detail message
61 * @param ex the nested exception
62 * @since JDK1.1
63 */
64 public ExportException(String s, Exception ex) {
65 super(s, ex);
66 }
67
68}
java/pkg/java/rmi/server/LoaderHandler.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/LoaderHandler.java+95−0
@@ -0,0 +1,95 @@
1/*
2 * Copyright (c) 1996, 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.server;
27
28import java.net.MalformedURLException;
29import java.net.URL;
30
31/**
32 * <code>LoaderHandler</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 *
39 * @deprecated no replacement
40 */
41@Deprecated
42public interface LoaderHandler {
43
44 /** package of system <code>LoaderHandler</code> implementation. */
45 final static String packagePrefix = "sun.rmi.server";
46
47 /**
48 * Loads a class from the location specified by the
49 * <code>java.rmi.server.codebase</code> property.
50 *
51 * @param name the name of the class to load
52 * @return the <code>Class</code> object representing the loaded class
53 * @exception MalformedURLException
54 * if the system property <b>java.rmi.server.codebase</b>
55 * contains an invalid URL
56 * @exception ClassNotFoundException
57 * if a definition for the class could not
58 * be found at the codebase location.
59 * @since JDK1.1
60 * @deprecated no replacement
61 */
62 @Deprecated
63 Class<?> loadClass(String name)
64 throws MalformedURLException, ClassNotFoundException;
65
66 /**
67 * Loads a class from a URL.
68 *
69 * @param codebase the URL from which to load the class
70 * @param name the name of the class to load
71 * @return the <code>Class</code> object representing the loaded class
72 * @exception MalformedURLException
73 * if the <code>codebase</code> paramater
74 * contains an invalid URL
75 * @exception ClassNotFoundException
76 * if a definition for the class could not
77 * be found at the specified URL
78 * @since JDK1.1
79 * @deprecated no replacement
80 */
81 @Deprecated
82 Class<?> loadClass(URL codebase, String name)
83 throws MalformedURLException, ClassNotFoundException;
84
85 /**
86 * Returns the security context of the given class loader.
87 *
88 * @param loader a class loader from which to get the security context
89 * @return the security context
90 * @since JDK1.1
91 * @deprecated no replacement
92 */
93 @Deprecated
94 Object getSecurityContext(ClassLoader loader);
95}
java/pkg/java/rmi/server/LogStream.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/LogStream.java+265−0
@@ -0,0 +1,265 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi.server;
26
27import java.io.*;
28import java.util.*;
29
30/**
31 * <code>LogStream</code> provides a mechanism for logging errors that are
32 * of possible interest to those monitoring a system.
33 *
34 * @author Ann Wollrath (lots of code stolen from Ken Arnold)
35 * @since JDK1.1
36 * @deprecated no replacement
37 */
38@Deprecated
39public class LogStream extends PrintStream {
40
41 /** table mapping known log names to log stream objects */
42 private static Hashtable known = new Hashtable(5);
43 /** default output stream for new logs */
44 private static PrintStream defaultStream = System.err;
45
46 /** log name for this log */
47 private String name;
48
49 /** stream where output of this log is sent to */
50 private OutputStream logOut;
51
52 /** string writer for writing message prefixes to log stream */
53 private OutputStreamWriter logWriter;
54
55 /** string buffer used for constructing log message prefixes */
56 private StringBuffer buffer = new StringBuffer();
57
58 /** stream used for buffering lines */
59 private ByteArrayOutputStream bufOut;
60
61 /**
62 * Create a new LogStream object. Since this only constructor is
63 * private, users must have a LogStream created through the "log"
64 * method.
65 * @param name string identifying messages from this log
66 * @out output stream that log messages will be sent to
67 * @since JDK1.1
68 * @deprecated no replacement
69 */
70 @Deprecated
71 private LogStream(String name, OutputStream out)
72 {
73 super(new ByteArrayOutputStream());
74 bufOut = (ByteArrayOutputStream) super.out;
75
76 this.name = name;
77 setOutputStream(out);
78 }
79
80 /**
81 * Return the LogStream identified by the given name. If
82 * a log corresponding to "name" does not exist, a log using
83 * the default stream is created.
84 * @param name name identifying the desired LogStream
85 * @return log associated with given name
86 * @since JDK1.1
87 * @deprecated no replacement
88 */
89 @Deprecated
90 public static LogStream log(String name) {
91 LogStream stream;
92 synchronized (known) {
93 stream = (LogStream)known.get(name);
94 if (stream == null) {
95 stream = new LogStream(name, defaultStream);
96 }
97 known.put(name, stream);
98 }
99 return stream;
100 }
101
102 /**
103 * Return the current default stream for new logs.
104 * @return default log stream
105 * @see #setDefaultStream
106 * @since JDK1.1
107 * @deprecated no replacement
108 */
109 @Deprecated
110 public static synchronized PrintStream getDefaultStream() {
111 return defaultStream;
112 }
113
114 /**
115 * Set the default stream for new logs.
116 * @param newDefault new default log stream
117 * @see #getDefaultStream
118 * @since JDK1.1
119 * @deprecated no replacement
120 */
121 @Deprecated
122 public static synchronized void setDefaultStream(PrintStream newDefault) {
123 defaultStream = newDefault;
124 }
125
126 /**
127 * Return the current stream to which output from this log is sent.
128 * @return output stream for this log
129 * @see #setOutputStream
130 * @since JDK1.1
131 * @deprecated no replacement
132 */
133 @Deprecated
134 public synchronized OutputStream getOutputStream()
135 {
136 return logOut;
137 }
138
139 /**
140 * Set the stream to which output from this log is sent.
141 * @param out new output stream for this log
142 * @see #getOutputStream
143 * @since JDK1.1
144 * @deprecated no replacement
145 */
146 @Deprecated
147 public synchronized void setOutputStream(OutputStream out)
148 {
149 logOut = out;
150 // Maintain an OutputStreamWriter with default CharToByteConvertor
151 // (just like new PrintStream) for writing log message prefixes.
152 logWriter = new OutputStreamWriter(logOut);
153 }
154
155 /**
156 * Write a byte of data to the stream. If it is not a newline, then
157 * the byte is appended to the internal buffer. If it is a newline,
158 * then the currently buffered line is sent to the log's output
159 * stream, prefixed with the appropriate logging information.
160 * @since JDK1.1
161 * @deprecated no replacement
162 */
163 @Deprecated
164 public void write(int b)
165 {
166 if (b == '\n') {
167 // synchronize on "this" first to avoid potential deadlock
168 synchronized (this) {
169 synchronized (logOut) {
170 // construct prefix for log messages:
171 buffer.setLength(0);;
172 buffer.append( // date/time stamp...
173 (new Date()).toString());
174 buffer.append(':');
175 buffer.append(name); // ...log name...
176 buffer.append(':');
177 buffer.append(Thread.currentThread().getName());
178 buffer.append(':'); // ...and thread name
179
180 try {
181 // write prefix through to underlying byte stream
182 logWriter.write(buffer.toString());
183 logWriter.flush();
184
185 // finally, write the already converted bytes of
186 // the log message
187 bufOut.writeTo(logOut);
188 logOut.write(b);
189 logOut.flush();
190 } catch (IOException e) {
191 setError();
192 } finally {
193 bufOut.reset();
194 }
195 }
196 }
197 }
198 else
199 super.write(b);
200 }
201
202 /**
203 * Write a subarray of bytes. Pass each through write byte method.
204 * @since JDK1.1
205 * @deprecated no replacement
206 */
207 @Deprecated
208 public void write(byte b[], int off, int len)
209 {
210 if (len < 0)
211 throw new ArrayIndexOutOfBoundsException(len);
212 for (int i = 0; i < len; ++ i)
213 write(b[off + i]);
214 }
215
216 /**
217 * Return log name as string representation.
218 * @return log name
219 * @since JDK1.1
220 * @deprecated no replacement
221 */
222 @Deprecated
223 public String toString()
224 {
225 return name;
226 }
227
228 /** log level constant (no logging). */
229 public static final int SILENT = 0;
230 /** log level constant (brief logging). */
231 public static final int BRIEF = 10;
232 /** log level constant (verbose logging). */
233 public static final int VERBOSE = 20;
234
235 /**
236 * Convert a string name of a logging level to its internal
237 * integer representation.
238 * @param s name of logging level (e.g., 'SILENT', 'BRIEF', 'VERBOSE')
239 * @return corresponding integer log level
240 * @since JDK1.1
241 * @deprecated no replacement
242 */
243 @Deprecated
244 public static int parseLevel(String s)
245 {
246 if ((s == null) || (s.length() < 1))
247 return -1;
248
249 try {
250 return Integer.parseInt(s);
251 } catch (NumberFormatException e) {
252 }
253 if (s.length() < 1)
254 return -1;
255
256 if ("SILENT".startsWith(s.toUpperCase()))
257 return SILENT;
258 else if ("BRIEF".startsWith(s.toUpperCase()))
259 return BRIEF;
260 else if ("VERBOSE".startsWith(s.toUpperCase()))
261 return VERBOSE;
262
263 return -1;
264 }
265}
java/pkg/java/rmi/server/ObjID.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/ObjID.java+248−0
@@ -0,0 +1,248 @@
1/*
2 * Copyright (c) 1996, 2006, 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.server;
26
27import java.io.DataInput;
28import java.io.DataOutput;
29import java.io.IOException;
30import java.io.ObjectInput;
31import java.io.ObjectOutput;
32import java.io.Serializable;
33import java.security.AccessController;
34import java.security.SecureRandom;
35import java.util.concurrent.atomic.AtomicLong;
36import sun.security.action.GetPropertyAction;
37
38/**
39 * An <code>ObjID</code> is used to identify a remote object exported
40 * to an RMI runtime. When a remote object is exported, it is assigned
41 * an object identifier either implicitly or explicitly, depending on
42 * the API used to export.
43 *
44 * <p>The {@link #ObjID()} constructor can be used to generate a unique
45 * object identifier. Such an <code>ObjID</code> is unique over time
46 * with respect to the host it is generated on.
47 *
48 * The {@link #ObjID(int)} constructor can be used to create a
49 * "well-known" object identifier. The scope of a well-known
50 * <code>ObjID</code> depends on the RMI runtime it is exported to.
51 *
52 * <p>An <code>ObjID</code> instance contains an object number (of type
53 * <code>long</code>) and an address space identifier (of type
54 * {@link UID}). In a unique <code>ObjID</code>, the address space
55 * identifier is unique with respect to a given host over time. In a
56 * well-known <code>ObjID</code>, the address space identifier is
57 * equivalent to one returned by invoking the {@link UID#UID(short)}
58 * constructor with the value zero.
59 *
60 * <p>If the system property <code>java.rmi.server.randomIDs</code>
61 * is defined to equal the string <code>"true"</code> (case insensitive),
62 * then the {@link #ObjID()} constructor will use a cryptographically
63 * strong random number generator to choose the object number of the
64 * returned <code>ObjID</code>.
65 *
66 * @author Ann Wollrath
67 * @author Peter Jones
68 * @since JDK1.1
69 */
70public final class ObjID implements Serializable {
71
72 /** Object number for well-known <code>ObjID</code> of the registry. */
73 public static final int REGISTRY_ID = 0;
74
75 /** Object number for well-known <code>ObjID</code> of the activator. */
76 public static final int ACTIVATOR_ID = 1;
77
78 /**
79 * Object number for well-known <code>ObjID</code> of
80 * the distributed garbage collector.
81 */
82 public static final int DGC_ID = 2;
83
84 /** indicate compatibility with JDK 1.1.x version of class */
85 private static final long serialVersionUID = -6386392263968365220L;
86
87 private static final AtomicLong nextObjNum = new AtomicLong(0);
88 private static final UID mySpace = new UID();
89 private static final SecureRandom secureRandom = new SecureRandom();
90
91 /**
92 * @serial object number
93 * @see #hashCode
94 */
95 private final long objNum;
96
97 /**
98 * @serial address space identifier (unique to host over time)
99 */
100 private final UID space;
101
102 /**
103 * Generates a unique object identifier.
104 *
105 * <p>If the system property <code>java.rmi.server.randomIDs</code>
106 * is defined to equal the string <code>"true"</code> (case insensitive),
107 * then this constructor will use a cryptographically
108 * strong random number generator to choose the object number of the
109 * returned <code>ObjID</code>.
110 */
111 public ObjID() {
112 /*
113 * If generating random object numbers, create a new UID to
114 * ensure uniqueness; otherwise, use a shared UID because
115 * sequential object numbers already ensure uniqueness.
116 */
117 if (useRandomIDs()) {
118 space = new UID();
119 objNum = secureRandom.nextLong();
120 } else {
121 space = mySpace;
122 objNum = nextObjNum.getAndIncrement();
123 }
124 }
125
126 /**
127 * Creates a "well-known" object identifier.
128 *
129 * <p>An <code>ObjID</code> created via this constructor will not
130 * clash with any <code>ObjID</code>s generated via the no-arg
131 * constructor.
132 *
133 * @param objNum object number for well-known object identifier
134 */
135 public ObjID(int objNum) {
136 space = new UID((short) 0);
137 this.objNum = objNum;
138 }
139
140 /**
141 * Constructs an object identifier given data read from a stream.
142 */
143 private ObjID(long objNum, UID space) {
144 this.objNum = objNum;
145 this.space = space;
146 }
147
148 /**
149 * Marshals a binary representation of this <code>ObjID</code> to
150 * an <code>ObjectOutput</code> instance.
151 *
152 * <p>Specifically, this method first invokes the given stream's
153 * {@link ObjectOutput#writeLong(long)} method with this object
154 * identifier's object number, and then it writes its address
155 * space identifier by invoking its {@link UID#write(DataOutput)}
156 * method with the stream.
157 *
158 * @param out the <code>ObjectOutput</code> instance to write
159 * this <code>ObjID</code> to
160 *
161 * @throws IOException if an I/O error occurs while performing
162 * this operation
163 */
164 public void write(ObjectOutput out) throws IOException {
165 out.writeLong(objNum);
166 space.write(out);
167 }
168
169 /**
170 * Constructs and returns a new <code>ObjID</code> instance by
171 * unmarshalling a binary representation from an
172 * <code>ObjectInput</code> instance.
173 *
174 * <p>Specifically, this method first invokes the given stream's
175 * {@link ObjectInput#readLong()} method to read an object number,
176 * then it invokes {@link UID#read(DataInput)} with the
177 * stream to read an address space identifier, and then it
178 * creates and returns a new <code>ObjID</code> instance that
179 * contains the object number and address space identifier that
180 * were read from the stream.
181 *
182 * @param in the <code>ObjectInput</code> instance to read
183 * <code>ObjID</code> from
184 *
185 * @return unmarshalled <code>ObjID</code> instance
186 *
187 * @throws IOException if an I/O error occurs while performing
188 * this operation
189 */
190 public static ObjID read(ObjectInput in) throws IOException {
191 long num = in.readLong();
192 UID space = UID.read(in);
193 return new ObjID(num, space);
194 }
195
196 /**
197 * Returns the hash code value for this object identifier, the
198 * object number.
199 *
200 * @return the hash code value for this object identifier
201 */
202 public int hashCode() {
203 return (int) objNum;
204 }
205
206 /**
207 * Compares the specified object with this <code>ObjID</code> for
208 * equality.
209 *
210 * This method returns <code>true</code> if and only if the
211 * specified object is an <code>ObjID</code> instance with the same
212 * object number and address space identifier as this one.
213 *
214 * @param obj the object to compare this <code>ObjID</code> to
215 *
216 * @return <code>true</code> if the given object is equivalent to
217 * this one, and <code>false</code> otherwise
218 */
219 public boolean equals(Object obj) {
220 if (obj instanceof ObjID) {
221 ObjID id = (ObjID) obj;
222 return objNum == id.objNum && space.equals(id.space);
223 } else {
224 return false;
225 }
226 }
227
228 /**
229 * Returns a string representation of this object identifier.
230 *
231 * @return a string representation of this object identifier
232 */
233 /*
234 * The address space identifier is only included in the string
235 * representation if it does not denote the local address space
236 * (or if the randomIDs property was set).
237 */
238 public String toString() {
239 return "[" + (space.equals(mySpace) ? "" : space + ", ") +
240 objNum + "]";
241 }
242
243 private static boolean useRandomIDs() {
244 String value = AccessController.doPrivileged(
245 new GetPropertyAction("java.rmi.server.randomIDs"));
246 return value == null ? true : Boolean.parseBoolean(value);
247 }
248}
java/pkg/java/rmi/server/Operation.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/Operation.java+73−0
@@ -0,0 +1,73 @@
1/*
2 * Copyright (c) 1996, 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.server;
27
28/**
29 * An <code>Operation</code> contains a description of a Java method.
30 * <code>Operation</code> objects were used in JDK1.1 version stubs and
31 * skeletons. The <code>Operation</code> class is not needed for 1.2 style
32 * stubs (stubs generated with <code>rmic -v1.2</code>); hence, this class
33 * is deprecated.
34 *
35 * @since JDK1.1
36 * @deprecated no replacement
37 */
38@Deprecated
39public class Operation {
40 private String operation;
41
42 /**
43 * Creates a new Operation object.
44 * @param op method name
45 * @deprecated no replacement
46 * @since JDK1.1
47 */
48 @Deprecated
49 public Operation(String op) {
50 operation = op;
51 }
52
53 /**
54 * Returns the name of the method.
55 * @return method name
56 * @deprecated no replacement
57 * @since JDK1.1
58 */
59 @Deprecated
60 public String getOperation() {
61 return operation;
62 }
63
64 /**
65 * Returns the string representation of the operation.
66 * @deprecated no replacement
67 * @since JDK1.1
68 */
69 @Deprecated
70 public String toString() {
71 return operation;
72 }
73}
java/pkg/java/rmi/server/RMIClassLoader$1.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIClassLoader$2.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIClassLoader.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIClassLoader.java+722−0
@@ -0,0 +1,722 @@
1/*
2 * Copyright (c) 1996, 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.server;
27
28import java.net.MalformedURLException;
29import java.net.URL;
30import java.security.AccessController;
31import java.security.PrivilegedAction;
32import java.util.Iterator;
33import java.util.ServiceLoader;
34
35/**
36 * <code>RMIClassLoader</code> comprises static methods to support
37 * dynamic class loading with RMI. Included are methods for loading
38 * classes from a network location (one or more URLs) and obtaining
39 * the location from which an existing class should be loaded by
40 * remote parties. These methods are used by the RMI runtime when
41 * marshalling and unmarshalling classes contained in the arguments
42 * and return values of remote method calls, and they also may be
43 * invoked directly by applications in order to mimic RMI's dynamic
44 * class loading behavior.
45 *
46 * <p>The implementation of the following static methods
47 *
48 * <ul>
49 *
50 * <li>{@link #loadClass(URL,String)}
51 * <li>{@link #loadClass(String,String)}
52 * <li>{@link #loadClass(String,String,ClassLoader)}
53 * <li>{@link #loadProxyClass(String,String[],ClassLoader)}
54 * <li>{@link #getClassLoader(String)}
55 * <li>{@link #getClassAnnotation(Class)}
56 *
57 * </ul>
58 *
59 * is provided by an instance of {@link RMIClassLoaderSpi}, the
60 * service provider interface for those methods. When one of the
61 * methods is invoked, its behavior is to delegate to a corresponding
62 * method on the service provider instance. The details of how each
63 * method delegates to the provider instance is described in the
64 * documentation for each particular method.
65 *
66 * <p>The service provider instance is chosen as follows:
67 *
68 * <ul>
69 *
70 * <li>If the system property
71 * <code>java.rmi.server.RMIClassLoaderSpi</code> is defined, then if
72 * its value equals the string <code>"default"</code>, the provider
73 * instance will be the value returned by an invocation of the {@link
74 * #getDefaultProviderInstance()} method, and for any other value, if
75 * a class named with the value of the property can be loaded by the
76 * system class loader (see {@link ClassLoader#getSystemClassLoader})
77 * and that class is assignable to {@link RMIClassLoaderSpi} and has a
78 * public no-argument constructor, then that constructor will be
79 * invoked to create the provider instance. If the property is
80 * defined but any other of those conditions are not true, then an
81 * unspecified <code>Error</code> will be thrown to code that attempts
82 * to use <code>RMIClassLoader</code>, indicating the failure to
83 * obtain a provider instance.
84 *
85 * <li>If a resource named
86 * <code>META-INF/services/java.rmi.server.RMIClassLoaderSpi</code> is
87 * visible to the system class loader, then the contents of that
88 * resource are interpreted as a provider-configuration file, and the
89 * first class name specified in that file is used as the provider
90 * class name. If a class with that name can be loaded by the system
91 * class loader and that class is assignable to {@link
92 * RMIClassLoaderSpi} and has a public no-argument constructor, then
93 * that constructor will be invoked to create the provider instance.
94 * If the resource is found but a provider cannot be instantiated as
95 * described, then an unspecified <code>Error</code> will be thrown to
96 * code that attempts to use <code>RMIClassLoader</code>, indicating
97 * the failure to obtain a provider instance.
98 *
99 * <li>Otherwise, the provider instance will be the value returned by
100 * an invocation of the {@link #getDefaultProviderInstance()} method.
101 *
102 * </ul>
103 *
104 * @author Ann Wollrath
105 * @author Peter Jones
106 * @author Laird Dornin
107 * @see RMIClassLoaderSpi
108 * @since JDK1.1
109 */
110public class RMIClassLoader {
111
112 /** "default" provider instance */
113 private static final RMIClassLoaderSpi defaultProvider =
114 newDefaultProviderInstance();
115
116 /** provider instance */
117 private static final RMIClassLoaderSpi provider =
118 AccessController.doPrivileged(
119 new PrivilegedAction<RMIClassLoaderSpi>() {
120 public RMIClassLoaderSpi run() { return initializeProvider(); }
121 });
122
123 /*
124 * Disallow anyone from creating one of these.
125 */
126 private RMIClassLoader() {}
127
128 /**
129 * Loads the class with the specified <code>name</code>.
130 *
131 * <p>This method delegates to {@link #loadClass(String,String)},
132 * passing <code>null</code> as the first argument and
133 * <code>name</code> as the second argument.
134 *
135 * @param name the name of the class to load
136 *
137 * @return the <code>Class</code> object representing the loaded class
138 *
139 * @throws MalformedURLException if a provider-specific URL used
140 * to load classes is invalid
141 *
142 * @throws ClassNotFoundException if a definition for the class
143 * could not be found at the codebase location
144 *
145 * @deprecated replaced by <code>loadClass(String,String)</code> method
146 * @see #loadClass(String,String)
147 */
148 @Deprecated
149 public static Class<?> loadClass(String name)
150 throws MalformedURLException, ClassNotFoundException
151 {
152 return loadClass((String) null, name);
153 }
154
155 /**
156 * Loads a class from a codebase URL.
157 *
158 * If <code>codebase</code> is <code>null</code>, then this method
159 * will behave the same as {@link #loadClass(String,String)} with a
160 * <code>null</code> <code>codebase</code> and the given class name.
161 *
162 * <p>This method delegates to the
163 * {@link RMIClassLoaderSpi#loadClass(String,String,ClassLoader)}
164 * method of the provider instance, passing the result of invoking
165 * {@link URL#toString} on the given URL (or <code>null</code> if
166 * <code>codebase</code> is null) as the first argument,
167 * <code>name</code> as the second argument,
168 * and <code>null</code> as the third argument.
169 *
170 * @param codebase the URL to load the class from, or <code>null</code>
171 *
172 * @param name the name of the class to load
173 *
174 * @return the <code>Class</code> object representing the loaded class
175 *
176 * @throws MalformedURLException if <code>codebase</code> is
177 * <code>null</code> and a provider-specific URL used
178 * to load classes is invalid
179 *
180 * @throws ClassNotFoundException if a definition for the class
181 * could not be found at the specified URL
182 */
183 public static Class<?> loadClass(URL codebase, String name)
184 throws MalformedURLException, ClassNotFoundException
185 {
186 return provider.loadClass(
187 codebase != null ? codebase.toString() : null, name, null);
188 }
189
190 /**
191 * Loads a class from a codebase URL path.
192 *
193 * <p>This method delegates to the
194 * {@link RMIClassLoaderSpi#loadClass(String,String,ClassLoader)}
195 * method of the provider instance, passing <code>codebase</code>
196 * as the first argument, <code>name</code> as the second argument,
197 * and <code>null</code> as the third argument.
198 *
199 * @param codebase the list of URLs (separated by spaces) to load
200 * the class from, or <code>null</code>
201 *
202 * @param name the name of the class to load
203 *
204 * @return the <code>Class</code> object representing the loaded class
205 *
206 * @throws MalformedURLException if <code>codebase</code> is
207 * non-<code>null</code> and contains an invalid URL, or if
208 * <code>codebase</code> is <code>null</code> and a provider-specific
209 * URL used to load classes is invalid
210 *
211 * @throws ClassNotFoundException if a definition for the class
212 * could not be found at the specified location
213 *
214 * @since 1.2
215 */
216 public static Class<?> loadClass(String codebase, String name)
217 throws MalformedURLException, ClassNotFoundException
218 {
219 return provider.loadClass(codebase, name, null);
220 }
221
222 /**
223 * Loads a class from a codebase URL path, optionally using the
224 * supplied loader.
225 *
226 * This method should be used when the caller would like to make
227 * available to the provider implementation an additional contextual
228 * class loader to consider, such as the loader of a caller on the
229 * stack. Typically, a provider implementation will attempt to
230 * resolve the named class using the given <code>defaultLoader</code>,
231 * if specified, before attempting to resolve the class from the
232 * codebase URL path.
233 *
234 * <p>This method delegates to the
235 * {@link RMIClassLoaderSpi#loadClass(String,String,ClassLoader)}
236 * method of the provider instance, passing <code>codebase</code>
237 * as the first argument, <code>name</code> as the second argument,
238 * and <code>defaultLoader</code> as the third argument.
239 *
240 * @param codebase the list of URLs (separated by spaces) to load
241 * the class from, or <code>null</code>
242 *
243 * @param name the name of the class to load
244 *
245 * @param defaultLoader additional contextual class loader
246 * to use, or <code>null</code>
247 *
248 * @return the <code>Class</code> object representing the loaded class
249 *
250 * @throws MalformedURLException if <code>codebase</code> is
251 * non-<code>null</code> and contains an invalid URL, or if
252 * <code>codebase</code> is <code>null</code> and a provider-specific
253 * URL used to load classes is invalid
254 *
255 * @throws ClassNotFoundException if a definition for the class
256 * could not be found at the specified location
257 *
258 * @since 1.4
259 */
260 public static Class<?> loadClass(String codebase, String name,
261 ClassLoader defaultLoader)
262 throws MalformedURLException, ClassNotFoundException
263 {
264 return provider.loadClass(codebase, name, defaultLoader);
265 }
266
267 /**
268 * Loads a dynamic proxy class (see {@link java.lang.reflect.Proxy})
269 * that implements a set of interfaces with the given names
270 * from a codebase URL path.
271 *
272 * <p>The interfaces will be resolved similar to classes loaded via
273 * the {@link #loadClass(String,String)} method using the given
274 * <code>codebase</code>.
275 *
276 * <p>This method delegates to the
277 * {@link RMIClassLoaderSpi#loadProxyClass(String,String[],ClassLoader)}
278 * method of the provider instance, passing <code>codebase</code>
279 * as the first argument, <code>interfaces</code> as the second argument,
280 * and <code>defaultLoader</code> as the third argument.
281 *
282 * @param codebase the list of URLs (space-separated) to load
283 * classes from, or <code>null</code>
284 *
285 * @param interfaces the names of the interfaces for the proxy class
286 * to implement
287 *
288 * @param defaultLoader additional contextual class loader
289 * to use, or <code>null</code>
290 *
291 * @return a dynamic proxy class that implements the named interfaces
292 *
293 * @throws MalformedURLException if <code>codebase</code> is
294 * non-<code>null</code> and contains an invalid URL, or
295 * if <code>codebase</code> is <code>null</code> and a provider-specific
296 * URL used to load classes is invalid
297 *
298 * @throws ClassNotFoundException if a definition for one of
299 * the named interfaces could not be found at the specified location,
300 * or if creation of the dynamic proxy class failed (such as if
301 * {@link java.lang.reflect.Proxy#getProxyClass(ClassLoader,Class[])}
302 * would throw an <code>IllegalArgumentException</code> for the given
303 * interface list)
304 *
305 * @since 1.4
306 */
307 public static Class<?> loadProxyClass(String codebase, String[] interfaces,
308 ClassLoader defaultLoader)
309 throws ClassNotFoundException, MalformedURLException
310 {
311 return provider.loadProxyClass(codebase, interfaces, defaultLoader);
312 }
313
314 /**
315 * Returns a class loader that loads classes from the given codebase
316 * URL path.
317 *
318 * <p>The class loader returned is the class loader that the
319 * {@link #loadClass(String,String)} method would use to load classes
320 * for the same <code>codebase</code> argument.
321 *
322 * <p>This method delegates to the
323 * {@link RMIClassLoaderSpi#getClassLoader(String)} method
324 * of the provider instance, passing <code>codebase</code> as the argument.
325 *
326 * <p>If there is a security manger, its <code>checkPermission</code>
327 * method will be invoked with a
328 * <code>RuntimePermission("getClassLoader")</code> permission;
329 * this could result in a <code>SecurityException</code>.
330 * The provider implementation of this method may also perform further
331 * security checks to verify that the calling context has permission to
332 * connect to all of the URLs in the codebase URL path.
333 *
334 * @param codebase the list of URLs (space-separated) from which
335 * the returned class loader will load classes from, or <code>null</code>
336 *
337 * @return a class loader that loads classes from the given codebase URL
338 * path
339 *
340 * @throws MalformedURLException if <code>codebase</code> is
341 * non-<code>null</code> and contains an invalid URL, or
342 * if <code>codebase</code> is <code>null</code> and a provider-specific
343 * URL used to identify the class loader is invalid
344 *
345 * @throws SecurityException if there is a security manager and the
346 * invocation of its <code>checkPermission</code> method fails, or
347 * if the caller does not have permission to connect to all of the
348 * URLs in the codebase URL path
349 *
350 * @since 1.3
351 */
352 public static ClassLoader getClassLoader(String codebase)
353 throws MalformedURLException, SecurityException
354 {
355 return provider.getClassLoader(codebase);
356 }
357
358 /**
359 * Returns the annotation string (representing a location for
360 * the class definition) that RMI will use to annotate the class
361 * descriptor when marshalling objects of the given class.
362 *
363 * <p>This method delegates to the
364 * {@link RMIClassLoaderSpi#getClassAnnotation(Class)} method
365 * of the provider instance, passing <code>cl</code> as the argument.
366 *
367 * @param cl the class to obtain the annotation for
368 *
369 * @return a string to be used to annotate the given class when
370 * it gets marshalled, or <code>null</code>
371 *
372 * @throws NullPointerException if <code>cl</code> is <code>null</code>
373 *
374 * @since 1.2
375 */
376 /*
377 * REMIND: Should we say that the returned class annotation will or
378 * should be a (space-separated) list of URLs?
379 */
380 public static String getClassAnnotation(Class<?> cl) {
381 return provider.getClassAnnotation(cl);
382 }
383
384 /**
385 * Returns the canonical instance of the default provider
386 * for the service provider interface {@link RMIClassLoaderSpi}.
387 * If the system property <code>java.rmi.server.RMIClassLoaderSpi</code>
388 * is not defined, then the <code>RMIClassLoader</code> static
389 * methods
390 *
391 * <ul>
392 *
393 * <li>{@link #loadClass(URL,String)}
394 * <li>{@link #loadClass(String,String)}
395 * <li>{@link #loadClass(String,String,ClassLoader)}
396 * <li>{@link #loadProxyClass(String,String[],ClassLoader)}
397 * <li>{@link #getClassLoader(String)}
398 * <li>{@link #getClassAnnotation(Class)}
399 *
400 * </ul>
401 *
402 * will use the canonical instance of the default provider
403 * as the service provider instance.
404 *
405 * <p>If there is a security manager, its
406 * <code>checkPermission</code> method will be invoked with a
407 * <code>RuntimePermission("setFactory")</code> permission; this
408 * could result in a <code>SecurityException</code>.
409 *
410 * <p>The default service provider instance implements
411 * {@link RMIClassLoaderSpi} as follows:
412 *
413 * <blockquote>
414 *
415 * <p>The <b>{@link RMIClassLoaderSpi#getClassAnnotation(Class)
416 * getClassAnnotation}</b> method returns a <code>String</code>
417 * representing the codebase URL path that a remote party should
418 * use to download the definition for the specified class. The
419 * format of the returned string is a path of URLs separated by
420 * spaces.
421 *
422 * The codebase string returned depends on the defining class
423 * loader of the specified class:
424 *
425 * <ul>
426 *
427 * <p><li>If the class loader is the system class loader (see
428 * {@link ClassLoader#getSystemClassLoader}), a parent of the
429 * system class loader such as the loader used for installed
430 * extensions, or the bootstrap class loader (which may be
431 * represented by <code>null</code>), then the value of the
432 * <code>java.rmi.server.codebase</code> property (or possibly an
433 * earlier cached value) is returned, or
434 * <code>null</code> is returned if that property is not set.
435 *
436 * <p><li>Otherwise, if the class loader is an instance of
437 * <code>URLClassLoader</code>, then the returned string is a
438 * space-separated list of the external forms of the URLs returned
439 * by invoking the <code>getURLs</code> methods of the loader. If
440 * the <code>URLClassLoader</code> was created by this provider to
441 * service an invocation of its <code>loadClass</code> or
442 * <code>loadProxyClass</code> methods, then no permissions are
443 * required to get the associated codebase string. If it is an
444 * arbitrary other <code>URLClassLoader</code> instance, then if
445 * there is a security manager, its <code>checkPermission</code>
446 * method will be invoked once for each URL returned by the
447 * <code>getURLs</code> method, with the permission returned by
448 * invoking <code>openConnection().getPermission()</code> on each
449 * URL; if any of those invocations throws a
450 * <code>SecurityException</code> or an <code>IOException</code>,
451 * then the value of the <code>java.rmi.server.codebase</code>
452 * property (or possibly an earlier cached value) is returned, or
453 * <code>null</code> is returned if that property is not set.
454 *
455 * <p><li>Finally, if the class loader is not an instance of
456 * <code>URLClassLoader</code>, then the value of the
457 * <code>java.rmi.server.codebase</code> property (or possibly an
458 * earlier cached value) is returned, or
459 * <code>null</code> is returned if that property is not set.
460 *
461 * </ul>
462 *
463 * <p>For the implementations of the methods described below,
464 * which all take a <code>String</code> parameter named
465 * <code>codebase</code> that is a space-separated list of URLs,
466 * each invocation has an associated <i>codebase loader</i> that
467 * is identified using the <code>codebase</code> argument in
468 * conjunction with the current thread's context class loader (see
469 * {@link Thread#getContextClassLoader()}). When there is a
470 * security manager, this provider maintains an internal table of
471 * class loader instances (which are at least instances of {@link
472 * java.net.URLClassLoader}) keyed by the pair of their parent
473 * class loader and their codebase URL path (an ordered list of
474 * URLs). If the <code>codebase</code> argument is <code>null</code>,
475 * the codebase URL path is the value of the system property
476 * <code>java.rmi.server.codebase</code> or possibly an
477 * earlier cached value. For a given codebase URL path passed as the
478 * <code>codebase</code> argument to an invocation of one of the
479 * below methods in a given context, the codebase loader is the
480 * loader in the table with the specified codebase URL path and
481 * the current thread's context class loader as its parent. If no
482 * such loader exists, then one is created and added to the table.
483 * The table does not maintain strong references to its contained
484 * loaders, in order to allow them and their defined classes to be
485 * garbage collected when not otherwise reachable. In order to
486 * prevent arbitrary untrusted code from being implicitly loaded
487 * into a virtual machine with no security manager, if there is no
488 * security manager set, the codebase loader is just the current
489 * thread's context class loader (the supplied codebase URL path
490 * is ignored, so remote class loading is disabled).
491 *
492 * <p>The <b>{@link RMIClassLoaderSpi#getClassLoader(String)
493 * getClassLoader}</b> method returns the codebase loader for the
494 * specified codebase URL path. If there is a security manager,
495 * then if the calling context does not have permission to connect
496 * to all of the URLs in the codebase URL path, a
497 * <code>SecurityException</code> will be thrown.
498 *
499 * <p>The <b>{@link
500 * RMIClassLoaderSpi#loadClass(String,String,ClassLoader)
501 * loadClass}</b> method attempts to load the class with the
502 * specified name as follows:
503 *
504 * <blockquote>
505 *
506 * If the <code>defaultLoader</code> argument is
507 * non-<code>null</code>, it first attempts to load the class with the
508 * specified <code>name</code> using the
509 * <code>defaultLoader</code>, such as by evaluating
510 *
511 * <pre>
512 * Class.forName(name, false, defaultLoader)
513 * </pre>
514 *
515 * If the class is successfully loaded from the
516 * <code>defaultLoader</code>, that class is returned. If an
517 * exception other than <code>ClassNotFoundException</code> is
518 * thrown, that exception is thrown to the caller.
519 *
520 * <p>Next, the <code>loadClass</code> method attempts to load the
521 * class with the specified <code>name</code> using the codebase
522 * loader for the specified codebase URL path.
523 * If there is a security manager, then the calling context
524 * must have permission to connect to all of the URLs in the
525 * codebase URL path; otherwise, the current thread's context
526 * class loader will be used instead of the codebase loader.
527 *
528 * </blockquote>
529 *
530 * <p>The <b>{@link
531 * RMIClassLoaderSpi#loadProxyClass(String,String[],ClassLoader)
532 * loadProxyClass}</b> method attempts to return a dynamic proxy
533 * class with the named interface as follows:
534 *
535 * <blockquote>
536 *
537 * <p>If the <code>defaultLoader</code> argument is
538 * non-<code>null</code> and all of the named interfaces can be
539 * resolved through that loader, then,
540 *
541 * <ul>
542 *
543 * <li>if all of the resolved interfaces are <code>public</code>,
544 * then it first attempts to obtain a dynamic proxy class (using
545 * {@link
546 * java.lang.reflect.Proxy#getProxyClass(ClassLoader,Class[])
547 * Proxy.getProxyClass}) for the resolved interfaces defined in
548 * the codebase loader; if that attempt throws an
549 * <code>IllegalArgumentException</code>, it then attempts to
550 * obtain a dynamic proxy class for the resolved interfaces
551 * defined in the <code>defaultLoader</code>. If both attempts
552 * throw <code>IllegalArgumentException</code>, then this method
553 * throws a <code>ClassNotFoundException</code>. If any other
554 * exception is thrown, that exception is thrown to the caller.
555 *
556 * <li>if all of the non-<code>public</code> resolved interfaces
557 * are defined in the same class loader, then it attempts to
558 * obtain a dynamic proxy class for the resolved interfaces
559 * defined in that loader.
560 *
561 * <li>otherwise, a <code>LinkageError</code> is thrown (because a
562 * class that implements all of the specified interfaces cannot be
563 * defined in any loader).
564 *
565 * </ul>
566 *
567 * <p>Otherwise, if all of the named interfaces can be resolved
568 * through the codebase loader, then,
569 *
570 * <ul>
571 *
572 * <li>if all of the resolved interfaces are <code>public</code>,
573 * then it attempts to obtain a dynamic proxy class for the
574 * resolved interfaces in the codebase loader. If the attempt
575 * throws an <code>IllegalArgumentException</code>, then this
576 * method throws a <code>ClassNotFoundException</code>.
577 *
578 * <li>if all of the non-<code>public</code> resolved interfaces
579 * are defined in the same class loader, then it attempts to
580 * obtain a dynamic proxy class for the resolved interfaces
581 * defined in that loader.
582 *
583 * <li>otherwise, a <code>LinkageError</code> is thrown (because a
584 * class that implements all of the specified interfaces cannot be
585 * defined in any loader).
586 *
587 * </ul>
588 *
589 * <p>Otherwise, a <code>ClassNotFoundException</code> is thrown
590 * for one of the named interfaces that could not be resolved.
591 *
592 * </blockquote>
593 *
594 * </blockquote>
595 *
596 * @return the canonical instance of the default service provider
597 *
598 * @throws SecurityException if there is a security manager and the
599 * invocation of its <code>checkPermission</code> method fails
600 *
601 * @since 1.4
602 */
603 public static RMIClassLoaderSpi getDefaultProviderInstance() {
604 SecurityManager sm = System.getSecurityManager();
605 if (sm != null) {
606 sm.checkPermission(new RuntimePermission("setFactory"));
607 }
608 return defaultProvider;
609 }
610
611 /**
612 * Returns the security context of the given class loader.
613 *
614 * @param loader a class loader from which to get the security context
615 *
616 * @return the security context
617 *
618 * @deprecated no replacement. As of the Java 2 platform v1.2, RMI no
619 * longer uses this method to obtain a class loader's security context.
620 * @see java.lang.SecurityManager#getSecurityContext()
621 */
622 @Deprecated
623 public static Object getSecurityContext(ClassLoader loader)
624 {
625 return sun.rmi.server.LoaderHandler.getSecurityContext(loader);
626 }
627
628 /**
629 * Creates an instance of the default provider class.
630 */
631 private static RMIClassLoaderSpi newDefaultProviderInstance() {
632 return new RMIClassLoaderSpi() {
633 public Class<?> loadClass(String codebase, String name,
634 ClassLoader defaultLoader)
635 throws MalformedURLException, ClassNotFoundException
636 {
637 return sun.rmi.server.LoaderHandler.loadClass(
638 codebase, name, defaultLoader);
639 }
640
641 public Class<?> loadProxyClass(String codebase,
642 String[] interfaces,
643 ClassLoader defaultLoader)
644 throws MalformedURLException, ClassNotFoundException
645 {
646 return sun.rmi.server.LoaderHandler.loadProxyClass(
647 codebase, interfaces, defaultLoader);
648 }
649
650 public ClassLoader getClassLoader(String codebase)
651 throws MalformedURLException
652 {
653 return sun.rmi.server.LoaderHandler.getClassLoader(codebase);
654 }
655
656 public String getClassAnnotation(Class<?> cl) {
657 return sun.rmi.server.LoaderHandler.getClassAnnotation(cl);
658 }
659 };
660 }
661
662 /**
663 * Chooses provider instance, following above documentation.
664 *
665 * This method assumes that it has been invoked in a privileged block.
666 */
667 private static RMIClassLoaderSpi initializeProvider() {
668 /*
669 * First check for the system property being set:
670 */
671 String providerClassName =
672 System.getProperty("java.rmi.server.RMIClassLoaderSpi");
673
674 if (providerClassName != null) {
675 if (providerClassName.equals("default")) {
676 return defaultProvider;
677 }
678
679 try {
680 Class<? extends RMIClassLoaderSpi> providerClass =
681 Class.forName(providerClassName, false,
682 ClassLoader.getSystemClassLoader())
683 .asSubclass(RMIClassLoaderSpi.class);
684 return providerClass.newInstance();
685
686 } catch (ClassNotFoundException e) {
687 throw new NoClassDefFoundError(e.getMessage());
688 } catch (IllegalAccessException e) {
689 throw new IllegalAccessError(e.getMessage());
690 } catch (InstantiationException e) {
691 throw new InstantiationError(e.getMessage());
692 } catch (ClassCastException e) {
693 Error error = new LinkageError(
694 "provider class not assignable to RMIClassLoaderSpi");
695 error.initCause(e);
696 throw error;
697 }
698 }
699
700 /*
701 * Next look for a provider configuration file installed:
702 */
703 Iterator<RMIClassLoaderSpi> iter =
704 ServiceLoader.load(RMIClassLoaderSpi.class,
705 ClassLoader.getSystemClassLoader()).iterator();
706 if (iter.hasNext()) {
707 try {
708 return iter.next();
709 } catch (ClassCastException e) {
710 Error error = new LinkageError(
711 "provider class not assignable to RMIClassLoaderSpi");
712 error.initCause(e);
713 throw error;
714 }
715 }
716
717 /*
718 * Finally, return the canonical instance of the default provider.
719 */
720 return defaultProvider;
721 }
722}
java/pkg/java/rmi/server/RMIClassLoaderSpi.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIClassLoaderSpi.java+192−0
@@ -0,0 +1,192 @@
1/*
2 * Copyright (c) 2000, 2006, 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.server;
27
28import java.net.MalformedURLException;
29import java.net.URL;
30
31/**
32 * <code>RMIClassLoaderSpi</code> is the service provider interface for
33 * <code>RMIClassLoader</code>.
34 *
35 * In particular, an <code>RMIClassLoaderSpi</code> instance provides an
36 * implementation of the following static methods of
37 * <code>RMIClassLoader</code>:
38 *
39 * <ul>
40 *
41 * <li>{@link RMIClassLoader#loadClass(URL,String)}
42 * <li>{@link RMIClassLoader#loadClass(String,String)}
43 * <li>{@link RMIClassLoader#loadClass(String,String,ClassLoader)}
44 * <li>{@link RMIClassLoader#loadProxyClass(String,String[],ClassLoader)}
45 * <li>{@link RMIClassLoader#getClassLoader(String)}
46 * <li>{@link RMIClassLoader#getClassAnnotation(Class)}
47 *
48 * </ul>
49 *
50 * When one of those methods is invoked, its behavior is to delegate
51 * to a corresponding method on an instance of this class.
52 * The details of how each method delegates to the provider instance is
53 * described in the documentation for each particular method.
54 * See the documentation for {@link RMIClassLoader} for a description
55 * of how a provider instance is chosen.
56 *
57 * @author Peter Jones
58 * @author Laird Dornin
59 * @see RMIClassLoader
60 * @since 1.4
61 */
62public abstract class RMIClassLoaderSpi {
63
64 /**
65 * Provides the implementation for
66 * {@link RMIClassLoader#loadClass(URL,String)},
67 * {@link RMIClassLoader#loadClass(String,String)}, and
68 * {@link RMIClassLoader#loadClass(String,String,ClassLoader)}.
69 *
70 * Loads a class from a codebase URL path, optionally using the
71 * supplied loader.
72 *
73 * Typically, a provider implementation will attempt to
74 * resolve the named class using the given <code>defaultLoader</code>,
75 * if specified, before attempting to resolve the class from the
76 * codebase URL path.
77 *
78 * <p>An implementation of this method must either return a class
79 * with the given name or throw an exception.
80 *
81 * @param codebase the list of URLs (separated by spaces) to load
82 * the class from, or <code>null</code>
83 *
84 * @param name the name of the class to load
85 *
86 * @param defaultLoader additional contextual class loader
87 * to use, or <code>null</code>
88 *
89 * @return the <code>Class</code> object representing the loaded class
90 *
91 * @throws MalformedURLException if <code>codebase</code> is
92 * non-<code>null</code> and contains an invalid URL, or
93 * if <code>codebase</code> is <code>null</code> and a provider-specific
94 * URL used to load classes is invalid
95 *
96 * @throws ClassNotFoundException if a definition for the class
97 * could not be found at the specified location
98 */
99 public abstract Class<?> loadClass(String codebase, String name,
100 ClassLoader defaultLoader)
101 throws MalformedURLException, ClassNotFoundException;
102
103 /**
104 * Provides the implementation for
105 * {@link RMIClassLoader#loadProxyClass(String,String[],ClassLoader)}.
106 *
107 * Loads a dynamic proxy class (see {@link java.lang.reflect.Proxy}
108 * that implements a set of interfaces with the given names
109 * from a codebase URL path, optionally using the supplied loader.
110 *
111 * <p>An implementation of this method must either return a proxy
112 * class that implements the named interfaces or throw an exception.
113 *
114 * @param codebase the list of URLs (space-separated) to load
115 * classes from, or <code>null</code>
116 *
117 * @param interfaces the names of the interfaces for the proxy class
118 * to implement
119 *
120 * @return a dynamic proxy class that implements the named interfaces
121 *
122 * @param defaultLoader additional contextual class loader
123 * to use, or <code>null</code>
124 *
125 * @throws MalformedURLException if <code>codebase</code> is
126 * non-<code>null</code> and contains an invalid URL, or
127 * if <code>codebase</code> is <code>null</code> and a provider-specific
128 * URL used to load classes is invalid
129 *
130 * @throws ClassNotFoundException if a definition for one of
131 * the named interfaces could not be found at the specified location,
132 * or if creation of the dynamic proxy class failed (such as if
133 * {@link java.lang.reflect.Proxy#getProxyClass(ClassLoader,Class[])}
134 * would throw an <code>IllegalArgumentException</code> for the given
135 * interface list)
136 */
137 public abstract Class<?> loadProxyClass(String codebase,
138 String[] interfaces,
139 ClassLoader defaultLoader)
140 throws MalformedURLException, ClassNotFoundException;
141
142 /**
143 * Provides the implementation for
144 * {@link RMIClassLoader#getClassLoader(String)}.
145 *
146 * Returns a class loader that loads classes from the given codebase
147 * URL path.
148 *
149 * <p>If there is a security manger, its <code>checkPermission</code>
150 * method will be invoked with a
151 * <code>RuntimePermission("getClassLoader")</code> permission;
152 * this could result in a <code>SecurityException</code>.
153 * The implementation of this method may also perform further security
154 * checks to verify that the calling context has permission to connect
155 * to all of the URLs in the codebase URL path.
156 *
157 * @param codebase the list of URLs (space-separated) from which
158 * the returned class loader will load classes from, or <code>null</code>
159 *
160 * @return a class loader that loads classes from the given codebase URL
161 * path
162 *
163 * @throws MalformedURLException if <code>codebase</code> is
164 * non-<code>null</code> and contains an invalid URL, or
165 * if <code>codebase</code> is <code>null</code> and a provider-specific
166 * URL used to identify the class loader is invalid
167 *
168 * @throws SecurityException if there is a security manager and the
169 * invocation of its <code>checkPermission</code> method fails, or
170 * if the caller does not have permission to connect to all of the
171 * URLs in the codebase URL path
172 */
173 public abstract ClassLoader getClassLoader(String codebase)
174 throws MalformedURLException; // SecurityException
175
176 /**
177 * Provides the implementation for
178 * {@link RMIClassLoader#getClassAnnotation(Class)}.
179 *
180 * Returns the annotation string (representing a location for
181 * the class definition) that RMI will use to annotate the class
182 * descriptor when marshalling objects of the given class.
183 *
184 * @param cl the class to obtain the annotation for
185 *
186 * @return a string to be used to annotate the given class when
187 * it gets marshalled, or <code>null</code>
188 *
189 * @throws NullPointerException if <code>cl</code> is <code>null</code>
190 */
191 public abstract String getClassAnnotation(Class<?> cl);
192}
java/pkg/java/rmi/server/RMIClientSocketFactory.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIClientSocketFactory.java+74−0
@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 1998, 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 */
25
26package java.rmi.server;
27
28import java.io.*;
29import java.net.*;
30
31/**
32 * An <code>RMIClientSocketFactory</code> instance is used by the RMI runtime
33 * in order to obtain client sockets for RMI calls. A remote object can be
34 * associated with an <code>RMIClientSocketFactory</code> when it is
35 * created/exported via the constructors or <code>exportObject</code> methods
36 * of <code>java.rmi.server.UnicastRemoteObject</code> and
37 * <code>java.rmi.activation.Activatable</code> .
38 *
39 * <p>An <code>RMIClientSocketFactory</code> instance associated with a remote
40 * object will be downloaded to clients when the remote object's reference is
41 * transmitted in an RMI call. This <code>RMIClientSocketFactory</code> will
42 * be used to create connections to the remote object for remote method calls.
43 *
44 * <p>An <code>RMIClientSocketFactory</code> instance can also be associated
45 * with a remote object registry so that clients can use custom socket
46 * communication with a remote object registry.
47 *
48 * <p>An implementation of this interface should be serializable and
49 * should implement {@link Object#equals} to return <code>true</code> when
50 * passed an instance that represents the same (functionally equivalent)
51 * client socket factory, and <code>false</code> otherwise (and it should also
52 * implement {@link Object#hashCode} consistently with its
53 * <code>Object.equals</code> implementation).
54 *
55 * @author Ann Wollrath
56 * @author Peter Jones
57 * @since 1.2
58 * @see java.rmi.server.UnicastRemoteObject
59 * @see java.rmi.activation.Activatable
60 * @see java.rmi.registry.LocateRegistry
61 */
62public interface RMIClientSocketFactory {
63
64 /**
65 * Create a client socket connected to the specified host and port.
66 * @param host the host name
67 * @param port the port number
68 * @return a socket connected to the specified host and port.
69 * @exception IOException if an I/O error occurs during socket creation
70 * @since 1.2
71 */
72 public Socket createSocket(String host, int port)
73 throws IOException;
74}
java/pkg/java/rmi/server/RMIFailureHandler.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIFailureHandler.java+60−0
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi.server;
27
28/**
29 * An <code>RMIFailureHandler</code> can be registered via the
30 * <code>RMISocketFactory.setFailureHandler</code> call. The
31 * <code>failure</code> method of the handler is invoked when the RMI
32 * runtime is unable to create a <code>ServerSocket</code> to listen
33 * for incoming calls. The <code>failure</code> method returns a boolean
34 * indicating whether the runtime should attempt to re-create the
35 * <code>ServerSocket</code>.
36 *
37 * @author Ann Wollrath
38 * @since JDK1.1
39 */
40public interface RMIFailureHandler {
41
42 /**
43 * The <code>failure</code> callback is invoked when the RMI
44 * runtime is unable to create a <code>ServerSocket</code> via the
45 * <code>RMISocketFactory</code>. An <code>RMIFailureHandler</code>
46 * is registered via a call to
47 * <code>RMISocketFacotry.setFailureHandler</code>. If no failure
48 * handler is installed, the default behavior is to attempt to
49 * re-create the ServerSocket.
50 *
51 * @param ex the exception that occurred during <code>ServerSocket</code>
52 * creation
53 * @return if true, the RMI runtime attempts to retry
54 * <code>ServerSocket</code> creation
55 * @see java.rmi.server.RMISocketFactory#setFailureHandler(RMIFailureHandler)
56 * @since JDK1.1
57 */
58 public boolean failure(Exception ex);
59
60}
java/pkg/java/rmi/server/RMIServerSocketFactory.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMIServerSocketFactory.java+74−0
@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 1998, 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 */
25
26package java.rmi.server;
27
28import java.io.*;
29import java.net.*;
30
31/**
32 * An <code>RMIServerSocketFactory</code> instance is used by the RMI runtime
33 * in order to obtain server sockets for RMI calls. A remote object can be
34 * associated with an <code>RMIServerSocketFactory</code> when it is
35 * created/exported via the constructors or <code>exportObject</code> methods
36 * of <code>java.rmi.server.UnicastRemoteObject</code> and
37 * <code>java.rmi.activation.Activatable</code> .
38 *
39 * <p>An <code>RMIServerSocketFactory</code> instance associated with a remote
40 * object is used to obtain the <code>ServerSocket</code> used to accept
41 * incoming calls from clients.
42 *
43 * <p>An <code>RMIServerSocketFactory</code> instance can also be associated
44 * with a remote object registry so that clients can use custom socket
45 * communication with a remote object registry.
46 *
47 * <p>An implementation of this interface
48 * should implement {@link Object#equals} to return <code>true</code> when
49 * passed an instance that represents the same (functionally equivalent)
50 * server socket factory, and <code>false</code> otherwise (and it should also
51 * implement {@link Object#hashCode} consistently with its
52 * <code>Object.equals</code> implementation).
53 *
54 * @author Ann Wollrath
55 * @author Peter Jones
56 * @since 1.2
57 * @see java.rmi.server.UnicastRemoteObject
58 * @see java.rmi.activation.Activatable
59 * @see java.rmi.registry.LocateRegistry
60 */
61public interface RMIServerSocketFactory {
62
63 /**
64 * Create a server socket on the specified port (port 0 indicates
65 * an anonymous port).
66 * @param port the port number
67 * @return the server socket on the specified port
68 * @exception IOException if an I/O error occurs during server socket
69 * creation
70 * @since 1.2
71 */
72 public ServerSocket createServerSocket(int port)
73 throws IOException;
74}
java/pkg/java/rmi/server/RMISocketFactory.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RMISocketFactory.java+188−0
@@ -0,0 +1,188 @@
1/*
2 * Copyright (c) 1996, 2002, 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.server;
27
28import java.io.*;
29import java.net.*;
30
31/**
32 * An <code>RMISocketFactory</code> instance is used by the RMI runtime
33 * in order to obtain client and server sockets for RMI calls. An
34 * application may use the <code>setSocketFactory</code> method to
35 * request that the RMI runtime use its socket factory instance
36 * instead of the default implementation.<p>
37 *
38 * The default socket factory implementation used goes through a
39 * three-tiered approach to creating client sockets. First, a direct
40 * socket connection to the remote VM is attempted. If that fails
41 * (due to a firewall), the runtime uses HTTP with the explicit port
42 * number of the server. If the firewall does not allow this type of
43 * communication, then HTTP to a cgi-bin script on the server is used
44 * to POST the RMI call.<p>
45 *
46 * @author Ann Wollrath
47 * @author Peter Jones
48 * @since JDK1.1
49 */
50public abstract class RMISocketFactory
51 implements RMIClientSocketFactory, RMIServerSocketFactory
52{
53
54 /** Client/server socket factory to be used by RMI runtime */
55 private static RMISocketFactory factory = null;
56 /** default socket factory used by this RMI implementation */
57 private static RMISocketFactory defaultSocketFactory;
58 /** Handler for socket creation failure */
59 private static RMIFailureHandler handler = null;
60
61 /**
62 * Constructs an <code>RMISocketFactory</code>.
63 * @since JDK1.1
64 */
65 public RMISocketFactory() {
66 super();
67 }
68
69 /**
70 * Creates a client socket connected to the specified host and port.
71 * @param host the host name
72 * @param port the port number
73 * @return a socket connected to the specified host and port.
74 * @exception IOException if an I/O error occurs during socket creation
75 * @since JDK1.1
76 */
77 public abstract Socket createSocket(String host, int port)
78 throws IOException;
79
80 /**
81 * Create a server socket on the specified port (port 0 indicates
82 * an anonymous port).
83 * @param port the port number
84 * @return the server socket on the specified port
85 * @exception IOException if an I/O error occurs during server socket
86 * creation
87 * @since JDK1.1
88 */
89 public abstract ServerSocket createServerSocket(int port)
90 throws IOException;
91
92 /**
93 * Set the global socket factory from which RMI gets sockets (if the
94 * remote object is not associated with a specific client and/or server
95 * socket factory). The RMI socket factory can only be set once. Note: The
96 * RMISocketFactory may only be set if the current security manager allows
97 * setting a socket factory; if disallowed, a SecurityException will be
98 * thrown.
99 * @param fac the socket factory
100 * @exception IOException if the RMI socket factory is already set
101 * @exception SecurityException if a security manager exists and its
102 * <code>checkSetFactory</code> method doesn't allow the operation.
103 * @see #getSocketFactory
104 * @see java.lang.SecurityManager#checkSetFactory()
105 * @since JDK1.1
106 */
107 public synchronized static void setSocketFactory(RMISocketFactory fac)
108 throws IOException
109 {
110 if (factory != null) {
111 throw new SocketException("factory already defined");
112 }
113 SecurityManager security = System.getSecurityManager();
114 if (security != null) {
115 security.checkSetFactory();
116 }
117 factory = fac;
118 }
119
120 /**
121 * Returns the socket factory set by the <code>setSocketFactory</code>
122 * method. Returns <code>null</code> if no socket factory has been
123 * set.
124 * @return the socket factory
125 * @see #setSocketFactory(RMISocketFactory)
126 * @since JDK1.1
127 */
128 public synchronized static RMISocketFactory getSocketFactory()
129 {
130 return factory;
131 }
132
133 /**
134 * Returns a reference to the default socket factory used
135 * by this RMI implementation. This will be the factory used
136 * by the RMI runtime when <code>getSocketFactory</code>
137 * returns <code>null</code>.
138 * @return the default RMI socket factory
139 * @since JDK1.1
140 */
141 public synchronized static RMISocketFactory getDefaultSocketFactory() {
142 if (defaultSocketFactory == null) {
143 defaultSocketFactory =
144 new sun.rmi.transport.proxy.RMIMasterSocketFactory();
145 }
146 return defaultSocketFactory;
147 }
148
149 /**
150 * Sets the failure handler to be called by the RMI runtime if server
151 * socket creation fails. By default, if no failure handler is installed
152 * and server socket creation fails, the RMI runtime does attempt to
153 * recreate the server socket.
154 *
155 * <p>If there is a security manager, this method first calls
156 * the security manager's <code>checkSetFactory</code> method
157 * to ensure the operation is allowed.
158 * This could result in a <code>SecurityException</code>.
159 *
160 * @param fh the failure handler
161 * @throws SecurityException if a security manager exists and its
162 * <code>checkSetFactory</code> method doesn't allow the
163 * operation.
164 * @see #getFailureHandler
165 * @see java.rmi.server.RMIFailureHandler#failure(Exception)
166 * @since JDK1.1
167 */
168 public synchronized static void setFailureHandler(RMIFailureHandler fh)
169 {
170 SecurityManager security = System.getSecurityManager();
171 if (security != null) {
172 security.checkSetFactory();
173 }
174 handler = fh;
175 }
176
177 /**
178 * Returns the handler for socket creation failure set by the
179 * <code>setFailureHandler</code> method.
180 * @return the failure handler
181 * @see #setFailureHandler(RMIFailureHandler)
182 * @since JDK1.1
183 */
184 public synchronized static RMIFailureHandler getFailureHandler()
185 {
186 return handler;
187 }
188}
java/pkg/java/rmi/server/RemoteCall.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteCall.java+132−0
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 1996, 2006, 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.server;
27import java.rmi.*;
28import java.io.ObjectOutput;
29import java.io.ObjectInput;
30import java.io.StreamCorruptedException;
31import java.io.IOException;
32
33/**
34 * <code>RemoteCall</code> is an abstraction used solely by the RMI runtime
35 * (in conjunction with stubs and skeletons of remote objects) to carry out a
36 * call to a remote object. The <code>RemoteCall</code> interface is
37 * deprecated because it is only used by deprecated methods of
38 * <code>java.rmi.server.RemoteRef</code>.
39 *
40 * @since JDK1.1
41 * @author Ann Wollrath
42 * @author Roger Riggs
43 * @see java.rmi.server.RemoteRef
44 * @deprecated no replacement.
45 */
46@Deprecated
47public interface RemoteCall {
48
49 /**
50 * Return the output stream the stub/skeleton should put arguments/results
51 * into.
52 *
53 * @return output stream for arguments/results
54 * @exception java.io.IOException if an I/O error occurs.
55 * @since JDK1.1
56 * @deprecated no replacement
57 */
58 @Deprecated
59 ObjectOutput getOutputStream() throws IOException;
60
61 /**
62 * Release the output stream; in some transports this would release
63 * the stream.
64 *
65 * @exception java.io.IOException if an I/O error occurs.
66 * @since JDK1.1
67 * @deprecated no replacement
68 */
69 @Deprecated
70 void releaseOutputStream() throws IOException;
71
72 /**
73 * Get the InputStream that the stub/skeleton should get
74 * results/arguments from.
75 *
76 * @return input stream for reading arguments/results
77 * @exception java.io.IOException if an I/O error occurs.
78 * @since JDK1.1
79 * @deprecated no replacement
80 */
81 @Deprecated
82 ObjectInput getInputStream() throws IOException;
83
84
85 /**
86 * Release the input stream. This would allow some transports to release
87 * the channel early.
88 *
89 * @exception java.io.IOException if an I/O error occurs.
90 * @since JDK1.1
91 * @deprecated no replacement
92 */
93 @Deprecated
94 void releaseInputStream() throws IOException;
95
96 /**
97 * Returns an output stream (may put out header information
98 * relating to the success of the call). Should only succeed
99 * once per remote call.
100 *
101 * @param success If true, indicates normal return, else indicates
102 * exceptional return.
103 * @return output stream for writing call result
104 * @exception java.io.IOException if an I/O error occurs.
105 * @exception java.io.StreamCorruptedException If already been called.
106 * @since JDK1.1
107 * @deprecated no replacement
108 */
109 @Deprecated
110 ObjectOutput getResultStream(boolean success) throws IOException,
111 StreamCorruptedException;
112
113 /**
114 * Do whatever it takes to execute the call.
115 *
116 * @exception java.lang.Exception if a general exception occurs.
117 * @since JDK1.1
118 * @deprecated no replacement
119 */
120 @Deprecated
121 void executeCall() throws Exception;
122
123 /**
124 * Allow cleanup after the remote call has completed.
125 *
126 * @exception java.io.IOException if an I/O error occurs.
127 * @since JDK1.1
128 * @deprecated no replacement
129 */
130 @Deprecated
131 void done() throws IOException;
132}
java/pkg/java/rmi/server/RemoteObject.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteObject.java+458−0
@@ -0,0 +1,458 @@
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.server;
27
28import java.rmi.Remote;
29import java.rmi.NoSuchObjectException;
30import java.lang.reflect.Proxy;
31import sun.rmi.server.Util;
32
33/**
34 * The <code>RemoteObject</code> class implements the
35 * <code>java.lang.Object</code> behavior for remote objects.
36 * <code>RemoteObject</code> provides the remote semantics of Object by
37 * implementing methods for hashCode, equals, and toString.
38 *
39 * @author Ann Wollrath
40 * @author Laird Dornin
41 * @author Peter Jones
42 * @since JDK1.1
43 */
44public abstract class RemoteObject implements Remote, java.io.Serializable {
45
46 /** The object's remote reference. */
47 transient protected RemoteRef ref;
48
49 /** indicate compatibility with JDK 1.1.x version of class */
50 private static final long serialVersionUID = -3215090123894869218L;
51
52 /**
53 * Creates a remote object.
54 */
55 protected RemoteObject() {
56 ref = null;
57 }
58
59 /**
60 * Creates a remote object, initialized with the specified remote
61 * reference.
62 * @param newref remote reference
63 */
64 protected RemoteObject(RemoteRef newref) {
65 ref = newref;
66 }
67
68 /**
69 * Returns the remote reference for the remote object.
70 *
71 * <p>Note: The object returned from this method may be an instance of
72 * an implementation-specific class. The <code>RemoteObject</code>
73 * class ensures serialization portability of its instances' remote
74 * references through the behavior of its custom
75 * <code>writeObject</code> and <code>readObject</code> methods. An
76 * instance of <code>RemoteRef</code> should not be serialized outside
77 * of its <code>RemoteObject</code> wrapper instance or the result may
78 * be unportable.
79 *
80 * @return remote reference for the remote object
81 * @since 1.2
82 */
83 public RemoteRef getRef() {
84 return ref;
85 }
86
87 /**
88 * Returns the stub for the remote object <code>obj</code> passed
89 * as a parameter. This operation is only valid <i>after</i>
90 * the object has been exported.
91 * @param obj the remote object whose stub is needed
92 * @return the stub for the remote object, <code>obj</code>.
93 * @exception NoSuchObjectException if the stub for the
94 * remote object could not be found.
95 * @since 1.2
96 */
97 public static Remote toStub(Remote obj) throws NoSuchObjectException {
98 if (obj instanceof RemoteStub ||
99 (obj != null &&
100 Proxy.isProxyClass(obj.getClass()) &&
101 Proxy.getInvocationHandler(obj) instanceof
102 RemoteObjectInvocationHandler))
103 {
104 return obj;
105 } else {
106 return sun.rmi.transport.ObjectTable.getStub(obj);
107 }
108 }
109
110 /**
111 * Returns a hashcode for a remote object. Two remote object stubs
112 * that refer to the same remote object will have the same hash code
113 * (in order to support remote objects as keys in hash tables).
114 *
115 * @see java.util.Hashtable
116 */
117 public int hashCode() {
118 return (ref == null) ? super.hashCode() : ref.remoteHashCode();
119 }
120
121 /**
122 * Compares two remote objects for equality.
123 * Returns a boolean that indicates whether this remote object is
124 * equivalent to the specified Object. This method is used when a
125 * remote object is stored in a hashtable.
126 * If the specified Object is not itself an instance of RemoteObject,
127 * then this method delegates by returning the result of invoking the
128 * <code>equals</code> method of its parameter with this remote object
129 * as the argument.
130 * @param obj the Object to compare with
131 * @return true if these Objects are equal; false otherwise.
132 * @see java.util.Hashtable
133 */
134 public boolean equals(Object obj) {
135 if (obj instanceof RemoteObject) {
136 if (ref == null) {
137 return obj == this;
138 } else {
139 return ref.remoteEquals(((RemoteObject)obj).ref);
140 }
141 } else if (obj != null) {
142 /*
143 * Fix for 4099660: if object is not an instance of RemoteObject,
144 * use the result of its equals method, to support symmetry is a
145 * remote object implementation class that does not extend
146 * RemoteObject wishes to support equality with its stub objects.
147 */
148 return obj.equals(this);
149 } else {
150 return false;
151 }
152 }
153
154 /**
155 * Returns a String that represents the value of this remote object.
156 */
157 public String toString() {
158 String classname = Util.getUnqualifiedName(getClass());
159 return (ref == null) ? classname :
160 classname + "[" + ref.remoteToString() + "]";
161 }
162
163 /**
164 * <code>writeObject</code> for custom serialization.
165 *
166 * <p>This method writes this object's serialized form for this class
167 * as follows:
168 *
169 * <p>The {@link RemoteRef#getRefClass(java.io.ObjectOutput) getRefClass}
170 * method is invoked on this object's <code>ref</code> field
171 * to obtain its external ref type name.
172 * If the value returned by <code>getRefClass</code> was
173 * a non-<code>null</code> string of length greater than zero,
174 * the <code>writeUTF</code> method is invoked on <code>out</code>
175 * with the value returned by <code>getRefClass</code>, and then
176 * the <code>writeExternal</code> method is invoked on
177 * this object's <code>ref</code> field passing <code>out</code>
178 * as the argument; otherwise,
179 * the <code>writeUTF</code> method is invoked on <code>out</code>
180 * with a zero-length string (<code>""</code>), and then
181 * the <code>writeObject</code> method is invoked on <code>out</code>
182 * passing this object's <code>ref</code> field as the argument.
183 *
184 * @serialData
185 *
186 * The serialized data for this class comprises a string (written with
187 * <code>ObjectOutput.writeUTF</code>) that is either the external
188 * ref type name of the contained <code>RemoteRef</code> instance
189 * (the <code>ref</code> field) or a zero-length string, followed by
190 * either the external form of the <code>ref</code> field as written by
191 * its <code>writeExternal</code> method if the string was of non-zero
192 * length, or the serialized form of the <code>ref</code> field as
193 * written by passing it to the serialization stream's
194 * <code>writeObject</code> if the string was of zero length.
195 *
196 * <p>If this object is an instance of
197 * {@link RemoteStub} or {@link RemoteObjectInvocationHandler}
198 * that was returned from any of
199 * the <code>UnicastRemoteObject.exportObject</code> methods
200 * and custom socket factories are not used,
201 * the external ref type name is <code>"UnicastRef"</code>.
202 *
203 * If this object is an instance of
204 * <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
205 * that was returned from any of
206 * the <code>UnicastRemoteObject.exportObject</code> methods
207 * and custom socket factories are used,
208 * the external ref type name is <code>"UnicastRef2"</code>.
209 *
210 * If this object is an instance of
211 * <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
212 * that was returned from any of
213 * the <code>java.rmi.activation.Activatable.exportObject</code> methods,
214 * the external ref type name is <code>"ActivatableRef"</code>.
215 *
216 * If this object is an instance of
217 * <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
218 * that was returned from
219 * the <code>RemoteObject.toStub</code> method (and the argument passed
220 * to <code>toStub</code> was not itself a <code>RemoteStub</code>),
221 * the external ref type name is a function of how the remote object
222 * passed to <code>toStub</code> was exported, as described above.
223 *
224 * If this object is an instance of
225 * <code>RemoteStub</code> or <code>RemoteObjectInvocationHandler</code>
226 * that was originally created via deserialization,
227 * the external ref type name is the same as that which was read
228 * when this object was deserialized.
229 *
230 * <p>If this object is an instance of
231 * <code>java.rmi.server.UnicastRemoteObject</code> that does not
232 * use custom socket factories,
233 * the external ref type name is <code>"UnicastServerRef"</code>.
234 *
235 * If this object is an instance of
236 * <code>UnicastRemoteObject</code> that does
237 * use custom socket factories,
238 * the external ref type name is <code>"UnicastServerRef2"</code>.
239 *
240 * <p>Following is the data that must be written by the
241 * <code>writeExternal</code> method and read by the
242 * <code>readExternal</code> method of <code>RemoteRef</code>
243 * implementation classes that correspond to the each of the
244 * defined external ref type names:
245 *
246 * <p>For <code>"UnicastRef"</code>:
247 *
248 * <ul>
249 *
250 * <li>the hostname of the referenced remote object,
251 * written by {@link java.io.ObjectOutput#writeUTF(String)}
252 *
253 * <li>the port of the referenced remote object,
254 * written by {@link java.io.ObjectOutput#writeInt(int)}
255 *
256 * <li>the data written as a result of calling
257 * {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
258 * on the <code>ObjID</code> instance contained in the reference
259 *
260 * <li>the boolean value <code>false</code>,
261 * written by {@link java.io.ObjectOutput#writeBoolean(boolean)}
262 *
263 * </ul>
264 *
265 * <p>For <code>"UnicastRef2"</code> with a
266 * <code>null</code> client socket factory:
267 *
268 * <ul>
269 *
270 * <li>the byte value <code>0x00</code>
271 * (indicating <code>null</code> client socket factory),
272 * written by {@link java.io.ObjectOutput#writeByte(int)}
273 *
274 * <li>the hostname of the referenced remote object,
275 * written by {@link java.io.ObjectOutput#writeUTF(String)}
276 *
277 * <li>the port of the referenced remote object,
278 * written by {@link java.io.ObjectOutput#writeInt(int)}
279 *
280 * <li>the data written as a result of calling
281 * {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
282 * on the <code>ObjID</code> instance contained in the reference
283 *
284 * <li>the boolean value <code>false</code>,
285 * written by {@link java.io.ObjectOutput#writeBoolean(boolean)}
286 *
287 * </ul>
288 *
289 * <p>For <code>"UnicastRef2"</code> with a
290 * non-<code>null</code> client socket factory:
291 *
292 * <ul>
293 *
294 * <li>the byte value <code>0x01</code>
295 * (indicating non-<code>null</code> client socket factory),
296 * written by {@link java.io.ObjectOutput#writeByte(int)}
297 *
298 * <li>the hostname of the referenced remote object,
299 * written by {@link java.io.ObjectOutput#writeUTF(String)}
300 *
301 * <li>the port of the referenced remote object,
302 * written by {@link java.io.ObjectOutput#writeInt(int)}
303 *
304 * <li>a client socket factory (object of type
305 * <code>java.rmi.server.RMIClientSocketFactory</code>),
306 * written by passing it to an invocation of
307 * <code>writeObject</code> on the stream instance
308 *
309 * <li>the data written as a result of calling
310 * {link java.rmi.server.ObjID#write(java.io.ObjectOutput)}
311 * on the <code>ObjID</code> instance contained in the reference
312 *
313 * <li>the boolean value <code>false</code>,
314 * written by {@link java.io.ObjectOutput#writeBoolean(boolean)}
315 *
316 * </ul>
317 *
318 * <p>For <code>"ActivatableRef"</code> with a
319 * <code>null</code> nested remote reference:
320 *
321 * <ul>
322 *
323 * <li>an instance of
324 * <code>java.rmi.activation.ActivationID</code>,
325 * written by passing it to an invocation of
326 * <code>writeObject</code> on the stream instance
327 *
328 * <li>a zero-length string (<code>""</code>),
329 * written by {@link java.io.ObjectOutput#writeUTF(String)}
330 *
331 * </ul>
332 *
333 * <p>For <code>"ActivatableRef"</code> with a
334 * non-<code>null</code> nested remote reference:
335 *
336 * <ul>
337 *
338 * <li>an instance of
339 * <code>java.rmi.activation.ActivationID</code>,
340 * written by passing it to an invocation of
341 * <code>writeObject</code> on the stream instance
342 *
343 * <li>the external ref type name of the nested remote reference,
344 * which must be <code>"UnicastRef2"</code>,
345 * written by {@link java.io.ObjectOutput#writeUTF(String)}
346 *
347 * <li>the external form of the nested remote reference,
348 * written by invoking its <code>writeExternal</code> method
349 * with the stream instance
350 * (see the description of the external form for
351 * <code>"UnicastRef2"</code> above)
352 *
353 * </ul>
354 *
355 * <p>For <code>"UnicastServerRef"</code> and
356 * <code>"UnicastServerRef2"</code>, no data is written by the
357 * <code>writeExternal</code> method or read by the
358 * <code>readExternal</code> method.
359 */
360 private void writeObject(java.io.ObjectOutputStream out)
361 throws java.io.IOException, java.lang.ClassNotFoundException
362 {
363 if (ref == null) {
364 throw new java.rmi.MarshalException("Invalid remote object");
365 } else {
366 String refClassName = ref.getRefClass(out);
367 if (refClassName == null || refClassName.length() == 0) {
368 /*
369 * No reference class name specified, so serialize
370 * remote reference.
371 */
372 out.writeUTF("");
373 out.writeObject(ref);
374 } else {
375 /*
376 * Built-in reference class specified, so delegate
377 * to reference to write out its external form.
378 */
379 out.writeUTF(refClassName);
380 ref.writeExternal(out);
381 }
382 }
383 }
384
385 /**
386 * <code>readObject</code> for custom serialization.
387 *
388 * <p>This method reads this object's serialized form for this class
389 * as follows:
390 *
391 * <p>The <code>readUTF</code> method is invoked on <code>in</code>
392 * to read the external ref type name for the <code>RemoteRef</code>
393 * instance to be filled in to this object's <code>ref</code> field.
394 * If the string returned by <code>readUTF</code> has length zero,
395 * the <code>readObject</code> method is invoked on <code>in</code>,
396 * and than the value returned by <code>readObject</code> is cast to
397 * <code>RemoteRef</code> and this object's <code>ref</code> field is
398 * set to that value.
399 * Otherwise, this object's <code>ref</code> field is set to a
400 * <code>RemoteRef</code> instance that is created of an
401 * implementation-specific class corresponding to the external ref
402 * type name returned by <code>readUTF</code>, and then
403 * the <code>readExternal</code> method is invoked on
404 * this object's <code>ref</code> field.
405 *
406 * <p>If the external ref type name is
407 * <code>"UnicastRef"</code>, <code>"UnicastServerRef"</code>,
408 * <code>"UnicastRef2"</code>, <code>"UnicastServerRef2"</code>,
409 * or <code>"ActivatableRef"</code>, a corresponding
410 * implementation-specific class must be found, and its
411 * <code>readExternal</code> method must read the serial data
412 * for that external ref type name as specified to be written
413 * in the <b>serialData</b> documentation for this class.
414 * If the external ref type name is any other string (of non-zero
415 * length), a <code>ClassNotFoundException</code> will be thrown,
416 * unless the implementation provides an implementation-specific
417 * class corresponding to that external ref type name, in which
418 * case this object's <code>ref</code> field will be set to an
419 * instance of that implementation-specific class.
420 */
421 private void readObject(java.io.ObjectInputStream in)
422 throws java.io.IOException, java.lang.ClassNotFoundException
423 {
424 String refClassName = in.readUTF();
425 if (refClassName == null || refClassName.length() == 0) {
426 /*
427 * No reference class name specified, so construct
428 * remote reference from its serialized form.
429 */
430 ref = (RemoteRef) in.readObject();
431 } else {
432 /*
433 * Built-in reference class specified, so delegate to
434 * internal reference class to initialize its fields from
435 * its external form.
436 */
437 String internalRefClassName =
438 RemoteRef.packagePrefix + "." + refClassName;
439 Class refClass = Class.forName(internalRefClassName);
440 try {
441 ref = (RemoteRef) refClass.newInstance();
442
443 /*
444 * If this step fails, assume we found an internal
445 * class that is not meant to be a serializable ref
446 * type.
447 */
448 } catch (InstantiationException e) {
449 throw new ClassNotFoundException(internalRefClassName, e);
450 } catch (IllegalAccessException e) {
451 throw new ClassNotFoundException(internalRefClassName, e);
452 } catch (ClassCastException e) {
453 throw new ClassNotFoundException(internalRefClassName, e);
454 }
455 ref.readExternal(in);
456 }
457 }
458}
java/pkg/java/rmi/server/RemoteObjectInvocationHandler$MethodToHash_Maps$1.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteObjectInvocationHandler$MethodToHash_Maps.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteObjectInvocationHandler.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteObjectInvocationHandler.java+283−0
@@ -0,0 +1,283 @@
1/*
2 * Copyright (c) 2003, 2005, 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.server;
26
27import java.io.InvalidObjectException;
28import java.lang.reflect.InvocationHandler;
29import java.lang.reflect.Method;
30import java.lang.reflect.Proxy;
31import java.rmi.Remote;
32import java.rmi.UnexpectedException;
33import java.rmi.activation.Activatable;
34import java.util.Map;
35import java.util.WeakHashMap;
36import sun.rmi.server.Util;
37import sun.rmi.server.WeakClassHashMap;
38
39/**
40 * An implementation of the <code>InvocationHandler</code> interface for
41 * use with Java Remote Method Invocation (Java RMI). This invocation
42 * handler can be used in conjunction with a dynamic proxy instance as a
43 * replacement for a pregenerated stub class.
44 *
45 * <p>Applications are not expected to use this class directly. A remote
46 * object exported to use a dynamic proxy with {@link UnicastRemoteObject}
47 * or {@link Activatable} has an instance of this class as that proxy's
48 * invocation handler.
49 *
50 * @author Ann Wollrath
51 * @since 1.5
52 **/
53public class RemoteObjectInvocationHandler
54 extends RemoteObject
55 implements InvocationHandler
56{
57 private static final long serialVersionUID = 2L;
58
59 /**
60 * A weak hash map, mapping classes to weak hash maps that map
61 * method objects to method hashes.
62 **/
63 private static final MethodToHash_Maps methodToHash_Maps =
64 new MethodToHash_Maps();
65
66 /**
67 * Creates a new <code>RemoteObjectInvocationHandler</code> constructed
68 * with the specified <code>RemoteRef</code>.
69 *
70 * @param ref the remote ref
71 *
72 * @throws NullPointerException if <code>ref</code> is <code>null</code>
73 **/
74 public RemoteObjectInvocationHandler(RemoteRef ref) {
75 super(ref);
76 if (ref == null) {
77 throw new NullPointerException();
78 }
79 }
80
81 /**
82 * Processes a method invocation made on the encapsulating
83 * proxy instance, <code>proxy</code>, and returns the result.
84 *
85 * <p><code>RemoteObjectInvocationHandler</code> implements this method
86 * as follows:
87 *
88 * <p>If <code>method</code> is one of the following methods, it
89 * is processed as described below:
90 *
91 * <ul>
92 *
93 * <li>{@link Object#hashCode Object.hashCode}: Returns the hash
94 * code value for the proxy.
95 *
96 * <li>{@link Object#equals Object.equals}: Returns <code>true</code>
97 * if the argument (<code>args[0]</code>) is an instance of a dynamic
98 * proxy class and this invocation handler is equal to the invocation
99 * handler of that argument, and returns <code>false</code> otherwise.
100 *
101 * <li>{@link Object#toString Object.toString}: Returns a string
102 * representation of the proxy.
103 * </ul>
104 *
105 * <p>Otherwise, a remote call is made as follows:
106 *
107 * <ul>
108 * <li>If <code>proxy</code> is not an instance of the interface
109 * {@link Remote}, then an {@link IllegalArgumentException} is thrown.
110 *
111 * <li>Otherwise, the {@link RemoteRef#invoke invoke} method is invoked
112 * on this invocation handler's <code>RemoteRef</code>, passing
113 * <code>proxy</code>, <code>method</code>, <code>args</code>, and the
114 * method hash (defined in section 8.3 of the "Java Remote Method
115 * Invocation (RMI) Specification") for <code>method</code>, and the
116 * result is returned.
117 *
118 * <li>If an exception is thrown by <code>RemoteRef.invoke</code> and
119 * that exception is a checked exception that is not assignable to any
120 * exception in the <code>throws</code> clause of the method
121 * implemented by the <code>proxy</code>'s class, then that exception
122 * is wrapped in an {@link UnexpectedException} and the wrapped
123 * exception is thrown. Otherwise, the exception thrown by
124 * <code>invoke</code> is thrown by this method.
125 * </ul>
126 *
127 * <p>The semantics of this method are unspecified if the
128 * arguments could not have been produced by an instance of some
129 * valid dynamic proxy class containing this invocation handler.
130 *
131 * @param proxy the proxy instance that the method was invoked on
132 * @param method the <code>Method</code> instance corresponding to the
133 * interface method invoked on the proxy instance
134 * @param args an array of objects containing the values of the
135 * arguments passed in the method invocation on the proxy instance, or
136 * <code>null</code> if the method takes no arguments
137 * @return the value to return from the method invocation on the proxy
138 * instance
139 * @throws Throwable the exception to throw from the method invocation
140 * on the proxy instance
141 **/
142 public Object invoke(Object proxy, Method method, Object[] args)
143 throws Throwable
144 {
145 if (method.getDeclaringClass() == Object.class) {
146 return invokeObjectMethod(proxy, method, args);
147 } else {
148 return invokeRemoteMethod(proxy, method, args);
149 }
150 }
151
152 /**
153 * Handles java.lang.Object methods.
154 **/
155 private Object invokeObjectMethod(Object proxy,
156 Method method,
157 Object[] args)
158 {
159 String name = method.getName();
160
161 if (name.equals("hashCode")) {
162 return hashCode();
163
164 } else if (name.equals("equals")) {
165 Object obj = args[0];
166 return
167 proxy == obj ||
168 (obj != null &&
169 Proxy.isProxyClass(obj.getClass()) &&
170 equals(Proxy.getInvocationHandler(obj)));
171
172 } else if (name.equals("toString")) {
173 return proxyToString(proxy);
174
175 } else {
176 throw new IllegalArgumentException(
177 "unexpected Object method: " + method);
178 }
179 }
180
181 /**
182 * Handles remote methods.
183 **/
184 private Object invokeRemoteMethod(Object proxy,
185 Method method,
186 Object[] args)
187 throws Exception
188 {
189 try {
190 if (!(proxy instanceof Remote)) {
191 throw new IllegalArgumentException(
192 "proxy not Remote instance");
193 }
194 return ref.invoke((Remote) proxy, method, args,
195 getMethodHash(method));
196 } catch (Exception e) {
197 if (!(e instanceof RuntimeException)) {
198 Class<?> cl = proxy.getClass();
199 try {
200 method = cl.getMethod(method.getName(),
201 method.getParameterTypes());
202 } catch (NoSuchMethodException nsme) {
203 throw (IllegalArgumentException)
204 new IllegalArgumentException().initCause(nsme);
205 }
206 Class<?> thrownType = e.getClass();
207 for (Class<?> declaredType : method.getExceptionTypes()) {
208 if (declaredType.isAssignableFrom(thrownType)) {
209 throw e;
210 }
211 }
212 e = new UnexpectedException("unexpected exception", e);
213 }
214 throw e;
215 }
216 }
217
218 /**
219 * Returns a string representation for a proxy that uses this invocation
220 * handler.
221 **/
222 private String proxyToString(Object proxy) {
223 Class<?>[] interfaces = proxy.getClass().getInterfaces();
224 if (interfaces.length == 0) {
225 return "Proxy[" + this + "]";
226 }
227 String iface = interfaces[0].getName();
228 if (iface.equals("java.rmi.Remote") && interfaces.length > 1) {
229 iface = interfaces[1].getName();
230 }
231 int dot = iface.lastIndexOf('.');
232 if (dot >= 0) {
233 iface = iface.substring(dot + 1);
234 }
235 return "Proxy[" + iface + "," + this + "]";
236 }
237
238 /**
239 * @throws InvalidObjectException unconditionally
240 **/
241 private void readObjectNoData() throws InvalidObjectException {
242 throw new InvalidObjectException("no data in stream; class: " +
243 this.getClass().getName());
244 }
245
246 /**
247 * Returns the method hash for the specified method. Subsequent calls
248 * to "getMethodHash" passing the same method argument should be faster
249 * since this method caches internally the result of the method to
250 * method hash mapping. The method hash is calculated using the
251 * "computeMethodHash" method.
252 *
253 * @param method the remote method
254 * @return the method hash for the specified method
255 */
256 private static long getMethodHash(Method method) {
257 return methodToHash_Maps.get(method.getDeclaringClass()).get(method);
258 }
259
260 /**
261 * A weak hash map, mapping classes to weak hash maps that map
262 * method objects to method hashes.
263 **/
264 private static class MethodToHash_Maps
265 extends WeakClassHashMap<Map<Method,Long>>
266 {
267 MethodToHash_Maps() {}
268
269 protected Map<Method,Long> computeValue(Class<?> remoteClass) {
270 return new WeakHashMap<Method,Long>() {
271 public synchronized Long get(Object key) {
272 Long hash = super.get(key);
273 if (hash == null) {
274 Method method = (Method) key;
275 hash = Util.computeMethodHash(method);
276 put(method, hash);
277 }
278 return hash;
279 }
280 };
281 }
282 }
283}
java/pkg/java/rmi/server/RemoteRef.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteRef.java+195−0
@@ -0,0 +1,195 @@
1/*
2 * Copyright (c) 1996, 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.server;
27
28import java.rmi.*;
29
30/**
31 * <code>RemoteRef</code> represents the handle for a remote object. A
32 * <code>RemoteStub</code> uses a remote reference to carry out a
33 * remote method invocation to a remote object.
34 *
35 * @author Ann Wollrath
36 * @since JDK1.1
37 * @see java.rmi.server.RemoteStub
38 */
39public interface RemoteRef extends java.io.Externalizable {
40
41 /** indicate compatibility with JDK 1.1.x version of class. */
42 static final long serialVersionUID = 3632638527362204081L;
43
44 /**
45 * Initialize the server package prefix: assumes that the
46 * implementation of server ref classes (e.g., UnicastRef,
47 * UnicastServerRef) are located in the package defined by the
48 * prefix.
49 */
50 final static String packagePrefix = "sun.rmi.server";
51
52 /**
53 * Invoke a method. This form of delegating method invocation
54 * to the reference allows the reference to take care of
55 * setting up the connection to the remote host, marshaling
56 * some representation for the method and parameters, then
57 * communicating the method invocation to the remote host.
58 * This method either returns the result of a method invocation
59 * on the remote object which resides on the remote host or
60 * throws a RemoteException if the call failed or an
61 * application-level exception if the remote invocation throws
62 * an exception.
63 *
64 * @param obj the object that contains the RemoteRef (e.g., the
65 * RemoteStub for the object.
66 * @param method the method to be invoked
67 * @param params the parameter list
68 * @param opnum a hash that may be used to represent the method
69 * @return result of remote method invocation
70 * @exception Exception if any exception occurs during remote method
71 * invocation
72 * @since 1.2
73 */
74 Object invoke(Remote obj,
75 java.lang.reflect.Method method,
76 Object[] params,
77 long opnum)
78 throws Exception;
79
80 /**
81 * Creates an appropriate call object for a new remote method
82 * invocation on this object. Passing operation array and index,
83 * allows the stubs generator to assign the operation indexes and
84 * interpret them. The remote reference may need the operation to
85 * encode in the call.
86 *
87 * @since JDK1.1
88 * @deprecated 1.2 style stubs no longer use this method. Instead of
89 * using a sequence of method calls on the stub's the remote reference
90 * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
91 * stub uses a single method, <code>invoke(Remote, Method, Object[],
92 * int)</code>, on the remote reference to carry out parameter
93 * marshalling, remote method executing and unmarshalling of the return
94 * value.
95 *
96 * @param obj remote stub through which to make call
97 * @param op array of stub operations
98 * @param opnum operation number
99 * @param hash stub/skeleton interface hash
100 * @return call object representing remote call
101 * @throws RemoteException if failed to initiate new remote call
102 * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
103 */
104 @Deprecated
105 RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash)
106 throws RemoteException;
107
108 /**
109 * Executes the remote call.
110 *
111 * Invoke will raise any "user" exceptions which
112 * should pass through and not be caught by the stub. If any
113 * exception is raised during the remote invocation, invoke should
114 * take care of cleaning up the connection before raising the
115 * "user" or remote exception.
116 *
117 * @since JDK1.1
118 * @deprecated 1.2 style stubs no longer use this method. Instead of
119 * using a sequence of method calls to the remote reference
120 * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
121 * stub uses a single method, <code>invoke(Remote, Method, Object[],
122 * int)</code>, on the remote reference to carry out parameter
123 * marshalling, remote method executing and unmarshalling of the return
124 * value.
125 *
126 * @param call object representing remote call
127 * @throws Exception if any exception occurs during remote method
128 * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
129 */
130 @Deprecated
131 void invoke(RemoteCall call) throws Exception;
132
133 /**
134 * Allows the remote reference to clean up (or reuse) the connection.
135 * Done should only be called if the invoke returns successfully
136 * (non-exceptionally) to the stub.
137 *
138 * @since JDK1.1
139 * @deprecated 1.2 style stubs no longer use this method. Instead of
140 * using a sequence of method calls to the remote reference
141 * (<code>newCall</code>, <code>invoke</code>, and <code>done</code>), a
142 * stub uses a single method, <code>invoke(Remote, Method, Object[],
143 * int)</code>, on the remote reference to carry out parameter
144 * marshalling, remote method executing and unmarshalling of the return
145 * value.
146 *
147 * @param call object representing remote call
148 * @throws RemoteException if remote error occurs during call cleanup
149 * @see #invoke(Remote,java.lang.reflect.Method,Object[],long)
150 */
151 @Deprecated
152 void done(RemoteCall call) throws RemoteException;
153
154 /**
155 * Returns the class name of the ref type to be serialized onto
156 * the stream 'out'.
157 * @param out the output stream to which the reference will be serialized
158 * @return the class name (without package qualification) of the reference
159 * type
160 * @since JDK1.1
161 */
162 String getRefClass(java.io.ObjectOutput out);
163
164 /**
165 * Returns a hashcode for a remote object. Two remote object stubs
166 * that refer to the same remote object will have the same hash code
167 * (in order to support remote objects as keys in hash tables).
168 *
169 * @return remote object hashcode
170 * @see java.util.Hashtable
171 * @since JDK1.1
172 */
173 int remoteHashCode();
174
175 /**
176 * Compares two remote objects for equality.
177 * Returns a boolean that indicates whether this remote object is
178 * equivalent to the specified Object. This method is used when a
179 * remote object is stored in a hashtable.
180 * @param obj the Object to compare with
181 * @return true if these Objects are equal; false otherwise.
182 * @see java.util.Hashtable
183 * @since JDK1.1
184 */
185 boolean remoteEquals(RemoteRef obj);
186
187 /**
188 * Returns a String that represents the reference of this remote
189 * object.
190 * @return string representing remote object reference
191 * @since JDK1.1
192 */
193 String remoteToString();
194
195}
java/pkg/java/rmi/server/RemoteServer.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteServer.java+115−0
@@ -0,0 +1,115 @@
1/*
2 * Copyright (c) 1996, 2002, 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.server;
26
27import java.rmi.*;
28import sun.rmi.server.UnicastServerRef;
29import sun.rmi.runtime.Log;
30
31/**
32 * The <code>RemoteServer</code> class is the common superclass to server
33 * implementations and provides the framework to support a wide range
34 * of remote reference semantics. Specifically, the functions needed
35 * to create and export remote objects (i.e. to make them remotely
36 * available) are provided abstractly by <code>RemoteServer</code> and
37 * concretely by its subclass(es).
38 *
39 * @author Ann Wollrath
40 * @since JDK1.1
41 */
42public abstract class RemoteServer extends RemoteObject
43{
44 /* indicate compatibility with JDK 1.1.x version of class */
45 private static final long serialVersionUID = -4100238210092549637L;
46
47 /**
48 * Constructs a <code>RemoteServer</code>.
49 * @since JDK1.1
50 */
51 protected RemoteServer() {
52 super();
53 }
54
55 /**
56 * Constructs a <code>RemoteServer</code> with the given reference type.
57 *
58 * @param ref the remote reference
59 * @since JDK1.1
60 */
61 protected RemoteServer(RemoteRef ref) {
62 super(ref);
63 }
64
65 /**
66 * Returns a string representation of the client host for the
67 * remote method invocation being processed in the current thread.
68 *
69 * @return a string representation of the client host
70 *
71 * @throws ServerNotActiveException if no remote method invocation
72 * is being processed in the current thread
73 *
74 * @since JDK1.1
75 */
76 public static String getClientHost() throws ServerNotActiveException {
77 return sun.rmi.transport.tcp.TCPTransport.getClientHost();
78 }
79
80 /**
81 * Log RMI calls to the output stream <code>out</code>. If
82 * <code>out</code> is <code>null</code>, call logging is turned off.
83 *
84 * <p>If there is a security manager, its
85 * <code>checkPermission</code> method will be invoked with a
86 * <code>java.util.logging.LoggingPermission("control")</code>
87 * permission; this could result in a <code>SecurityException</code>.
88 *
89 * @param out the output stream to which RMI calls should be logged
90 * @throws SecurityException if there is a security manager and
91 * the invocation of its <code>checkPermission</code> method
92 * fails
93 * @see #getLog
94 * @since JDK1.1
95 */
96 public static void setLog(java.io.OutputStream out)
97 {
98 logNull = (out == null);
99 UnicastServerRef.callLog.setOutputStream(out);
100 }
101
102 /**
103 * Returns stream for the RMI call log.
104 * @return the call log
105 * @see #setLog
106 * @since JDK1.1
107 */
108 public static java.io.PrintStream getLog()
109 {
110 return (logNull ? null : UnicastServerRef.callLog.getPrintStream());
111 }
112
113 // initialize log status
114 private static boolean logNull = !UnicastServerRef.logCalls;
115}
java/pkg/java/rmi/server/RemoteStub.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/RemoteStub.java+74−0
@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi.server;
26
27/**
28 * The <code>RemoteStub</code> class is the common superclass to client
29 * stubs and provides the framework to support a wide range of remote
30 * reference semantics. Stub objects are surrogates that support
31 * exactly the same set of remote interfaces defined by the actual
32 * implementation of the remote object.
33 *
34 * @author Ann Wollrath
35 * @since JDK1.1
36 */
37abstract public class RemoteStub extends RemoteObject {
38
39 /** indicate compatibility with JDK 1.1.x version of class */
40 private static final long serialVersionUID = -1585587260594494182L;
41
42 /**
43 * Constructs a <code>RemoteStub</code>.
44 */
45 protected RemoteStub() {
46 super();
47 }
48
49 /**
50 * Constructs a <code>RemoteStub</code>, with the specified remote
51 * reference.
52 *
53 * @param ref the remote reference
54 * @since JDK1.1
55 */
56 protected RemoteStub(RemoteRef ref) {
57 super(ref);
58 }
59
60 /**
61 * Sets the remote reference inside the remote stub.
62 *
63 * @param stub the remote stub
64 * @param ref the remote reference
65 * @since JDK1.1
66 * @deprecated no replacement. The <code>setRef</code> method
67 * is not needed since <code>RemoteStub</code>s can be created with
68 * the <code>RemoteStub(RemoteRef)</code> constructor.
69 */
70 @Deprecated
71 protected static void setRef(RemoteStub stub, RemoteRef ref) {
72 throw new UnsupportedOperationException();
73 }
74}
java/pkg/java/rmi/server/ServerCloneException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/ServerCloneException.java+112−0
@@ -0,0 +1,112 @@
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.server;
27
28/**
29 * A <code>ServerCloneException</code> is thrown if a remote exception occurs
30 * during the cloning of a <code>UnicastRemoteObject</code>.
31 *
32 * <p>As of release 1.4, this exception has been retrofitted to conform to
33 * the general purpose exception-chaining mechanism. The "nested exception"
34 * that may be provided at construction time and accessed via the public
35 * {@link #detail} field is now known as the <i>cause</i>, and may be
36 * accessed via the {@link Throwable#getCause()} method, as well as
37 * the aforementioned "legacy field."
38 *
39 * <p>Invoking the method {@link Throwable#initCause(Throwable)} on an
40 * instance of <code>ServerCloneException</code> always throws {@link
41 * IllegalStateException}.
42 *
43 * @author Ann Wollrath
44 * @since JDK1.1
45 * @see java.rmi.server.UnicastRemoteObject#clone()
46 */
47public class ServerCloneException extends CloneNotSupportedException {
48
49 /**
50 * The cause of the exception.
51 *
52 * <p>This field predates the general-purpose exception chaining facility.
53 * The {@link Throwable#getCause()} method is now the preferred means of
54 * obtaining this information.
55 *
56 * @serial
57 */
58 public Exception detail;
59
60 /* indicate compatibility with JDK 1.1.x version of class */
61 private static final long serialVersionUID = 6617456357664815945L;
62
63 /**
64 * Constructs a <code>ServerCloneException</code> with the specified
65 * detail message.
66 *
67 * @param s the detail message.
68 */
69 public ServerCloneException(String s) {
70 super(s);
71 initCause(null); // Disallow subsequent initCause
72 }
73
74 /**
75 * Constructs a <code>ServerCloneException</code> with the specified
76 * detail message and cause.
77 *
78 * @param s the detail message.
79 * @param cause the cause
80 */
81 public ServerCloneException(String s, Exception cause) {
82 super(s);
83 initCause(null); // Disallow subsequent initCause
84 detail = cause;
85 }
86
87 /**
88 * Returns the detail message, including the message from the cause, if
89 * any, of this exception.
90 *
91 * @return the detail message
92 */
93 public String getMessage() {
94 if (detail == null)
95 return super.getMessage();
96 else
97 return super.getMessage() +
98 "; nested exception is: \n\t" +
99 detail.toString();
100 }
101
102 /**
103 * Returns the cause of this exception. This method returns the value
104 * of the {@link #detail} field.
105 *
106 * @return the cause, which may be <tt>null</tt>.
107 * @since 1.4
108 */
109 public Throwable getCause() {
110 return detail;
111 }
112}
java/pkg/java/rmi/server/ServerNotActiveException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/ServerNotActiveException.java+61−0
@@ -0,0 +1,61 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi.server;
27
28/**
29 * An <code>ServerNotActiveException</code> is an <code>Exception</code>
30 * thrown during a call to <code>RemoteServer.getClientHost</code> if
31 * the getClientHost method is called outside of servicing a remote
32 * method call.
33 *
34 * @author Roger Riggs
35 * @since JDK1.1
36 * @see java.rmi.server.RemoteServer#getClientHost()
37 */
38public class ServerNotActiveException extends java.lang.Exception {
39
40 /* indicate compatibility with JDK 1.1.x version of class */
41 private static final long serialVersionUID = 4687940720827538231L;
42
43 /**
44 * Constructs an <code>ServerNotActiveException</code> with no specified
45 * detail message.
46 * @since JDK1.1
47 */
48 public ServerNotActiveException() {}
49
50 /**
51 * Constructs an <code>ServerNotActiveException</code> with the specified
52 * detail message.
53 *
54 * @param s the detail message.
55 * @since JDK1.1
56 */
57 public ServerNotActiveException(String s)
58 {
59 super(s);
60 }
61}
java/pkg/java/rmi/server/ServerRef.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/ServerRef.java+66−0
@@ -0,0 +1,66 @@
1/*
2 * Copyright (c) 1996, 1999, 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.server;
27
28import java.rmi.*;
29
30/**
31 * A ServerRef represents the server-side handle for a remote object
32 * implementation.
33 *
34 * @author Ann Wollrath
35 * @since JDK1.1
36 */
37public interface ServerRef extends RemoteRef {
38
39 /** indicate compatibility with JDK 1.1.x version of class. */
40 static final long serialVersionUID = -4557750989390278438L;
41
42 /**
43 * Creates a client stub object for the supplied Remote object.
44 * If the call completes successfully, the remote object should
45 * be able to accept incoming calls from clients.
46 * @param obj the remote object implementation
47 * @param data information necessary to export the object
48 * @return the stub for the remote object
49 * @exception RemoteException if an exception occurs attempting
50 * to export the object (e.g., stub class could not be found)
51 * @since JDK1.1
52 */
53 RemoteStub exportObject(Remote obj, Object data)
54 throws RemoteException;
55
56 /**
57 * Returns the hostname of the current client. When called from a
58 * thread actively handling a remote method invocation the
59 * hostname of the client is returned.
60 * @return the client's host name
61 * @exception ServerNotActiveException if called outside of servicing
62 * a remote method invocation
63 * @since JDK1.1
64 */
65 String getClientHost() throws ServerNotActiveException;
66}
java/pkg/java/rmi/server/Skeleton.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/Skeleton.java+70−0
@@ -0,0 +1,70 @@
1/*
2 * Copyright (c) 1996, 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 */
25package java.rmi.server;
26
27import java.rmi.Remote;
28
29/**
30 * The <code>Skeleton</code> interface is used solely by the RMI
31 * implementation.
32 *
33 * <p> Every version 1.1 (and version 1.1 compatible skeletons generated in
34 * 1.2 using <code>rmic -vcompat</code>) skeleton class generated by the rmic
35 * stub compiler implements this interface. A skeleton for a remote object is
36 * a server-side entity that dispatches calls to the actual remote object
37 * implementation.
38 *
39 * @author Ann Wollrath
40 * @since JDK1.1
41 * @deprecated no replacement. Skeletons are no longer required for remote
42 * method calls in the Java 2 platform v1.2 and greater.
43 */
44@Deprecated
45public interface Skeleton {
46 /**
47 * Unmarshals arguments, calls the actual remote object implementation,
48 * and marshals the return value or any exception.
49 *
50 * @param obj remote implementation to dispatch call to
51 * @param theCall object representing remote call
52 * @param opnum operation number
53 * @param hash stub/skeleton interface hash
54 * @exception java.lang.Exception if a general exception occurs.
55 * @since JDK1.1
56 * @deprecated no replacement
57 */
58 @Deprecated
59 void dispatch(Remote obj, RemoteCall theCall, int opnum, long hash)
60 throws Exception;
61
62 /**
63 * Returns the operations supported by the skeleton.
64 * @return operations supported by skeleton
65 * @since JDK1.1
66 * @deprecated no replacement
67 */
68 @Deprecated
69 Operation[] getOperations();
70}
java/pkg/java/rmi/server/SkeletonMismatchException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/SkeletonMismatchException.java+62−0
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1996, 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.server;
27
28import java.rmi.RemoteException;
29
30/**
31 * This exception is thrown when a call is received that does not
32 * match the available skeleton. It indicates either that the
33 * remote method names or signatures in this interface have changed or
34 * that the stub class used to make the call and the skeleton
35 * receiving the call were not generated by the same version of
36 * the stub compiler (<code>rmic</code>).
37 *
38 * @author Roger Riggs
39 * @since JDK1.1
40 * @deprecated no replacement. Skeletons are no longer required for remote
41 * method calls in the Java 2 platform v1.2 and greater.
42 */
43@Deprecated
44public class SkeletonMismatchException extends RemoteException {
45
46 /* indicate compatibility with JDK 1.1.x version of class */
47 private static final long serialVersionUID = -7780460454818859281L;
48
49 /**
50 * Constructs a new <code>SkeletonMismatchException</code> with
51 * a specified detail message.
52 *
53 * @param s the detail message
54 * @since JDK1.1
55 * @deprecated no replacement
56 */
57 @Deprecated
58 public SkeletonMismatchException(String s) {
59 super(s);
60 }
61
62}
java/pkg/java/rmi/server/SkeletonNotFoundException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/SkeletonNotFoundException.java+68−0
@@ -0,0 +1,68 @@
1/*
2 * Copyright (c) 1996, 2006, 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.server;
27
28import java.rmi.RemoteException;
29
30/**
31 * A <code>SkeletonNotFoundException</code> is thrown if the
32 * <code>Skeleton</code> corresponding to the remote object being
33 * exported is not found. Skeletons are no longer required, so this
34 * exception is never thrown.
35 *
36 * @since JDK1.1
37 * @deprecated no replacement. Skeletons are no longer required for remote
38 * method calls in the Java 2 platform v1.2 and greater.
39 */
40@Deprecated
41public class SkeletonNotFoundException extends RemoteException {
42
43 /* indicate compatibility with JDK 1.1.x version of class */
44 private static final long serialVersionUID = -7860299673822761231L;
45
46 /**
47 * Constructs a <code>SkeletonNotFoundException</code> with the specified
48 * detail message.
49 *
50 * @param s the detail message.
51 * @since JDK1.1
52 */
53 public SkeletonNotFoundException(String s) {
54 super(s);
55 }
56
57 /**
58 * Constructs a <code>SkeletonNotFoundException</code> with the specified
59 * detail message and nested exception.
60 *
61 * @param s the detail message.
62 * @param ex the nested exception
63 * @since JDK1.1
64 */
65 public SkeletonNotFoundException(String s, Exception ex) {
66 super(s, ex);
67 }
68}
java/pkg/java/rmi/server/SocketSecurityException.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/SocketSecurityException.java+62−0
@@ -0,0 +1,62 @@
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.server;
27
28/**
29 * An obsolete subclass of {@link ExportException}.
30 *
31 * @author Ann Wollrath
32 * @since JDK1.1
33 **/
34public class SocketSecurityException extends ExportException {
35
36 /* indicate compatibility with JDK 1.1.x version of class */
37 private static final long serialVersionUID = -7622072999407781979L;
38
39 /**
40 * Constructs an <code>SocketSecurityException</code> with the specified
41 * detail message.
42 *
43 * @param s the detail message.
44 * @since JDK1.1
45 */
46 public SocketSecurityException(String s) {
47 super(s);
48 }
49
50 /**
51 * Constructs an <code>SocketSecurityException</code> with the specified
52 * detail message and nested exception.
53 *
54 * @param s the detail message.
55 * @param ex the nested exception
56 * @since JDK1.1
57 */
58 public SocketSecurityException(String s, Exception ex) {
59 super(s, ex);
60 }
61
62}
java/pkg/java/rmi/server/UID.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/UID.java+267−0
@@ -0,0 +1,267 @@
1/*
2 * Copyright (c) 1996, 2006, 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.server;
26
27import java.io.DataInput;
28import java.io.DataOutput;
29import java.io.IOException;
30import java.io.Serializable;
31import java.security.SecureRandom;
32
33/**
34 * A <code>UID</code> represents an identifier that is unique over time
35 * with respect to the host it is generated on, or one of 2<sup>16</sup>
36 * "well-known" identifiers.
37 *
38 * <p>The {@link #UID()} constructor can be used to generate an
39 * identifier that is unique over time with respect to the host it is
40 * generated on. The {@link #UID(short)} constructor can be used to
41 * create one of 2<sup>16</sup> well-known identifiers.
42 *
43 * <p>A <code>UID</code> instance contains three primitive values:
44 * <ul>
45 * <li><code>unique</code>, an <code>int</code> that uniquely identifies
46 * the VM that this <code>UID</code> was generated in, with respect to its
47 * host and at the time represented by the <code>time</code> value (an
48 * example implementation of the <code>unique</code> value would be a
49 * process identifier),
50 * or zero for a well-known <code>UID</code>
51 * <li><code>time</code>, a <code>long</code> equal to a time (as returned
52 * by {@link System#currentTimeMillis()}) at which the VM that this
53 * <code>UID</code> was generated in was alive,
54 * or zero for a well-known <code>UID</code>
55 * <li><code>count</code>, a <code>short</code> to distinguish
56 * <code>UID</code>s generated in the same VM with the same
57 * <code>time</code> value
58 * </ul>
59 *
60 * <p>An independently generated <code>UID</code> instance is unique
61 * over time with respect to the host it is generated on as long as
62 * the host requires more than one millisecond to reboot and its system
63 * clock is never set backward. A globally unique identifier can be
64 * constructed by pairing a <code>UID</code> instance with a unique host
65 * identifier, such as an IP address.
66 *
67 * @author Ann Wollrath
68 * @author Peter Jones
69 * @since JDK1.1
70 */
71public final class UID implements Serializable {
72
73 private static int hostUnique;
74 private static boolean hostUniqueSet = false;
75
76 private static final Object lock = new Object();
77 private static long lastTime = System.currentTimeMillis();
78 private static short lastCount = Short.MIN_VALUE;
79
80 /** indicate compatibility with JDK 1.1.x version of class */
81 private static final long serialVersionUID = 1086053664494604050L;
82
83 /**
84 * number that uniquely identifies the VM that this <code>UID</code>
85 * was generated in with respect to its host and at the given time
86 * @serial
87 */
88 private final int unique;
89
90 /**
91 * a time (as returned by {@link System#currentTimeMillis()}) at which
92 * the VM that this <code>UID</code> was generated in was alive
93 * @serial
94 */
95 private final long time;
96
97 /**
98 * 16-bit number to distinguish <code>UID</code> instances created
99 * in the same VM with the same time value
100 * @serial
101 */
102 private final short count;
103
104 /**
105 * Generates a <code>UID</code> that is unique over time with
106 * respect to the host that it was generated on.
107 */
108 public UID() {
109
110 synchronized (lock) {
111 if (!hostUniqueSet) {
112 hostUnique = (new SecureRandom()).nextInt();
113 hostUniqueSet = true;
114 }
115 unique = hostUnique;
116 if (lastCount == Short.MAX_VALUE) {
117 boolean interrupted = Thread.interrupted();
118 boolean done = false;
119 while (!done) {
120 long now = System.currentTimeMillis();
121 if (now <= lastTime) {
122 // wait for time to change
123 try {
124 Thread.currentThread().sleep(1);
125 } catch (InterruptedException e) {
126 interrupted = true;
127 }
128 } else {
129 lastTime = now;
130 lastCount = Short.MIN_VALUE;
131 done = true;
132 }
133 }
134 if (interrupted) {
135 Thread.currentThread().interrupt();
136 }
137 }
138 time = lastTime;
139 count = lastCount++;
140 }
141 }
142
143 /**
144 * Creates a "well-known" <code>UID</code>.
145 *
146 * There are 2<sup>16</sup> possible such well-known ids.
147 *
148 * <p>A <code>UID</code> created via this constructor will not
149 * clash with any <code>UID</code>s generated via the no-arg
150 * constructor.
151 *
152 * @param num number for well-known <code>UID</code>
153 */
154 public UID(short num) {
155 unique = 0;
156 time = 0;
157 count = num;
158 }
159
160 /**
161 * Constructs a <code>UID</code> given data read from a stream.
162 */
163 private UID(int unique, long time, short count) {
164 this.unique = unique;
165 this.time = time;
166 this.count = count;
167 }
168
169 /**
170 * Returns the hash code value for this <code>UID</code>.
171 *
172 * @return the hash code value for this <code>UID</code>
173 */
174 public int hashCode() {
175 return (int) time + (int) count;
176 }
177
178 /**
179 * Compares the specified object with this <code>UID</code> for
180 * equality.
181 *
182 * This method returns <code>true</code> if and only if the
183 * specified object is a <code>UID</code> instance with the same
184 * <code>unique</code>, <code>time</code>, and <code>count</code>
185 * values as this one.
186 *
187 * @param obj the object to compare this <code>UID</code> to
188 *
189 * @return <code>true</code> if the given object is equivalent to
190 * this one, and <code>false</code> otherwise
191 */
192 public boolean equals(Object obj) {
193 if (obj instanceof UID) {
194 UID uid = (UID) obj;
195 return (unique == uid.unique &&
196 count == uid.count &&
197 time == uid.time);
198 } else {
199 return false;
200 }
201 }
202
203 /**
204 * Returns a string representation of this <code>UID</code>.
205 *
206 * @return a string representation of this <code>UID</code>
207 */
208 public String toString() {
209 return Integer.toString(unique,16) + ":" +
210 Long.toString(time,16) + ":" +
211 Integer.toString(count,16);
212 }
213
214 /**
215 * Marshals a binary representation of this <code>UID</code> to
216 * a <code>DataOutput</code> instance.
217 *
218 * <p>Specifically, this method first invokes the given stream's
219 * {@link DataOutput#writeInt(int)} method with this <code>UID</code>'s
220 * <code>unique</code> value, then it invokes the stream's
221 * {@link DataOutput#writeLong(long)} method with this <code>UID</code>'s
222 * <code>time</code> value, and then it invokes the stream's
223 * {@link DataOutput#writeShort(int)} method with this <code>UID</code>'s
224 * <code>count</code> value.
225 *
226 * @param out the <code>DataOutput</code> instance to write
227 * this <code>UID</code> to
228 *
229 * @throws IOException if an I/O error occurs while performing
230 * this operation
231 */
232 public void write(DataOutput out) throws IOException {
233 out.writeInt(unique);
234 out.writeLong(time);
235 out.writeShort(count);
236 }
237
238 /**
239 * Constructs and returns a new <code>UID</code> instance by
240 * unmarshalling a binary representation from an
241 * <code>DataInput</code> instance.
242 *
243 * <p>Specifically, this method first invokes the given stream's
244 * {@link DataInput#readInt()} method to read a <code>unique</code> value,
245 * then it invoke's the stream's
246 * {@link DataInput#readLong()} method to read a <code>time</code> value,
247 * then it invoke's the stream's
248 * {@link DataInput#readShort()} method to read a <code>count</code> value,
249 * and then it creates and returns a new <code>UID</code> instance
250 * that contains the <code>unique</code>, <code>time</code>, and
251 * <code>count</code> values that were read from the stream.
252 *
253 * @param in the <code>DataInput</code> instance to read
254 * <code>UID</code> from
255 *
256 * @return unmarshalled <code>UID</code> instance
257 *
258 * @throws IOException if an I/O error occurs while performing
259 * this operation
260 */
261 public static UID read(DataInput in) throws IOException {
262 int unique = in.readInt();
263 long time = in.readLong();
264 short count = in.readShort();
265 return new UID(unique, time, count);
266 }
267}
java/pkg/java/rmi/server/UnicastRemoteObject.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/UnicastRemoteObject.java+312−0
@@ -0,0 +1,312 @@
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 */
25package java.rmi.server;
26
27import java.rmi.*;
28import sun.rmi.server.UnicastServerRef;
29import sun.rmi.server.UnicastServerRef2;
30
31/**
32 * Used for exporting a remote object with JRMP and obtaining a stub
33 * that communicates to the remote object.
34 *
35 * <p>For the constructors and static <code>exportObject</code> methods
36 * below, the stub for a remote object being exported is obtained as
37 * follows:
38 *
39 * <p><ul>
40 *
41 * <li>If the remote object is exported using the {@link
42 * #exportObject(Remote) UnicastRemoteObject.exportObject(Remote)} method,
43 * a stub class (typically pregenerated from the remote object's class
44 * using the <code>rmic</code> tool) is loaded and an instance of that stub
45 * class is constructed as follows.
46 * <ul>
47 *
48 * <li>A "root class" is determined as follows: if the remote object's
49 * class directly implements an interface that extends {@link Remote}, then
50 * the remote object's class is the root class; otherwise, the root class is
51 * the most derived superclass of the remote object's class that directly
52 * implements an interface that extends <code>Remote</code>.
53 *
54 * <li>The name of the stub class to load is determined by concatenating
55 * the binary name of the root class with the suffix <code>"_Stub"</code>.
56 *
57 * <li>The stub class is loaded by name using the class loader of the root
58 * class. The stub class must extend {@link RemoteStub} and must have a
59 * public constructor that has one parameter, of type {@link RemoteRef}.
60 *
61 * <li>Finally, an instance of the stub class is constructed with a
62 * {@link RemoteRef}.
63 * </ul>
64 *
65 * <li>If the appropriate stub class could not be found, or the stub class
66 * could not be loaded, or a problem occurs creating the stub instance, a
67 * {@link StubNotFoundException} is thrown.
68 *
69 * <p>
70 * <li>For all other means of exporting:
71 * <p><ul>
72 *
73 * <li>If the remote object's stub class (as defined above) could not be
74 * loaded or the system property
75 * <code>java.rmi.server.ignoreStubClasses</code> is set to
76 * <code>"true"</code> (case insensitive), a {@link
77 * java.lang.reflect.Proxy} instance is constructed with the following
78 * properties:
79 *
80 * <ul>
81 *
82 * <li>The proxy's class is defined by the class loader of the remote
83 * object's class.
84 *
85 * <li>The proxy implements all the remote interfaces implemented by the
86 * remote object's class.
87 *
88 * <li>The proxy's invocation handler is a {@link
89 * RemoteObjectInvocationHandler} instance constructed with a
90 * {@link RemoteRef}.
91 *
92 * <li>If the proxy could not be created, a {@link StubNotFoundException}
93 * will be thrown.
94 * </ul>
95 *
96 * <p>
97 * <li>Otherwise, an instance of the remote object's stub class (as
98 * described above) is used as the stub.
99 *
100 * </ul>
101 * </ul>
102 *
103 * @author Ann Wollrath
104 * @author Peter Jones
105 * @since JDK1.1
106 **/
107public class UnicastRemoteObject extends RemoteServer {
108
109 /**
110 * @serial port number on which to export object
111 */
112 private int port = 0;
113
114 /**
115 * @serial client-side socket factory (if any)
116 */
117 private RMIClientSocketFactory csf = null;
118
119 /**
120 * @serial server-side socket factory (if any) to use when
121 * exporting object
122 */
123 private RMIServerSocketFactory ssf = null;
124
125 /* indicate compatibility with JDK 1.1.x version of class */
126 private static final long serialVersionUID = 4974527148936298033L;
127
128 /**
129 * Creates and exports a new UnicastRemoteObject object using an
130 * anonymous port.
131 * @throws RemoteException if failed to export object
132 * @since JDK1.1
133 */
134 protected UnicastRemoteObject() throws RemoteException
135 {
136 this(0);
137 }
138
139 /**
140 * Creates and exports a new UnicastRemoteObject object using the
141 * particular supplied port.
142 * @param port the port number on which the remote object receives calls
143 * (if <code>port</code> is zero, an anonymous port is chosen)
144 * @throws RemoteException if failed to export object
145 * @since 1.2
146 */
147 protected UnicastRemoteObject(int port) throws RemoteException
148 {
149 this.port = port;
150 exportObject((Remote) this, port);
151 }
152
153 /**
154 * Creates and exports a new UnicastRemoteObject object using the
155 * particular supplied port and socket factories.
156 * @param port the port number on which the remote object receives calls
157 * (if <code>port</code> is zero, an anonymous port is chosen)
158 * @param csf the client-side socket factory for making calls to the
159 * remote object
160 * @param ssf the server-side socket factory for receiving remote calls
161 * @throws RemoteException if failed to export object
162 * @since 1.2
163 */
164 protected UnicastRemoteObject(int port,
165 RMIClientSocketFactory csf,
166 RMIServerSocketFactory ssf)
167 throws RemoteException
168 {
169 this.port = port;
170 this.csf = csf;
171 this.ssf = ssf;
172 exportObject((Remote) this, port, csf, ssf);
173 }
174
175 /**
176 * Re-export the remote object when it is deserialized.
177 */
178 private void readObject(java.io.ObjectInputStream in)
179 throws java.io.IOException, java.lang.ClassNotFoundException
180 {
181 in.defaultReadObject();
182 reexport();
183 }
184
185 /**
186 * Returns a clone of the remote object that is distinct from
187 * the original.
188 *
189 * @exception CloneNotSupportedException if clone failed due to
190 * a RemoteException.
191 * @return the new remote object
192 * @since JDK1.1
193 */
194 public Object clone() throws CloneNotSupportedException
195 {
196 try {
197 UnicastRemoteObject cloned = (UnicastRemoteObject) super.clone();
198 cloned.reexport();
199 return cloned;
200 } catch (RemoteException e) {
201 throw new ServerCloneException("Clone failed", e);
202 }
203 }
204
205 /*
206 * Exports this UnicastRemoteObject using its initialized fields because
207 * its creation bypassed running its constructors (via deserialization
208 * or cloning, for example).
209 */
210 private void reexport() throws RemoteException
211 {
212 if (csf == null && ssf == null) {
213 exportObject((Remote) this, port);
214 } else {
215 exportObject((Remote) this, port, csf, ssf);
216 }
217 }
218
219 /**
220 * Exports the remote object to make it available to receive incoming
221 * calls using an anonymous port.
222 * @param obj the remote object to be exported
223 * @return remote object stub
224 * @exception RemoteException if export fails
225 * @since JDK1.1
226 */
227 public static RemoteStub exportObject(Remote obj)
228 throws RemoteException
229 {
230 /*
231 * Use UnicastServerRef constructor passing the boolean value true
232 * to indicate that only a generated stub class should be used. A
233 * generated stub class must be used instead of a dynamic proxy
234 * because the return value of this method is RemoteStub which a
235 * dynamic proxy class cannot extend.
236 */
237 return (RemoteStub) exportObject(obj, new UnicastServerRef(true));
238 }
239
240 /**
241 * Exports the remote object to make it available to receive incoming
242 * calls, using the particular supplied port.
243 * @param obj the remote object to be exported
244 * @param port the port to export the object on
245 * @return remote object stub
246 * @exception RemoteException if export fails
247 * @since 1.2
248 */
249 public static Remote exportObject(Remote obj, int port)
250 throws RemoteException
251 {
252 return exportObject(obj, new UnicastServerRef(port));
253 }
254
255 /**
256 * Exports the remote object to make it available to receive incoming
257 * calls, using a transport specified by the given socket factory.
258 * @param obj the remote object to be exported
259 * @param port the port to export the object on
260 * @param csf the client-side socket factory for making calls to the
261 * remote object
262 * @param ssf the server-side socket factory for receiving remote calls
263 * @return remote object stub
264 * @exception RemoteException if export fails
265 * @since 1.2
266 */
267 public static Remote exportObject(Remote obj, int port,
268 RMIClientSocketFactory csf,
269 RMIServerSocketFactory ssf)
270 throws RemoteException
271 {
272
273 return exportObject(obj, new UnicastServerRef2(port, csf, ssf));
274 }
275
276 /**
277 * Removes the remote object, obj, from the RMI runtime. If
278 * successful, the object can no longer accept incoming RMI calls.
279 * If the force parameter is true, the object is forcibly unexported
280 * even if there are pending calls to the remote object or the
281 * remote object still has calls in progress. If the force
282 * parameter is false, the object is only unexported if there are
283 * no pending or in progress calls to the object.
284 *
285 * @param obj the remote object to be unexported
286 * @param force if true, unexports the object even if there are
287 * pending or in-progress calls; if false, only unexports the object
288 * if there are no pending or in-progress calls
289 * @return true if operation is successful, false otherwise
290 * @exception NoSuchObjectException if the remote object is not
291 * currently exported
292 * @since 1.2
293 */
294 public static boolean unexportObject(Remote obj, boolean force)
295 throws java.rmi.NoSuchObjectException
296 {
297 return sun.rmi.transport.ObjectTable.unexportObject(obj, force);
298 }
299
300 /**
301 * Exports the specified object using the specified server ref.
302 */
303 private static Remote exportObject(Remote obj, UnicastServerRef sref)
304 throws RemoteException
305 {
306 // if obj extends UnicastRemoteObject, set its ref.
307 if (obj instanceof UnicastRemoteObject) {
308 ((UnicastRemoteObject) obj).ref = sref;
309 }
310 return sref.exportObject(obj, null, false);
311 }
312}
java/pkg/java/rmi/server/Unreferenced.class+0−0

Binary file not shown.

java/pkg/java/rmi/server/Unreferenced.java+45−0
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 1996, 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
26package java.rmi.server;
27
28/**
29 * A remote object implementation should implement the
30 * <code>Unreferenced</code> interface to receive notification when there are
31 * no more clients that reference that remote object.
32 *
33 * @author Ann Wollrath
34 * @author Roger Riggs
35 * @since JDK1.1
36 */
37public interface Unreferenced {
38 /**
39 * Called by the RMI runtime sometime after the runtime determines that
40 * the reference list, the list of clients referencing the remote object,
41 * becomes empty.
42 * @since JDK1.1
43 */
44 public void unreferenced();
45}
java/pkg/java/rmi/server/mkfile+34−0
@@ -0,0 +1,34 @@
1<../../../../../mkconfig
2
3TARG=\
4 ExportException.dis\
5 LoaderHandler.dis\
6 LogStream.dis\
7 ObjID.dis\
8 Operation.dis\
9 RemoteCall.dis\
10 RemoteObject.dis\
11 RemoteObjectInvocationHandler.dis\
12 RemoteRef.dis\
13 RemoteServer.dis\
14 RemoteStub.dis\
15 RMIClassLoader.dis\
16 RMIClassLoaderSpi.dis\
17 RMIClientSocketFactory.dis\
18 RMIFailureHandler.dis\
19 RMIServerSocketFactory.dis\
20 RMISocketFactory.dis\
21 ServerCloneException.dis\
22 ServerNotActiveException.dis\
23 ServerRef.dis\
24 Skeleton.dis\
25 SkeletonMismatchException.dis\
26 SkeletonNotFoundException.dis\
27 SocketSecurityException.dis\
28 UID.dis\
29 UnicastRemoteObject.dis\
30 Unreferenced.dis\
31
32DISBIN=$ROOT/java/dis/java/java/java/rmi/server
33
34<$ROOT/mkfiles/mkjava
java/pkg/java/rmi/server/package.html+53−0
@@ -0,0 +1,53 @@
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<body bgcolor="white">
29
30Provides classes and interfaces for supporting the server
31side of RMI. A group of classes are used by the stubs and skeletons
32generated by the rmic stub compiler. Another group of classes
33implements the RMI Transport protocol and HTTP tunneling.
34
35<!--
36<h2>Package Specification</h2>
37
38##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
39<ul>
40 <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
41</ul>
42
43<h2>Related Documentation</h2>
44
45For overviews, tutorials, examples, guides, and tool documentation, please see:
46<ul>
47 <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
48</ul>
49-->
50
51@since JDK1.1
52</body>
53</html>