Example #1
0
  /**
   * Create an <code>ObjectName</code> for this <code>Realm</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param realm The Realm to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, Realm realm)
      throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = realm.getContainer();

    if (container instanceof Engine) {
      name = new ObjectName(domain + ":type=Realm");
    } else if (container instanceof Host) {
      name = new ObjectName(domain + ":type=Realm,host=" + container.getName());
    } else if (container instanceof Context) {
      String path = ((Context) container).getPath();
      if (path.length() < 1) {
        path = "/";
      }
      Host host = (Host) container.getParent();
      name = new ObjectName(domain + ":type=Realm,path=" + path + ",host=" + host.getName());
    }

    return (name);
  }