use of javax.management.StandardMBean in project felix by apache.
the class MX4JMBeanServer method isInstanceOf.
public boolean isInstanceOf(ObjectName objectName, String className) throws InstanceNotFoundException {
if (className == null || className.trim().length() == 0) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid class name"));
}
objectName = secureObjectName(objectName);
MBeanMetaData metadata = findMBeanMetaData(objectName);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new MBeanPermission(metadata.info.getClassName(), "-", objectName, "isInstanceOf"));
}
try {
ClassLoader loader = metadata.classloader;
Class cls = null;
if (loader != null)
cls = loader.loadClass(className);
else
cls = Class.forName(className, false, null);
if (metadata.mbean instanceof StandardMBean) {
Object impl = ((StandardMBean) metadata.mbean).getImplementation();
return cls.isInstance(impl);
} else {
return cls.isInstance(metadata.mbean);
}
} catch (ClassNotFoundException x) {
return false;
}
}
use of javax.management.StandardMBean in project hadoop by apache.
the class SimulatedFSDataset method registerMBean.
/**
* Register the FSDataset MBean using the name
* "hadoop:service=DataNode,name=FSDatasetState-<storageid>"
* We use storage id for MBean name since a minicluster within a single
* Java VM may have multiple Simulated Datanodes.
*/
void registerMBean(final String storageId) {
// We wrap to bypass standard mbean naming convetion.
// This wraping can be removed in java 6 as it is more flexible in
// package naming for mbeans and their impl.
StandardMBean bean;
try {
bean = new StandardMBean(this, FSDatasetMBean.class);
mbeanName = MBeans.register("DataNode", "FSDatasetState-" + storageId, bean);
} catch (NotCompliantMBeanException e) {
DataNode.LOG.warn("Error registering FSDatasetState MBean", e);
}
DataNode.LOG.info("Registered FSDatasetState MBean");
}
use of javax.management.StandardMBean in project smscgateway by RestComm.
the class HttpUsersManagement method registerHttpUserMbean.
private void registerHttpUserMbean(HttpUser httpUser) {
try {
ObjectName httpUserObjNname = new ObjectName(SmscManagement.JMX_DOMAIN + ":layer=HttpUser,name=" + httpUser.getUserName());
StandardMBean httpUserMxBean = new StandardMBean(httpUser, HttpUserMBean.class, true);
if (this.mbeanServer != null)
this.mbeanServer.registerMBean(httpUserMxBean, httpUserObjNname);
} catch (InstanceAlreadyExistsException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (MBeanRegistrationException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (NotCompliantMBeanException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
} catch (MalformedObjectNameException e) {
logger.error(String.format("Error while registering MBean for HttpUser %s", httpUser.getUserName()), e);
}
}
use of javax.management.StandardMBean in project fabric8 by jboss-fuse.
the class ProfileMetadata method activate.
@Activate
void activate(Map<String, ?> configuration) throws Exception {
updateConfiguration(configuration);
activateComponent();
if (mbeanServer != null) {
StandardMBean mbean = new StandardMBean(this, ProfileMetadataMXBean.class);
JMXUtils.registerMBean(mbean, mbeanServer, OBJECT_NAME);
}
}
use of javax.management.StandardMBean in project fabric8 by jboss-fuse.
the class GitHttpServerRegistrationHandler method registerGitHttpEndpoint.
/**
* (Re)registers <code>io.fabric8:type=GitServer</code>
*/
private void registerGitHttpEndpoint() {
if (mbeanServer.getOptional() != null) {
try {
StandardMBean mbean = new StandardMBean(new io.fabric8.git.http.GitHttpEndpoint(this), GitHttpEndpointMBean.class);
unregisterGitHttpEndpoint();
mbeanServer.get().registerMBean(mbean, objectName);
} catch (Exception e) {
LOGGER.warn("Exception during " + objectName + " registration: " + e.getMessage(), e);
}
}
}
Aggregations