JmxThrottlingConfiguration implements DynamicMBean { @Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { Assert.notNull(attribute, "attribute must not be null"); String attrName = attribute.getName(); String[] nameParts = StringUtils.split(attrName, ThrottleScope.THROTTLE_SEPARATOR); if (nameParts.length != 2) { throw new AttributeNotFoundException("attribute name is not in expected format: 'systemName . serviceName'"); } String attrValue = (String)attribute.getValue(); String[] valueParts = StringUtils.split(attrValue, ThrottleProps.PROP_VALUE_SEPARATOR); if (valueParts.length != 2) { throw new InvalidAttributeValueException("attribute value is not in expected format: 'limit / interval'"); } configuration.addProperty(nameParts[0], nameParts[1], Integer.valueOf(valueParts[1]), Integer.valueOf(valueParts[0])); } @Autowired  JmxThrottlingConfiguration(AbstractThrottlingConfiguration configuration); @Override MBeanInfo getMBeanInfo(); @Override Object getAttribute(String attrName); @Override void setAttribute(Attribute attribute); @Override AttributeList getAttributes(String[] attrNames); @Override AttributeList setAttributes(AttributeList objects); @Override Object invoke(String actionName, Object[] params, String[] signature);  }
@Test public void testSetAttribute() throws Exception { Attribute attribute = new Attribute("crm.op2", "20/40"); jmx.setAttribute(attribute); assertThat(jmx.getAttribute("crm.op2").toString(), is("20/40")); try { attribute = new Attribute("something", "20/40"); jmx.setAttribute(attribute); fail("there is no attribute with specified key"); } catch (AttributeNotFoundException ex) { } }