/** @see DynamicMBean#setAttributes */ public AttributeList setAttributes(AttributeList attributes) { /* Sanity checking. */ if (attributes == null) { throw new IllegalArgumentException("attribute list can't be null"); } /* Set each attribute specified. */ AttributeList results = new AttributeList(); for (int i = 0; i < attributes.size(); i++) { Attribute attr = (Attribute) attributes.get(i); try { /* Set new value. */ jeHelper.setAttribute(targetEnv, attr); /* * Add the name and new value to the result list. Be sure * to ask the MBean for the new value, rather than simply * using attr.getValue(), because the new value may not * be same if it is modified according to the JE * implementation. */ String name = attr.getName(); Object newValue = jeHelper.getAttribute(targetEnv, name); results.add(new Attribute(name, newValue)); } catch (Exception e) { e.printStackTrace(); } } return results; }
/** @see DynamicMBean#getAttributes */ public AttributeList getAttributes(String[] attributes) { /* Sanity checking. */ if (attributes == null) { throw new IllegalArgumentException("Attributes cannot be null"); } /* Get each requested attribute. */ AttributeList results = new AttributeList(); for (int i = 0; i < attributes.length; i++) { try { String name = attributes[i]; Object value = jeHelper.getAttribute(targetEnv, name); results.add(new Attribute(name, value)); } catch (Exception e) { e.printStackTrace(); } } return results; }
/** @see DynamicMBean#getAttribute */ public Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException { return jeHelper.getAttribute(targetEnv, attributeName); }