use of javax.management.DynamicMBean in project controller by opendaylight.
the class DynamicWritableWrapperTest method setNumberOfThreads.
private void setNumberOfThreads(final int numberOfThreads) throws Exception {
DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, DynamicMBean.class);
proxy.setAttribute(new Attribute(THREAD_COUNT, numberOfThreads));
}
use of javax.management.DynamicMBean in project controller by opendaylight.
the class DynamicWritableWrapperTest method testSetAttribute.
@Test
public void testSetAttribute() throws Exception {
DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, DynamicMBean.class);
proxy.setAttribute(new Attribute(THREAD_COUNT, newThreadCount));
assertEquals(newThreadCount, proxy.getAttribute(THREAD_COUNT));
assertEquals(newThreadCount, threadPoolConfigBean.getThreadCount());
AttributeList attributeList = new AttributeList();
attributeList.add(new Attribute(THREAD_COUNT, threadCount));
boolean bool = true;
attributeList.add(new Attribute(TRIGGER_NEW_INSTANCE_CREATION, bool));
proxy.setAttributes(attributeList);
assertEquals(threadCount, threadPoolConfigBean.getThreadCount());
assertEquals(bool, threadPoolConfigBean.isTriggerNewInstanceCreation());
}
use of javax.management.DynamicMBean in project tomcat70 by apache.
the class MBeanUtils method createMBean.
/**
* Create, register, and return an MBean for this
* <code>Group</code> object.
*
* @param group The Group to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Group group) throws Exception {
String mname = createManagedName(group);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with " + mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(group);
ObjectName oname = createObjectName(domain, group);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
use of javax.management.DynamicMBean in project tomcat70 by apache.
the class MBeanUtils method createMBean.
/**
* Create, register, and return an MBean for this
* <code>Role</code> object.
*
* @param role The Role to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Role role) throws Exception {
String mname = createManagedName(role);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with " + mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(role);
ObjectName oname = createObjectName(domain, role);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
use of javax.management.DynamicMBean in project tomcat70 by apache.
the class MBeanUtils method createMBean.
/**
* Create, register, and return an MBean for this
* <code>User</code> object.
*
* @param user The User to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(User user) throws Exception {
String mname = createManagedName(user);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with " + mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(user);
ObjectName oname = createObjectName(domain, user);
if (mserver.isRegistered(oname)) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
Aggregations