コード例 #1
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * 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);
  }
コード例 #2
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * Create an <code>ObjectName</code> for this <code>ContextResource</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param resource The ContextResource to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  public static ObjectName createObjectName(String domain, ContextResource resource)
      throws MalformedObjectNameException {

    ObjectName name = null;
    String encodedResourceName = encodeStr(resource.getName());
    Object container = resource.getNamingResources().getContainer();
    if (container instanceof Server) {
      name =
          new ObjectName(
              domain
                  + ":type=Resource"
                  + ",resourcetype=Global,class="
                  + resource.getType()
                  + ",name="
                  + encodedResourceName);
    } else if (container instanceof Context) {
      String path = ((Context) container).getPath();
      if (path.length() < 1) path = "/";
      Host host = (Host) ((Context) container).getParent();
      name =
          new ObjectName(
              domain
                  + ":type=Resource"
                  + ",resourcetype=Context,path="
                  + path
                  + ",host="
                  + host.getName()
                  + ",class="
                  + resource.getType()
                  + ",name="
                  + encodedResourceName);
    } else if (container instanceof DefaultContext) {
      container = ((DefaultContext) container).getParent();
      if (container instanceof Host) {
        Host host = (Host) container;
        name =
            new ObjectName(
                domain
                    + ":type=Resource"
                    + ",resourcetype=HostDefaultContext,host="
                    + host.getName()
                    + ",class="
                    + resource.getType()
                    + ",name="
                    + encodedResourceName);
      } else if (container instanceof Engine) {
        name =
            new ObjectName(
                domain
                    + ":type=Resource"
                    + ",resourcetype=ServiceDefaultContext,class="
                    + resource.getType()
                    + ",name="
                    + encodedResourceName);
      }
    }

    return (name);
  }
コード例 #3
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * 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);
  }
コード例 #4
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * Create an <code>ObjectName</code> for this <code>DefaultContext</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param context The DefaultContext to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, DefaultContext context)
      throws MalformedObjectNameException {

    ObjectName name = null;
    Container container = context.getParent();
    if (container instanceof Host) {
      Host host = (Host) container;
      name = new ObjectName(domain + ":type=DefaultContext,host=" + host.getName());
    } else if (container instanceof Engine) {
      name = new ObjectName(domain + ":type=DefaultContext");
    }

    return (name);
  }
コード例 #5
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * Create an <code>ObjectName</code> for this <code>Context</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param context The Context to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, Context context)
      throws MalformedObjectNameException {

    ObjectName name = null;
    Host host = (Host) context.getParent();
    String path = context.getPath();
    if (path.length() < 1) path = "/";
    // FIXME
    name =
        new ObjectName(
            domain
                + ":j2eeType=WebModule,name=//"
                + host.getName()
                + path
                + ",J2EEApplication=none,J2EEServer=none");

    return (name);
  }
コード例 #6
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * 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);
  }
コード例 #7
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * Create an <code>ObjectName</code> for this <code>Server</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param resources The NamingResources to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, NamingResources resources)
      throws MalformedObjectNameException {

    ObjectName name = null;
    Object container = resources.getContainer();
    if (container instanceof Server) {
      name = new ObjectName(domain + ":type=NamingResources" + ",resourcetype=Global");
    } else if (container instanceof Context) {
      String path = ((Context) container).getPath();
      if (path.length() < 1) path = "/";
      Host host = (Host) ((Context) container).getParent();
      name =
          new ObjectName(
              domain
                  + ":type=NamingResources"
                  + ",resourcetype=Context,path="
                  + path
                  + ",host="
                  + host.getName());
    } else if (container instanceof DefaultContext) {
      container = ((DefaultContext) container).getParent();
      if (container instanceof Host) {
        Host host = (Host) container;
        name =
            new ObjectName(
                domain
                    + ":type=NamingResources"
                    + ",resourcetype=HostDefaultContext,host="
                    + host.getName());
      } else if (container instanceof Engine) {
        name =
            new ObjectName(
                domain + ":type=NamingResources" + ",resourcetype=ServiceDefaultContext");
      }
    }

    return (name);
  }
コード例 #8
0
ファイル: MBeanUtils.java プロジェクト: phan-pivotal/OSS
  /**
   * Create an <code>ObjectName</code> for this <code>Host</code> object.
   *
   * @param domain Domain in which this name is to be created
   * @param host The Host to be named
   * @exception MalformedObjectNameException if a name cannot be created
   */
  static ObjectName createObjectName(String domain, Host host) throws MalformedObjectNameException {

    ObjectName name = null;
    name = new ObjectName(domain + ":type=Host,host=" + host.getName());
    return (name);
  }