use of javax.management.Attribute in project jetty.project by eclipse.
the class ObjectMBean method setAttributes.
/* ------------------------------------------------------------ */
public AttributeList setAttributes(AttributeList attrs) {
if (LOG.isDebugEnabled())
LOG.debug("setAttributes");
AttributeList results = new AttributeList(attrs.size());
Iterator<Object> iter = attrs.iterator();
while (iter.hasNext()) {
try {
Attribute attr = (Attribute) iter.next();
setAttribute(attr);
results.add(new Attribute(attr.getName(), getAttribute(attr.getName())));
} catch (Exception e) {
LOG.warn(Log.EXCEPTION, e);
}
}
return results;
}
use of javax.management.Attribute in project jetty.project by eclipse.
the class ObjectMBeanTest method testDerivedAttributes.
/*
* this test uses the com.acme.Derived test classes
*/
@Test
public void testDerivedAttributes() throws Exception {
Derived derived = new Derived();
ObjectMBean mbean = (ObjectMBean) ObjectMBean.mbeanFor(derived);
ObjectMBean managed = (ObjectMBean) ObjectMBean.mbeanFor(derived.getManagedInstance());
mbean.setMBeanContainer(container);
managed.setMBeanContainer(container);
container.beanAdded(null, derived);
container.beanAdded(null, derived.getManagedInstance());
MBeanInfo toss = managed.getMBeanInfo();
Assert.assertNotNull(mbean.getMBeanInfo());
MBeanInfo info = mbean.getMBeanInfo();
Assert.assertEquals("name does not match", "com.acme.Derived", info.getClassName());
Assert.assertEquals("description does not match", "Test the mbean stuff", info.getDescription());
// for ( MBeanAttributeInfo i : info.getAttributes())
// {
// LOG.debug(i.toString());
// }
/*
* 2 attributes from lifecycle and 2 from Derived and 1 from MBean
*/
Assert.assertEquals("attribute count does not match", 6, info.getAttributes().length);
Assert.assertEquals("attribute values does not match", "Full Name", mbean.getAttribute("fname"));
mbean.setAttribute(new Attribute("fname", "Fuller Name"));
Assert.assertEquals("set attribute value does not match", "Fuller Name", mbean.getAttribute("fname"));
Assert.assertEquals("proxy attribute values do not match", "goop", mbean.getAttribute("goop"));
// Thread.sleep(100000);
}
use of javax.management.Attribute in project jetty.project by eclipse.
the class ObjectMBeanUtilTest method testSetAttributeAttributeWithWrongAttrName.
@Test(expected = AttributeNotFoundException.class)
public void testSetAttributeAttributeWithWrongAttrName() throws Exception {
// given
attribute = new Attribute("fnameee", "charu");
// when
objectMBean.setAttribute(attribute);
// then
fail("An AttributeNotFoundException must have occured by now as there is no attribute " + "with the name ffname in bean");
}
use of javax.management.Attribute in project hadoop by apache.
the class MetricsSourceAdapter method setAttrCacheTag.
private void setAttrCacheTag(MetricsTag tag, int recNo) {
String key = tagName(tag.name(), recNo);
attrCache.put(key, new Attribute(key, tag.value()));
}
use of javax.management.Attribute in project hadoop by apache.
the class MetricsSourceAdapter method getAttributes.
@Override
public AttributeList getAttributes(String[] attributes) {
updateJmxCache();
synchronized (this) {
AttributeList ret = new AttributeList();
for (String key : attributes) {
Attribute attr = attrCache.get(key);
if (LOG.isDebugEnabled()) {
LOG.debug(key + ": " + attr);
}
ret.add(attr);
}
return ret;
}
}
Aggregations