Пример #1
0
  /**
   * Create the available management interface for this environment. The attributes and operations
   * available vary according to environment configuration.
   */
  private synchronized void resetMBeanInfo() {

    /*
     * Get JE attributes, operation and notification information
     * from JEMBeanHelper. An application may choose to add functionality
     * of its own when constructing the MBeanInfo.
     */

    /* Attributes. */
    List attributeList = jeHelper.getAttributeList(targetEnv);
    MBeanAttributeInfo[] attributeInfo = new MBeanAttributeInfo[attributeList.size()];
    attributeList.toArray(attributeInfo);

    /* Constructors. */
    Constructor[] constructors = this.getClass().getConstructors();
    MBeanConstructorInfo[] constructorInfo = new MBeanConstructorInfo[constructors.length];
    for (int i = 0; i < constructors.length; i++) {
      constructorInfo[i] = new MBeanConstructorInfo(this.getClass().getName(), constructors[i]);
    }

    /* Operations. */

    /*
     * Get the list of operations available from the jeHelper. Then add
     * an open and close operation.
     */
    List operationList = jeHelper.getOperationList(targetEnv);
    if (targetEnv == null) {
      operationList.add(
          new MBeanOperationInfo(
              OP_OPEN,
              "Configure and open the JE environment.",
              new MBeanParameterInfo[0], // no params
              "java.lang.Boolean",
              MBeanOperationInfo.ACTION_INFO));
    } else {
      operationList.add(
          new MBeanOperationInfo(
              OP_CLOSE,
              "Close the JE environment.",
              new MBeanParameterInfo[0], // no params
              "void",
              MBeanOperationInfo.ACTION_INFO));
    }

    MBeanOperationInfo[] operationInfo = new MBeanOperationInfo[operationList.size()];
    operationList.toArray(operationInfo);

    /* Notifications. */
    MBeanNotificationInfo[] notificationInfo = jeHelper.getNotificationInfo(targetEnv);

    /* Generate the MBean description. */
    mbeanInfo =
        new MBeanInfo(
            this.getClass().getName(),
            DESCRIPTION,
            attributeInfo,
            constructorInfo,
            operationInfo,
            notificationInfo);
  }