Package javax.management

Examples of javax.management.MBeanInfo


      }
    }
    if (validMBean && attributeVariable != null)
    {
      validMBean = false;
      MBeanInfo info = server.getMBeanInfo(objectName);
      MBeanAttributeInfo[] attributes = info.getAttributes();

      if (attributes != null)
      {
        for (int i=0;i<attributes.length;i++)
        {
          if (attributes[i].getName().equals(attributeVariable))
          {
            targetAttribute = attributes[i];
            validMBean = true;
            break;
          }
        }
      }
    }
    if (validMBean)
    {
      Element root = document.createElement("MBean");
      document.appendChild(root);

      root.setAttribute("objectname", objectName.toString());
      MBeanInfo info = server.getMBeanInfo(objectName);
      root.setAttribute("classname", info.getClassName());
      root.setAttribute("description", info.getDescription());

      Element attribute = document.createElement("Attribute");
      attribute.setAttribute("name", attributeVariable);
      attribute.setAttribute("classname", targetAttribute.getType());
      Object attributeValue = server.getAttribute(objectName, attributeVariable);
View Full Code Here


  private Element createMBeanElement(Document document, ObjectName objectName, HttpInputStream in)
    throws JMException
  {
    Element root = document.createElement("MBean");

    MBeanInfo info = server.getMBeanInfo(objectName);
    root.setAttribute("description", info.getDescription());
    root.setAttribute("classname", info.getClassName());
    root.setAttribute("objectname", objectName.toString());
/*
    if (info instanceof ModelMBeanInfo)
    {
      root.setAttribute("model", "true");
    }
*/
    if (HttpUtil.booleanVariableValue(in, "attributes", true)) {
      MBeanAttributeInfo[] attributes = info.getAttributes();
      if (attributes != null)
      {
        SortedMap sortedAttributes = new TreeMap();
        for (int i=0;i<attributes.length;i++)
        {
          Element attribute = document.createElement("Attribute");
          attribute.setAttribute("name", attributes[i].getName());
          attribute.setAttribute("type", attributes[i].getType());
          attribute.setAttribute("description", attributes[i].getDescription());
          attribute.setAttribute("strinit", String.valueOf(CommandProcessorUtil.canCreateParameterValue(attributes[i].getType())));
          if (attributes[i].isReadable() && attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "RW");
          }
          if (attributes[i].isReadable() && !attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "RO");
          }
          if (!attributes[i].isReadable() && attributes[i].isWritable())
          {
            attribute.setAttribute("availability", "WO");
          }
          try
          {
            Object attributeValue = server.getAttribute(objectName, attributes[i].getName());
            attribute.setAttribute("isnull", (attributeValue==null)?"true":"false");
            if (attributeValue != null)
            {
              attribute.setAttribute("value", attributeValue.toString());
              if (attributeValue.getClass().isArray())
              {
                attribute.setAttribute("aggregation", "array");
              }
              if (attributeValue instanceof java.util.Collection)
              {
                attribute.setAttribute("aggregation", "collection");
              }
              if (attributeValue instanceof java.util.Map)
              {
                attribute.setAttribute("aggregation", "map");
              }
            }
            else
            {
              attribute.setAttribute("value", "null");
            }

          }
          catch (JMException e)
          {
            attribute.setAttribute("value", e.getMessage());
          }
          sortedAttributes.put(attributes[i].getName(), attribute);
        }
        Iterator keys = sortedAttributes.keySet().iterator();
        while (keys.hasNext())
        {
          root.appendChild((Element)sortedAttributes.get(keys.next()));
        }
      }
    }
    if (HttpUtil.booleanVariableValue(in, "constructors", true))
    {
      MBeanConstructorInfo[] constructors = info.getConstructors();
      if (constructors != null)
      {
        // How to order contructors?
        for (int i=0;i<constructors.length;i++)
        {
          Element constructor = document.createElement("Constructor");
          constructor.setAttribute("name", constructors[i].getName());
          constructor.setAttribute("description", constructors[i].getDescription());
          addParameters(constructor, document, constructors[i].getSignature());
          root.appendChild(constructor);
        }
      }
    }
    if (HttpUtil.booleanVariableValue(in, "operations", true))
    {
      MBeanOperationInfo[] operations = info.getOperations();
      if (operations != null)
      {
        for (int i=0;i<operations.length;i++)
        {
          Element operation = document.createElement("Operation");
          operation.setAttribute("name", operations[i].getName());
          operation.setAttribute("description", operations[i].getDescription());
          operation.setAttribute("return", operations[i].getReturnType());
          switch (operations[i].getImpact())
          {
            case MBeanOperationInfo.UNKNOWN:
              operation.setAttribute("impact", "unknown");
              break;
            case MBeanOperationInfo.ACTION:
              operation.setAttribute("impact", "action");
              break;
            case MBeanOperationInfo.INFO:
              operation.setAttribute("impact", "info");
              break;
            case MBeanOperationInfo.ACTION_INFO:
              operation.setAttribute("impact", "action_info");
              break;
          }
          addParameters(operation, document, operations[i].getSignature());
          root.appendChild(operation);
        }
      }
    }
    if (HttpUtil.booleanVariableValue(in, "notifications", true))
    {
      MBeanNotificationInfo[] notifications = info.getNotifications();
      if (notifications != null)
      {
        for (int i=0;i<notifications.length;i++)
        {
          Element notification = document.createElement("Notification");
View Full Code Here

  private Element setAttribute(Document document, String attributeVariable, String valueVariable, ObjectName name) throws JMException
  {
    Element attributeElement = document.createElement("Attribute");
    attributeElement.setAttribute("attribute", attributeVariable);
    MBeanInfo info = server.getMBeanInfo(name);
    MBeanAttributeInfo[] attributes = info.getAttributes();
    MBeanAttributeInfo targetAttribute = null;
    if (attributes != null)
    {
      for (int i=0;i<attributes.length;i++)
      {
View Full Code Here

      return document;
    }

    if (server.isRegistered(name))
    {
      MBeanInfo info = server.getMBeanInfo(name);
      MBeanAttributeInfo[] attributes = info.getAttributes();
      MBeanAttributeInfo targetAttribute = null;
      if (attributes != null)
      {
        for (int i=0;i<attributes.length;i++)
        {
View Full Code Here

                        continue;
                    }

                    String oname = objectName.getDomain() + ":" + objectName.getCanonicalKeyPropertyListString();

                    MBeanInfo mbi = mbsc.getMBeanInfo(objectName);
                    MBeanAttributeInfo[] attribs = mbi.getAttributes();
                    ArrayList<String> attributes = new ArrayList<String>(attribs.length);

                    for (MBeanAttributeInfo attr : attribs) {
                        String type = attr.getType();
View Full Code Here

        .println("==========================================================>>>>>>>>>");
    while (iterator.hasNext()) {
      ObjectName oname = iterator.next();

      try {
        MBeanInfo minfo = MBeanAnnotationRegister.getMBeanServer()
            .getMBeanInfo(oname);
        String code = minfo.getClassName();

        if ("org.apache.commons.modeler.BaseModelMBean".equals(code)) {
          code = oname
              + ":"
              + (String) mBeanServer.getAttribute(oname,
                  "modelerType");
        }
        if ("javax.management.modelmbean.RequiredModelMBean"
            .equals(code)) {
          code = oname + ":" + minfo.getDescription();
        }
        System.out.println("modelerType: " + code);

        // ================属性============>>>>
        MBeanAttributeInfo attrs[] = minfo.getAttributes();
        Object value = null;

        for (int i = 0; i < attrs.length; i++) {
          if (!attrs[i].isReadable())
            continue;
          String attName = attrs[i].getName();
          if (attName.indexOf("=") >= 0 || attName.indexOf(":") >= 0
              || attName.indexOf(" ") >= 0) {
            continue;
          }

          try {
            value = mBeanServer.getAttribute(oname, attName);
          } catch (Throwable t) {
            continue;
          }
          if (value == null)
            continue;
          if ("modelerType".equals(attName))
            continue;
          String valueString = value.toString();
          System.out.println("Attribute::" + attName + ": "
              + valueString);

          if (attrs[i].getName().equals("ruleMemoryValue")) {
            Attribute attr = new Attribute("ruleMemoryValue", 100);
            mBeanServer.setAttribute(oname, attr);

            System.out.println(".......set finished..........");

            Object attribute = mBeanServer.getAttribute(oname,
                "ruleMemoryValue");
            System.out.println("attribute:::: finished:::"
                + attribute);
          }
        }

        // ===============操作=================>>>
        MBeanOperationInfo[] operations = minfo.getOperations();

        for (int i = 0; i < operations.length; i++) {
          String opName = operations[i].getName();
          System.out.println("operations:::::" + opName + ": "
              + operations[i].getDescription());
View Full Code Here

    return infoArray;
  }

  public static String getType(ObjectName oname, String attName) {
    String type = null;
    MBeanInfo info;
    try {
      info = server.getMBeanInfo(oname);
    } catch (Exception e) {
      logger.info("Can't find metadata for object" + oname);
      return null;
    }

    MBeanAttributeInfo attInfo[] = info.getAttributes();
    for (int i = 0; i < attInfo.length; i++) {
      if (attName.equals(attInfo[i].getName())) {
        type = attInfo[i].getType();
        return type;
      }
View Full Code Here

  public static void main(String[] args) {
    CmJvmConsumer jvm = new CmJvmConsumer();
    MBeanAnnotationRegister.register(jvm);

    try {
      MBeanInfo mBeanInfo = getMBeanServer().getMBeanInfo(
          new ObjectName(CommonUtils
              .getStrObjectName(CmJvmConsumer.class)));

      System.out.println(mBeanInfo.getClassName());
      System.out.println(mBeanInfo.getDescription());

      MBeanOperationInfo[] operations = mBeanInfo.getOperations();
      for (MBeanOperationInfo info : operations) {
        System.out.println("oper: " + info.getName() + " | "
            + info.getDescription());
      }

      MBeanAttributeInfo[] attributes = mBeanInfo.getAttributes();
      for (MBeanAttributeInfo info : attributes) {
        System.out.println("attr: " + info.getName() + " | "
            + info.getDescription());
      }
    } catch (IntrospectionException e) {
View Full Code Here

        } catch (NoSuchMethodException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        MBeanNotificationInfo mni = new MBeanNotificationInfo(new String[] {"asd"}, "nmnm!", "asdklajsdasl");
        return new MBeanInfo("clzName", "Desc", new MBeanAttributeInfo[] { mai }, new MBeanConstructorInfo[0], new MBeanOperationInfo[0], new MBeanNotificationInfo[] {mni});

    }
View Full Code Here

        String callMethod = definition.getMethod();

        ObjectName objectName = new ObjectName(callBean);

        // Find MBean
        MBeanInfo mBeanInfo = mBeanServerConnection.getMBeanInfo(objectName);
        if (mBeanInfo == null) {
            throw new IllegalArgumentException("MBean with name " + callBean + " is not found");
        }

        // Find operation
View Full Code Here

TOP

Related Classes of javax.management.MBeanInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.