示例#1
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();
        }
      }
    }
  }