Package javax.management

Examples of javax.management.AttributeList


   }
  
   public void selftest() throws Exception
   {
      // Store some attributes under an id
      AttributeList alist = new AttributeList();
      String storeId = "bananarama";
     
      Integer anInteger = new Integer(666);
      String aString = new String("Evil Test");
      alist.add(new Attribute("Attr1", anInteger));
      alist.add(new Attribute("Attr2", aString));
      apm.store(storeId, alist);
     
      // Read them back
      AttributeList alist2 = apm.load(storeId);     
   }
View Full Code Here


         println(out, depth, j2eeType + "=" + name);
        
         // print attributes, if any
         if (type.attributes != null)
         {
            AttributeList attrs = server.getAttributes(node, type.attributes);
            for (int i = 0; i < attrs.size(); i++)
            {
               Attribute attr = (Attribute)attrs.get(i);
               println(out, depth + 1, attr.getName() + "=" + attr.getValue());
            }
         }
        
         // print out associations, if any
View Full Code Here

   /**
    **/
   public AttributeList _getAttributes(ObjectName pName, String[] pAttributes)
   {
      AttributeList lReturn = null;
      try
      {
         lReturn = server.getAttributes(pName, pAttributes);
      }
      catch (Exception e)
View Full Code Here

      // First we try to get the attribute from the local node
      // and if not found the look for an instance out in the
      // node. This does not apply for JVMs.
      //AS ToDo: JVMs are not supported yet
      //AS ToDo: Now only the first list is taken, shall we add a merge capabilities ?
      AttributeList lReturn = null;
      try
      {
         lReturn = server.getAttributes(pName, pAttributes);
      }
      catch (InstanceNotFoundException infe)
View Full Code Here

      String[] names = new String[attributeNames.size()];
      attributeNames.toArray(names);
      log.debug("as string[]: " + Strings.join(names, ","));

      AttributeList attrList = server.getAttributes(objectName, names);
      log.debug("attribute list: " + attrList);

      if (attrList.size() == 0)
      {
         throw new CommandException("No matching attributes");
      }
      else if (attrList.size() != names.length)
      {
         log.warn("Not all specified attributes were found");
      }

      PrintWriter out = context.getWriter();

      Iterator iter = attrList.iterator();
      while (iter.hasNext())
      {
         Attribute attr = (Attribute) iter.next();
         if (prefix)
         {
View Full Code Here

      }

      MBeanInfo info = server.getMBeanInfo(objectName);
      MBeanAttributeInfo[] attribute_info = info.getAttributes();
      String type;
      AttributeList attrs = new AttributeList(attributeNames.size());
      Attribute attr;
      String attr_name;
      Object attr_value, real_value;
      MBeanAttributeInfo attr_info;


      for (Iterator it = attributeNames.iterator(); it.hasNext();)
      {
         attr_name = (String) it.next();
         attr_value = it.next();

         attr_info = findAttribute(attr_name, attribute_info);
         if (attr_info == null)
            throw new CommandException("attribute " + attr_name + " not found");
         type = attr_info.getType();

         PropertyEditor editor = PropertyEditors.getEditor(type);
         editor.setAsText((String) attr_value);
         real_value = editor.getValue();

         attr = new Attribute(attr_name, real_value);
         attrs.add(attr);
      }

      AttributeList ret = server.setAttributes(objectName, attrs);
      System.out.println("The following attributes were set successfuly:");
      if (ret.size() > 0)
      {
         for (Iterator it = ret.iterator(); it.hasNext();)
         {
            Attribute a = (Attribute) it.next();
            System.out.println(a.getName() + "=" + a.getValue());
         }
      }
View Full Code Here

      throw new AttributeNotFoundException(name+": is not an attribute");
   }

   public AttributeList getAttributes(String[] names)
   {
      AttributeList list = new AttributeList();
      for(int n = 0; n < names.length; n ++)
      {
         String name = names[n];
         try
         {
            Object value = getAttribute(name);
            Attribute attr = new Attribute(name, value);
            list.add(attr);
         }
         catch(Exception e)
         {
         }
      }
View Full Code Here

         throw new AttributeNotFoundException(name+": is not an attribute");     
   }

   public AttributeList setAttributes(AttributeList attributeList)
   {
      AttributeList list = new AttributeList();
      for(int n = 0; n < attributeList.size(); n ++)
      {
         Attribute attr = (Attribute) attributeList.get(n);
         try
         {
            setAttribute(attr);
            list.add(attr);
         }
         catch(Exception e)
         {
         }
      }
View Full Code Here

   {
      MBeanServer server = getMBeanServer();
      ObjectName objName = new ObjectName(name);
      MBeanInfo info = server.getMBeanInfo(objName);
      MBeanAttributeInfo[] attributesInfo = info.getAttributes();
      AttributeList newAttributes = new AttributeList();
      for(int a = 0; a < attributesInfo.length; a ++)
      {
         MBeanAttributeInfo attrInfo = attributesInfo[a];
         String attrName = attrInfo.getName();
         if( attributes.containsKey(attrName) == false )
            continue;
         String value = (String) attributes.get(attrName);
         if (value.equals("null") && server.getAttribute(objName, attrName) == null) {
            log.trace("ignoring 'null' for " + attrName);
            continue;
         }
         String attrType = attrInfo.getType();
         Attribute attr = null;
         try
         {
            Object realValue = PropertyEditors.convertValue(value, attrType);
            attr = new Attribute(attrName, realValue);
         }
         catch(ClassNotFoundException e)
         {
            String s = (attr != null) ? attr.getName() : attrType;
            log.trace("Failed to load class for attribute: " + s, e);
            throw new ReflectionException(e, "Failed to load class for attribute: " + s);
         }
         catch(IntrospectionException e)
         {
            log.trace("Skipped setting attribute: " + attrName +
                    ", cannot find PropertyEditor for type: " + attrType);
            continue;
         }

         server.setAttribute(objName, attr);
         newAttributes.add(attr);
      }
      return newAttributes;
   }
View Full Code Here

         attributes.put(param, value);
      }

      try
      {
         AttributeList newAttributes = setAttributes(name, attributes);
         MBeanData data = getMBeanData(name);
         request.setAttribute("mbeanData", data);
         RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/inspectMBean.jsp");
         rd.forward(request, response);
      }
View Full Code Here

TOP

Related Classes of javax.management.AttributeList

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.