use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.
the class TooManyFooTest method main.
public static void main(String[] args) throws Exception {
final Child child = new Child();
test(child, "Child[MBean]", false);
final ChildMix childx = new ChildMix();
test(childx, "ChildMix[MXBean]", true);
final ChildMixMix childmx = new ChildMixMix();
test(childmx, "ChildMixMix[MXBean]", false);
final StandardMBean schild = new StandardMBean(child, ChildMBean.class);
test(schild, "Child[StandarMBean(Child)]", false);
final StandardMBean schildx = new StandardMBean(childx, ChildMXBean.class, true);
test(schildx, "ChildMix[StandarMXBean(ChildMix)]", true);
final StandardMBean schildmx = new StandardMBean(childmx, ChildMixMXBean.class, true);
test(schildmx, "ChildMixMix[StandarMXBean(ChildMixMix)]", true);
}
use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.
the class ServerDelegate method createStandardMBean.
/**
* Instantiates and registers a StandardMBean in the MBean server.
*
* @param implementationClassName
* The implementation class name of the MBean.
* @param interfaceClassName
* The management interface class name of the MBean.
* @param isMXBean
* If true, the resultant MBean is an MXBean.
* @param name
* The object name of the StandardMBean.
*/
@SuppressWarnings("unchecked")
public void createStandardMBean(String implementationClassName, String interfaceClassName, boolean isMXBean, ObjectName name) throws Exception {
Object implementation = Class.forName(implementationClassName).newInstance();
Class<Object> interfaceClass = interfaceClassName == null ? null : (Class<Object>) Class.forName(interfaceClassName);
// Create the StandardMBean
StandardMBean standardMBean = new StandardMBean(implementation, interfaceClass, isMXBean);
// Register the StandardMBean
mbeanServer.registerMBean(standardMBean, name);
}
use of javax.management.StandardMBean in project ddf by codice.
the class SolrCache method configureMBean.
private void configureMBean() {
LOGGER.debug("Registering Cache Manager Service MBean");
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
try {
objectName = new ObjectName(SolrCacheMBean.OBJECTNAME);
} catch (MalformedObjectNameException e) {
LOGGER.info("Could not create object name", e);
}
try {
try {
mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
} catch (InstanceAlreadyExistsException e) {
LOGGER.debug("Re-registering Cache Manager MBean");
mbeanServer.unregisterMBean(objectName);
mbeanServer.registerMBean(new StandardMBean(this, SolrCacheMBean.class), objectName);
}
} catch (Exception e) {
LOGGER.debug("Could not register MBean.", e);
}
}
use of javax.management.StandardMBean in project jdk8u_jdk by JetBrains.
the class OldMBeanServerTest method testJavaxManagementStandardMBean.
private static void testJavaxManagementStandardMBean() throws Exception {
ObjectName name = new ObjectName("a:b=c");
Object mbean = new StandardMBean(new Boring(), BoringMBean.class);
mbsc.createMBean(StandardMBean.class.getName(), name, new Object[] { new Boring(), BoringMBean.class }, new String[] { Object.class.getName(), Class.class.getName() });
assert mbsc.getAttribute(name, "Name").equals("Jessica");
assert mbsc.invoke(name, "add", new Object[] { 2, 3 }, new String[] { "int", "int" }).equals(5);
mbsc.unregisterMBean(name);
}
use of javax.management.StandardMBean in project drools by kiegroup.
the class DroolsManagementAgent method registerMBean.
public void registerMBean(Object owner, Object mbean, ObjectName name) {
try {
MBeanServer mbs = getMBeanServer();
if (!mbs.isRegistered(name)) {
mbs.registerMBean(mbean, name);
List<ObjectName> mbl = mbeans.get(owner);
if (mbl == null) {
mbl = new LinkedList<ObjectName>();
mbeans.put(owner, mbl);
if (mbean instanceof StandardMBean) {
mbeansRefs.put(owner, ((StandardMBean) mbean).getImplementation());
} else {
mbeansRefs.put(owner, mbean);
}
}
mbl.add(name);
logger.debug("Registered {} into the platform MBean Server", name);
}
} catch (Exception e) {
logger.error("Unable to register mbean " + name + " into the platform MBean Server", e);
}
}
Aggregations