Package javax.management

Examples of javax.management.MBeanAttributeInfo


      MBeanAttributeInfo[] attrs = info.getAttributes();
      if (attrs == null || attrs.length == 0) throw new AttributeNotFoundException("No attributes defined for this MBean");

      for (int i = 0; i < attrs.length; ++i)
      {
         MBeanAttributeInfo attr = attrs[i];
         if (attr == null) continue;

         if (attribute.getName().equals(attr.getName()))
         {
            if (!attr.isWritable()) throw new ReflectionException(new NoSuchMethodException("No setter defined for attribute: " + attribute));

            try
            {
               String signature = attr.getType();
               Class cls = Utils.loadClass(resource.getClass().getClassLoader(), signature);
               invoke(resource, "set" + attr.getName(), new Class[]{cls}, new Object[]{attribute.getValue()});
               return;
            }
            catch (ClassNotFoundException x)
            {
               throw new ReflectionException(x);
View Full Code Here


      }
   }

   public Object getAttribute(MBeanMetaData metadata, String attribute) throws MBeanException, AttributeNotFoundException, ReflectionException
   {
      MBeanAttributeInfo attr = getStandardAttributeInfo(metadata, attribute, false);
      if (attr != null)
      {
         String attributeName = getAttributeName(attr, true);
         try
         {
View Full Code Here

   }

   public void setAttribute(MBeanMetaData metadata, Attribute attribute) throws MBeanException, AttributeNotFoundException, InvalidAttributeValueException, ReflectionException
   {
      String name = attribute.getName();
      MBeanAttributeInfo attr = getStandardAttributeInfo(metadata, name, true);
      if (attr != null)
      {
         String attributeName = getAttributeName(attr, false);
         try
         {
            invokeImpl(metadata, attributeName, new String[]{attr.getType()}, new Object[]{attribute.getValue()});
         }
         catch (IllegalArgumentException x)
         {
            throw new InvalidAttributeValueException("Invalid value for attribute " + name + ": " + attribute.getValue());
         }
View Full Code Here

      }
   }

   private MBeanAttributeInfo getStandardAttributeInfo(MBeanMetaData metadata, String attribute, boolean isWritable)
   {
      MBeanAttributeInfo attr = null;
      synchronized (attributes)
      {
         attr = (MBeanAttributeInfo)attributes.get(attribute);
      }
      if (attr != null)
      {
         if (isWritable && attr.isWritable()) return attr;
         if (!isWritable && attr.isReadable()) return attr;
      }
      else
      {
         MBeanAttributeInfo[] attrs = metadata.info.getAttributes();
         if (attrs != null)
         {
            for (int i = 0; i < attrs.length; ++i)
            {
               attr = attrs[i];
               String name = attr.getName();
               if (attribute.equals(name))
               {
                  synchronized (attributes)
                  {
                     attributes.put(attribute, attr);
                  }
                  if (isWritable && attr.isWritable()) return attr;
                  if (!isWritable && attr.isReadable()) return attr;
               }
            }
         }
      }
      return null;
View Full Code Here

    String name = in.getVariable("objectname");
    String attributeVariable = in.getVariable("attribute");
    String formatVariable = in.getVariable("format");
    ObjectName objectName = null;
    MBeanAttributeInfo targetAttribute = null;
    // special case
    boolean validMBean = false;
    if (name != null)
    {
      objectName = new ObjectName(name);
      if (server.isRegistered(objectName))
      {
        validMBean = true;
      }
    }
    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);
      attribute.setAttribute("isnull", (attributeValue==null)?"true":"false");
      root.appendChild(attribute);

      if ("array".equals(formatVariable) && attributeValue.getClass().isArray())
View Full Code Here

  }

  private void getProperties(MBeanServerConnection mbsc){
    try{
      ObjectName on=new ObjectName("TabUI:name=OsgiProbes");
      MBeanAttributeInfo attrInfo[] = mbsc.getMBeanInfo(on).getAttributes();
      Object content [][]=new String[attrInfo.length][2];
      for (int k=0;k<attrInfo.length;k++) {
        content [k][0]=attrInfo[k].getName();
        content [k][1]=mbsc.getAttribute(on, attrInfo[k].getName());
      }
View Full Code Here

  {
    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++)
      {
        if (attributes[i].getName().equals(attributeVariable))
        {
          targetAttribute = attributes[i];
          break;
        }
      }
    }
    if (targetAttribute != null)
    {
      String type = targetAttribute.getType();
      Object value = null;
      if (valueVariable != null)
      {
        try
        {
View Full Code Here

    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++)
        {
          if (attributes[i].getName().equals(attributeVariable))
          {
            targetAttribute = attributes[i];
            break;
          }
        }
      }
      if (targetAttribute != null)
      {
        String type = targetAttribute.getType();
        Object value = null;
        if (valueVariable != null)
        {
          try
          {
View Full Code Here

          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;
View Full Code Here

    } 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

TOP

Related Classes of javax.management.MBeanAttributeInfo

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.