use of javax.management.StandardMBean in project Payara by payara.
the class BootAMX method create.
/**
* Create an instance of the booter.
*/
public static synchronized BootAMX create(final ServiceLocator habitat, final MBeanServer server) {
final BootAMX booter = new BootAMX(habitat, server);
final ObjectName objectName = getBootAMXMBeanObjectName();
try {
final StandardMBean mbean = new StandardMBean(booter, BootAMXMBean.class);
if (!server.registerMBean(mbean, objectName).getObjectName().equals(objectName)) {
throw new IllegalStateException();
}
} catch (JMException e) {
e.printStackTrace();
throw new IllegalStateException(e);
}
return booter;
}
use of javax.management.StandardMBean in project fabric8 by jboss-fuse.
the class JolokiaMXBeanProxy method getMXBeanProxy.
@SuppressWarnings("unchecked")
public static <T extends Object> T getMXBeanProxy(String serviceURL, ObjectName objectName, Class<T> mxbeanInterface, String username, String password, MBeanInfo mbeanInfo) {
// [TODO] this should be obtaind remotely over jolokia
if (mbeanInfo == null) {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
try {
StandardMBean impl = new StandardMBean(Mockito.mock(mxbeanInterface), mxbeanInterface, true);
server.registerMBean(impl, objectName);
mbeanInfo = server.getMBeanInfo(objectName);
} finally {
if (server.isRegistered(objectName)) {
server.unregisterMBean(objectName);
}
}
} catch (Exception ex) {
throw new IllegalStateException("Cannot obtain MBeanInfo", ex);
}
}
ClassLoader classLoader = mxbeanInterface.getClassLoader();
InvocationHandler handler = new MXBeanInvocationHandler(serviceURL, objectName, username, password, classLoader, mbeanInfo);
return (T) Proxy.newProxyInstance(classLoader, new Class<?>[] { mxbeanInterface }, handler);
}
use of javax.management.StandardMBean in project smscgateway by RestComm.
the class MProcManagement method registerMProcRuleMbean.
private void registerMProcRuleMbean(MProcRuleMBean mProcRule) {
try {
ObjectName esmeObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=MProcRule,name=" + mProcRule.getId());
StandardMBean esmeMxBean = new StandardMBean(mProcRule, MProcRuleMBean.class, true);
if (this.mbeanServer != null)
this.mbeanServer.registerMBean(esmeMxBean, esmeObjNname);
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
} catch (MBeanRegistrationException e) {
logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
} catch (NotCompliantMBeanException e) {
logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
} catch (MalformedObjectNameException e) {
logger.error(String.format("Error while registering MBean for MProcRule %d", mProcRule.getId()), e);
}
}
use of javax.management.StandardMBean in project smscgateway by RestComm.
the class SipManagement method registerSipMbean.
private void registerSipMbean(Sip esme) {
try {
ObjectName esmeObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=Sip,name=" + esme.getName());
StandardMBean esmeMxBean = new StandardMBean(esme, SipMBean.class, true);
if (this.mbeanServer != null)
this.mbeanServer.registerMBean(esmeMxBean, esmeObjNname);
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
} catch (MBeanRegistrationException e) {
logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
} catch (NotCompliantMBeanException e) {
logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
} catch (MalformedObjectNameException e) {
logger.error(String.format("Error while registering MBean for SIP %s", esme.getName()), e);
}
}
use of javax.management.StandardMBean in project fabric8 by jboss-fuse.
the class ClusterBootstrapManager method activate.
@Activate
void activate() throws Exception {
StandardMBean mbean = new StandardMBean(this, ClusterBootstrapManagerMBean.class);
JMXUtils.registerMBean(mbean, mbeanServer.get(), OBJECT_NAME);
activateComponent();
}
Aggregations