Showing the changes to java/pkg/java/rmi/activation (31 of 18352 files). Show all
Unified · Split
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.rmi.MarshalledObject; | |
| 29 | +import java.rmi.NoSuchObjectException; | |
| 30 | +import java.rmi.Remote; | |
| 31 | +import java.rmi.RemoteException; | |
| 32 | +import java.rmi.activation.UnknownGroupException; | |
| 33 | +import java.rmi.activation.UnknownObjectException; | |
| 34 | +import java.rmi.server.RMIClientSocketFactory; | |
| 35 | +import java.rmi.server.RMIServerSocketFactory; | |
| 36 | +import java.rmi.server.RemoteServer; | |
| 37 | +import 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 | + */ | |
| 55 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package 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 | + */ | |
| 35 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.io.Serializable; | |
| 29 | +import 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 | + */ | |
| 52 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package 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 | + */ | |
| 45 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.lang.reflect.Constructor; | |
| 29 | +import java.lang.reflect.InvocationTargetException; | |
| 30 | +import java.rmi.MarshalledObject; | |
| 31 | +import java.rmi.Naming; | |
| 32 | +import java.rmi.Remote; | |
| 33 | +import java.rmi.RemoteException; | |
| 34 | +import java.rmi.activation.UnknownGroupException; | |
| 35 | +import java.rmi.activation.UnknownObjectException; | |
| 36 | +import java.rmi.server.RMIClassLoader; | |
| 37 | +import java.rmi.server.UnicastRemoteObject; | |
| 38 | +import java.security.AccessController; | |
| 39 | +import 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 | + */ | |
| 98 | +public 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 | +} | |
Binary file not shown.
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.io.IOException; | |
| 29 | +import java.io.ObjectInputStream; | |
| 30 | +import java.io.Serializable; | |
| 31 | +import java.rmi.MarshalledObject; | |
| 32 | +import java.util.Arrays; | |
| 33 | +import 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 | + */ | |
| 59 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import 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 | + */ | |
| 48 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.io.IOException; | |
| 29 | +import java.io.InvalidObjectException; | |
| 30 | +import java.io.ObjectInputStream; | |
| 31 | +import java.io.ObjectOutputStream; | |
| 32 | +import java.io.Serializable; | |
| 33 | +import java.lang.reflect.InvocationHandler; | |
| 34 | +import java.lang.reflect.Proxy; | |
| 35 | +import java.rmi.MarshalledObject; | |
| 36 | +import java.rmi.Remote; | |
| 37 | +import java.rmi.RemoteException; | |
| 38 | +import java.rmi.UnmarshalException; | |
| 39 | +import java.rmi.server.RemoteObject; | |
| 40 | +import java.rmi.server.RemoteObjectInvocationHandler; | |
| 41 | +import java.rmi.server.RemoteRef; | |
| 42 | +import 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 | + */ | |
| 70 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.rmi.MarshalledObject; | |
| 29 | +import java.rmi.Remote; | |
| 30 | +import 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 | + */ | |
| 42 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.rmi.MarshalledObject; | |
| 29 | +import java.rmi.Remote; | |
| 30 | +import java.rmi.RemoteException; | |
| 31 | +import java.rmi.activation.UnknownGroupException; | |
| 32 | +import 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 | + */ | |
| 49 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.rmi.Remote; | |
| 29 | +import java.rmi.RemoteException; | |
| 30 | +import java.rmi.activation.UnknownGroupException; | |
| 31 | +import 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 | + */ | |
| 47 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package java.rmi.activation; | |
| 27 | + | |
| 28 | +import java.rmi.MarshalledObject; | |
| 29 | +import java.rmi.Remote; | |
| 30 | +import java.rmi.RemoteException; | |
| 31 | +import 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 | + */ | |
| 64 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package 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 | + */ | |
| 45 | +public 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 | +} | |
Binary file not shown.
| @@ -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 | + | |
| 26 | +package 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 | + */ | |
| 47 | +public 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 | +} | |
| @@ -0,0 +1,21 @@ | ||
| 1 | +<../../../../../mkconfig | |
| 2 | + | |
| 3 | +TARG=\ | |
| 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 | + | |
| 19 | +DISBIN=$ROOT/java/dis/java/java/java/rmi/activation | |
| 20 | + | |
| 21 | +<$ROOT/mkfiles/mkjava | |
| @@ -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 | + | |
| 30 | +Provides support for RMI Object Activation. A remote | |
| 31 | +object'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 | + | |
| 44 | +For 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> | |