Example #1
0
  /**
   * Removes the associated tie from an internal table and calls {@link Tie#deactivate} to
   * deactivate the object.
   *
   * @param target the object to unexport.
   */
  public void unexportObject(java.rmi.Remote target) throws java.rmi.NoSuchObjectException {
    synchronized (exportedServants) {
      Tie cachedTie = lookupTie(target);
      if (cachedTie != null) {
        exportedServants.remove(target);
        Utility.purgeStubForTie(cachedTie);
        Utility.purgeTieAndServant(cachedTie);
        try {
          cleanUpTie(cachedTie);
        } catch (BAD_OPERATION e) {
          // ignore
        } catch (org.omg.CORBA.OBJ_ADAPTER e) {
          // This can happen when the target was never associated with a POA.
          // We can safely ignore this case.
        }

        // Is it time to shut down our keep alive thread?
        if (exportedServants.isEmpty()) {
          keepAlive.quit();
          keepAlive = null;
        }
      } else {
        throw new java.rmi.NoSuchObjectException("Tie not found");
      }
    }
  }
Example #2
0
  /**
   * Registers a target for a tie. Adds the tie to an internal table and calls {@link Tie#setTarget}
   * on the tie object.
   *
   * @param tie the tie to register.
   * @param target the target for the tie.
   */
  public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target) {
    synchronized (exportedServants) {
      // Do we already have this target registered?
      if (lookupTie(target) == null) {
        // No, so register it and set the target...
        exportedServants.put(target, tie);
        tie.setTarget(target);

        // Do we need to instantiate our keep-alive thread?
        if (keepAlive == null) {
          // Yes. Instantiate our keep-alive thread and start
          // it up...
          keepAlive =
              (KeepAlive)
                  AccessController.doPrivileged(
                      new PrivilegedAction() {
                        public java.lang.Object run() {
                          return new KeepAlive();
                        }
                      });
          keepAlive.start();
        }
      }
    }
  }