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

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

    if (container instanceof Engine) {
      name = new ObjectName(domain + ":type=Manager");
    } else if (container instanceof Host) {
      name = new ObjectName(domain + ":type=Manager,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=Manager,path=" + path + ",host=" + host.getName());
    } else if (container == null) {
      DefaultContext defaultContext = manager.getDefaultContext();
      if (defaultContext != null) {
        Container parent = defaultContext.getParent();
        if (parent instanceof Engine) {
          name = new ObjectName(domain + ":type=DefaultManager");
        } else if (parent instanceof Host) {
          name = new ObjectName(domain + ":type=DefaultManager,host=" + parent.getName());
        }
      }
    }

    return (name);
  }
Ejemplo n.º 2
0
  /**
   * Create an <code>ObjectName</code> for this <code>Valve</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param valve The Valve to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, GlassFishValve valve)
      throws MalformedObjectNameException {
    if (valve instanceof ValveBase) {
      ObjectName name = ((ValveBase) valve).getObjectName();
      if (name != null) return name;
    }

    ObjectName name = null;
    Container container = null;
    String className = valve.getClass().getName();
    int period = className.lastIndexOf('.');
    if (period >= 0) className = className.substring(period + 1);
    if (valve instanceof Contained) {
      container = ((Contained) valve).getContainer();
    }
    if (container == null) {
      throw new MalformedObjectNameException(
          "Cannot create mbean for non-contained valve " + valve);
    }
    if (container instanceof Engine) {
      String local = "";
      int seq = getSeq(local);
      String ext = "";
      if (seq > 0) {
        ext = ",seq=" + seq;
      }
      name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local);
    } else if (container instanceof Host) {
      String local = ",host=" + container.getName();
      int seq = getSeq(local);
      String ext = "";
      if (seq > 0) {
        ext = ",seq=" + seq;
      }
      name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local);
    } else if (container instanceof Context) {
      String path = ((Context) container).getPath();
      if (path.length() < 1) {
        path = "/";
      }
      Host host = (Host) container.getParent();
      String local = ",path=" + path + ",host=" + host.getName();
      int seq = getSeq(local);
      String ext = "";
      if (seq > 0) {
        ext = ",seq=" + seq;
      }
      name = new ObjectName(domain + ":type=Valve,name=" + className + ext + local);
    }

    return (name);
  }
Ejemplo n.º 3
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);
  }