示例#1
0
  /*
   *
   *   Date      By	Description
   * MM/DD/YYYY
   * ----------  --	-----------
   * 11/17/2003  INB	Ensure that <code>InteruptedExceptions</code> do not
   *			keep the <code>Lock</code> from being cleared.  Clear
   *			the <code>Thread</code> from the <code>Lock</code>.
   * 02/21/2001  INB	Created.
   *
   */
  private final void unlockReadWrite() throws java.lang.InterruptedException {
    java.lang.InterruptedException interruptedException = null;
    boolean grabbed = false;

    try {
      // Grab the primary lock.
      while (!grabbed) {
        try {
          getPrimaryLock().grab("", false, false);
          grabbed = true;
        } catch (java.lang.InterruptedException e) {
          // Clear any interruptions and retry the grab.
          interruptedException = e;
          com.rbnb.compat.Utilities.interrupted(Thread.currentThread());
        }
      }

      // Clear the primary lock.
      getPrimaryLock().unlock();

    } finally {
      // Release the primary lock.
      if (grabbed) {
        synchronized (getPrimaryLock()) {
          getPrimaryLock().release();
          if (getPrimaryLock().count == 0) {
            getPrimaryLock().setThread(null);
          }
        }
      }

      // Throw the <code>InterruptedException</code> if one happened.
      if (interruptedException != null) {
        throw interruptedException;
      }
    }
  }
  /*
   *
   *   Date      By	Description
   * MM/DD/YYYY
   * ----------  --	-----------
   * 04/28/2004  INB	Created.
   *
   */
  public AddressPermissions(String stringI) throws java.lang.Exception {
    super();

    int eql = stringI.indexOf("=");

    if (eql == -1) {
      // If there is no equals (=), then the entire thing is the
      // address.
      setAddress(stringI);

    } else if (eql == 0) {
      // No actual address was provided.
      throw new java.lang.IllegalArgumentException("No address provided in " + stringI);

    } else {
      // Otherwise, we have permissions as well as an address.
      String permString = stringI.substring(eql + 1);

      if (permString.length() == 0) {
        // If there are no permissions provided, then that's an
        // error.
        throw new java.lang.IllegalArgumentException(
            "No permissions provided with address " + "epecification " + stringI);
      }

      // Turn on the appropriate permissions bits.
      setPermissions(0x00);
      char permChar;
      int idx1;

      for (int idx = 0; idx < permString.length(); ++idx) {
        // Determine which permission is being granted by each
        // character in the permissions string.
        permChar = permString.charAt(idx);

        // Find the matching access character.
        for (idx1 = 0; idx1 < ACCESS_VALUES.length; ++idx1) {
          if (permChar == ACCESS_VALUES[idx1]) {
            break;
          }
        }

        if (idx1 == ACCESS_VALUES.length) {
          // No matching character was found, throw an exception.
          throw new java.lang.IllegalArgumentException(
              "Unrecognized permission access character in " + stringI);
        }

        // Set the corresponding bit.
        setPermissions(getPermissions() | (0x01 << idx1));
      }

      // Set the address.
      setAddress(stringI.substring(0, eql));
    }

    if (getAddress().equals("*")) {
      // If this is the default wildcard address, then use the
      // default wildcard.
      setWildcard(AddressAuthorization.Wildcard);

    } else if (getAddress().equalsIgnoreCase("localhost")) {
      // If the address is localhost, then map it to the actual localhost
      // address.
      if (Localhost == null) {
        Localhost = TCP.buildAddress("localhost");
        Localhost = Localhost.substring(6, com.rbnb.compat.Utilities.lastIndexOf(Localhost, ":"));
        Localhost_Wildcard = new com.rbnb.utility.Wildcards(Localhost);
      }
      setAddress(Localhost);
      setWildcard(Localhost_Wildcard);

    } else {
      // Otherwise, create a new wildcard.
      setWildcard(new com.rbnb.utility.Wildcards(getAddress()));
    }
  }