use of javax.management.StandardMBean in project ignite by apache.
the class GridMBeanSelfTest method testCorrectMBeanInfo.
/**
* Tests correct MBean interface.
*
* @throws Exception Thrown if test fails.
*/
@Test
public void testCorrectMBeanInfo() throws Exception {
StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterface.class);
MBeanInfo info = mbean.getMBeanInfo();
assert info.getDescription().equals("MBeanDescription.");
assert info.getOperations().length == 2;
for (MBeanOperationInfo opInfo : info.getOperations()) {
if (opInfo.getDescription().equals("MBeanOperation."))
assert opInfo.getSignature().length == 2;
else {
assert opInfo.getDescription().equals("MBeanSuperOperation.");
assert opInfo.getSignature().length == 1;
}
}
for (MBeanParameterInfo paramInfo : info.getOperations()[0].getSignature()) {
if (paramInfo.getName().equals("ignored"))
assert paramInfo.getDescription().equals("MBeanOperationParameter1.");
else {
assert paramInfo.getName().equals("someData");
assert paramInfo.getDescription().equals("MBeanOperationParameter2.");
}
}
assert info.getAttributes().length == 4 : "Expected 4 attributes but got " + info.getAttributes().length;
for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
if (!attrInfo.isWritable()) {
assert (attrInfo.getDescription().equals("MBeanReadonlyGetter.") || attrInfo.getDescription().equals("MBeanROGetter."));
} else {
assert (attrInfo.getDescription().equals("MBeanWritableGetter.") || attrInfo.getDescription().equals("MBeanWritableIsGetter."));
}
}
}
use of javax.management.StandardMBean in project ignite by apache.
the class GridMBeanSelfTest method testEmptyNameMBeanInfo.
/**
* Tests correct MBean interface.
*
* @throws Exception Thrown if test fails.
*/
@Test
public void testEmptyNameMBeanInfo() throws Exception {
try {
StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceEmptyName.class);
mbean.getMBeanInfo();
} catch (AssertionError ignored) {
return;
}
assert false;
}
use of javax.management.StandardMBean in project ignite by apache.
the class GridMBeanSelfTest method testEmptyDescriptionMBeanInfo.
/**
* Tests correct MBean interface.
*
* @throws Exception Thrown if test fails.
*/
@Test
public void testEmptyDescriptionMBeanInfo() throws Exception {
try {
StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceEmptyDescription.class);
mbean.getMBeanInfo();
} catch (AssertionError ignored) {
return;
}
assert false;
}
use of javax.management.StandardMBean in project drools by kiegroup.
the class MBeanUtils method registerMBean.
public static synchronized <T> void registerMBean(T mbean, Class<T> mbeanInterface, ObjectName name) {
try {
MBeanServer mbs = getMBeanServer();
if (!mbs.isRegistered(name)) {
final StandardMBean adapter = new StandardMBean(mbean, mbeanInterface);
mbs.registerMBean(adapter, name);
}
} catch (Exception e) {
logger.error("Unable to register mbean " + name + " into the platform MBean Server", e);
}
}
use of javax.management.StandardMBean in project drools by kiegroup.
the class KnowledgeBaseMonitoring method startInternalMBeans.
public void startInternalMBeans() {
for (EntryPointNode epn : kbase.getRete().getEntryPointNodes().values()) {
for (ObjectTypeNode otn : epn.getObjectTypeNodes().values()) {
ObjectTypeNodeMonitor otnm = new ObjectTypeNodeMonitor(otn);
try {
final StandardMBean adapter = new StandardMBean(otnm, ObjectTypeNodeMonitorMBean.class);
ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=EntryPoints,EntryPoint=" + otnm.getNameSufix() + ",ObjectType=" + ((ClassObjectType) otn.getObjectType()).getClassName());
DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
} catch (NotCompliantMBeanException e) {
logger.error("Unable to register ObjectTypeNodeMonitor mbean for OTN " + otn.getObjectType() + " into the platform MBean Server", e);
}
}
}
final KieBaseConfigurationMonitor kbcm = new KieBaseConfigurationMonitor(kbase.getConfiguration());
try {
final StandardMBean adapter = new StandardMBean(kbcm, KieBaseConfigurationMonitorMBean.class);
ObjectName name = DroolsManagementAgent.createObjectName(this.name.toString() + ",group=Configuration");
DroolsManagementAgent.getInstance().registerMBean(kbase, adapter, name);
} catch (NotCompliantMBeanException e) {
logger.error("Unable to register KBaseConfigurationMonitor mbean into the platform MBean Server", e);
}
}
Aggregations