Search in sources :

Example 51 with StandardMBean

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;
    }
}
Also used : StandardMBean(javax.management.StandardMBean) MBeanPermission(javax.management.MBeanPermission) PrivateClassLoader(javax.management.loading.PrivateClassLoader) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 52 with StandardMBean

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");
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) FSDatasetMBean(org.apache.hadoop.hdfs.server.datanode.metrics.FSDatasetMBean)

Example 53 with StandardMBean

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);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 54 with StandardMBean

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);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) Activate(org.apache.felix.scr.annotations.Activate)

Example 55 with StandardMBean

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);
        }
    }
}
Also used : StandardMBean(javax.management.StandardMBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException)

Aggregations

StandardMBean (javax.management.StandardMBean)70 ObjectName (javax.management.ObjectName)32 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)21 MBeanServer (javax.management.MBeanServer)17 MalformedObjectNameException (javax.management.MalformedObjectNameException)16 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)12 MBeanRegistrationException (javax.management.MBeanRegistrationException)9 Test (org.junit.Test)9 JMException (javax.management.JMException)7 IOException (java.io.IOException)6 Logger (org.apache.aries.jmx.Logger)6 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 Activate (org.apache.felix.scr.annotations.Activate)5 IgniteStandardMXBean (org.apache.ignite.internal.mxbean.IgniteStandardMXBean)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 MBeanInfo (javax.management.MBeanInfo)4 OpenDataException (javax.management.openmbean.OpenDataException)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)3 CompositeType (javax.management.openmbean.CompositeType)3 OpenType (javax.management.openmbean.OpenType)3