src/share/classes/sun/rmi/server/ActivationGroupImpl.java

Print this page




 295             entry = new ActiveEntry(impl);
 296             active.put(id, entry);
 297             return entry.mobj;
 298 
 299         } catch (NoSuchMethodException | NoSuchMethodError e) {
 300             /* user forgot to provide activatable constructor?
 301              * or code recompiled and user forgot to provide
 302              *  activatable constructor?
 303              */
 304             throw new ActivationException
 305                 ("Activatable object must provide an activation"+
 306                  " constructor", e );
 307 
 308         } catch (InvocationTargetException e) {
 309             throw new ActivationException("exception in object constructor",
 310                                           e.getTargetException());
 311 
 312         } catch (Exception e) {
 313             throw new ActivationException("unable to activate object", e);
 314         } finally {
 315             releaseLock(id);
 316             checkInactiveGroup();

 317         }
 318     }
 319 
 320 
 321    /**
 322     * The group's <code>inactiveObject</code> method is called
 323     * indirectly via a call to the <code>Activatable.inactive</code>
 324     * method. A remote object implementation must call
 325     * <code>Activatable</code>'s <code>inactive</code> method when
 326     * that object deactivates (the object deems that it is no longer
 327     * active). If the object does not call
 328     * <code>Activatable.inactive</code> when it deactivates, the
 329     * object will never be garbage collected since the group keeps
 330     * strong references to the objects it creates. <p>
 331     *
 332     * The group's <code>inactiveObject</code> method
 333     * unexports the remote object from the RMI runtime so that the
 334     * object can no longer receive incoming RMI calls. This call will
 335     * only succeed if the object has no pending/executing calls. If
 336     * the object does have pending/executing RMI calls, then false


 368             ActiveEntry entry = active.get(id);
 369             if (entry == null) {
 370                 // REMIND: should this be silent?
 371                 throw new UnknownObjectException("object not active");
 372             }
 373 
 374             try {
 375                 if (Activatable.unexportObject(entry.impl, false) == false)
 376                     return false;
 377             } catch (NoSuchObjectException allowUnexportedObjects) {
 378             }
 379 
 380             try {
 381                 super.inactiveObject(id);
 382             } catch (UnknownObjectException allowUnregisteredObjects) {
 383             }
 384 
 385             active.remove(id);
 386 
 387         } finally {
 388             releaseLock(id);
 389             checkInactiveGroup();

 390         }
 391 
 392         return true;
 393     }
 394 
 395     /*
 396      * Determines if the group has become inactive and
 397      * marks it as such.
 398      */
 399     private void checkInactiveGroup() {
 400         boolean groupMarkedInactive = false;
 401         synchronized (this) {
 402             if (active.size() == 0 && lockedIDs.size() == 0 &&
 403                 groupInactive == false)
 404             {
 405                 groupInactive = true;
 406                 groupMarkedInactive = true;
 407             }
 408         }
 409 




 295             entry = new ActiveEntry(impl);
 296             active.put(id, entry);
 297             return entry.mobj;
 298 
 299         } catch (NoSuchMethodException | NoSuchMethodError e) {
 300             /* user forgot to provide activatable constructor?
 301              * or code recompiled and user forgot to provide
 302              *  activatable constructor?
 303              */
 304             throw new ActivationException
 305                 ("Activatable object must provide an activation"+
 306                  " constructor", e );
 307 
 308         } catch (InvocationTargetException e) {
 309             throw new ActivationException("exception in object constructor",
 310                                           e.getTargetException());
 311 
 312         } catch (Exception e) {
 313             throw new ActivationException("unable to activate object", e);
 314         } finally {

 315             checkInactiveGroup();
 316             releaseLock(id);
 317         }
 318     }
 319 
 320 
 321    /**
 322     * The group's <code>inactiveObject</code> method is called
 323     * indirectly via a call to the <code>Activatable.inactive</code>
 324     * method. A remote object implementation must call
 325     * <code>Activatable</code>'s <code>inactive</code> method when
 326     * that object deactivates (the object deems that it is no longer
 327     * active). If the object does not call
 328     * <code>Activatable.inactive</code> when it deactivates, the
 329     * object will never be garbage collected since the group keeps
 330     * strong references to the objects it creates. <p>
 331     *
 332     * The group's <code>inactiveObject</code> method
 333     * unexports the remote object from the RMI runtime so that the
 334     * object can no longer receive incoming RMI calls. This call will
 335     * only succeed if the object has no pending/executing calls. If
 336     * the object does have pending/executing RMI calls, then false


 368             ActiveEntry entry = active.get(id);
 369             if (entry == null) {
 370                 // REMIND: should this be silent?
 371                 throw new UnknownObjectException("object not active");
 372             }
 373 
 374             try {
 375                 if (Activatable.unexportObject(entry.impl, false) == false)
 376                     return false;
 377             } catch (NoSuchObjectException allowUnexportedObjects) {
 378             }
 379 
 380             try {
 381                 super.inactiveObject(id);
 382             } catch (UnknownObjectException allowUnregisteredObjects) {
 383             }
 384 
 385             active.remove(id);
 386 
 387         } finally {

 388             checkInactiveGroup();
 389             releaseLock(id);
 390         }
 391 
 392         return true;
 393     }
 394 
 395     /*
 396      * Determines if the group has become inactive and
 397      * marks it as such.
 398      */
 399     private void checkInactiveGroup() {
 400         boolean groupMarkedInactive = false;
 401         synchronized (this) {
 402             if (active.size() == 0 && lockedIDs.size() == 0 &&
 403                 groupInactive == false)
 404             {
 405                 groupInactive = true;
 406                 groupMarkedInactive = true;
 407             }
 408         }
 409