Ejemplo n.º 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");
      }
    }
  }
Ejemplo n.º 2
0
 /** An unsynchronized version of getTie() for internal use. */
 private static Tie lookupTie(Remote target) {
   Tie result = (Tie) exportedServants.get(target);
   if (result == null && target instanceof Tie) {
     if (exportedServants.contains(target)) {
       result = (Tie) target;
     }
   }
   return result;
 }
Ejemplo n.º 3
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();
        }
      }
    }
  }
Ejemplo n.º 4
0
  // Used by TOAFactory.shutdown to unexport all targets for this
  // particular ORB.  This happens during ORB shutdown.
  public void unregisterTargetsForORB(org.omg.CORBA.ORB orb) {
    for (Enumeration e = exportedServants.keys(); e.hasMoreElements(); ) {
      java.lang.Object key = e.nextElement();
      Remote target = (Remote) (key instanceof Tie ? ((Tie) key).getTarget() : key);

      // Bug 4476347: BAD_OPERATION is thrown if the ties delegate isn't set.
      // We can ignore this because it means the tie is not connected to an ORB.
      try {
        if (orb == getTie(target).orb()) {
          try {
            unexportObject(target);
          } catch (java.rmi.NoSuchObjectException ex) {
            // We neglect this exception if at all if it is
            // raised. It is not harmful.
          }
        }
      } catch (BAD_OPERATION bad) {
        /* Ignore */
      }
    }
  }