code: public static AttributeList setAttributes(String name, HashMap attributes) throws JMException
     {
        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))
              continue;
  
           String value = (String) attributes.get(attrName);
           if (value.equals("null") && server.getAttribute(objName, attrName) == null)
           {
              if (trace)
                 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)
           {
              if (trace)
                 log.trace("Failed to load class for attribute: " + attrType, e);
              throw new ReflectionException(e, "Failed to load class for attribute: " + attrType);
           }
           catch (IntrospectionException e)
           {
              if (trace)
                 log.trace("Skipped setting attribute: " + attrName + 
                           ", cannot find PropertyEditor for type: " + attrType);
              continue;
           }
  
           server.setAttribute(objName, attr);
           newAttributes.add(attr);
        }
  
        return newAttributes;
     }
docs: Set MBean attributes
  @param name The bean name
  @param attributes The attributes
  @return The updated attribute list
  @exception JMException Thrown if an error occurs