Search in sources :

Example 6 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project redisson by redisson.

the class JCacheManager method enableManagement.

@Override
public void enableManagement(String cacheName, boolean enabled) {
    checkNotClosed();
    if (cacheName == null) {
        throw new NullPointerException();
    }
    JCache<?, ?> cache = caches.get(cacheName);
    if (cache == null) {
        throw new NullPointerException();
    }
    if (enabled) {
        JCacheManagementMXBean statBean = managementBeans.get(cache);
        if (statBean == null) {
            statBean = new JCacheManagementMXBean(cache);
            JCacheManagementMXBean oldBean = managementBeans.putIfAbsent(cache, statBean);
            if (oldBean != null) {
                statBean = oldBean;
            }
        }
        try {
            ObjectName objectName = queryNames("Configuration", cache);
            if (mBeanServer.queryNames(objectName, null).isEmpty()) {
                mBeanServer.registerMBean(statBean, objectName);
            }
        } catch (MalformedObjectNameException e) {
            throw new CacheException(e);
        } catch (InstanceAlreadyExistsException e) {
            throw new CacheException(e);
        } catch (MBeanRegistrationException e) {
            throw new CacheException(e);
        } catch (NotCompliantMBeanException e) {
            throw new CacheException(e);
        }
    } else {
        unregisterManagementBean(cache);
    }
    cache.getConfiguration(JCacheConfiguration.class).setManagementEnabled(enabled);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) JCacheConfiguration(org.redisson.jcache.configuration.JCacheConfiguration) CacheException(javax.cache.CacheException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) JCacheManagementMXBean(org.redisson.jcache.bean.JCacheManagementMXBean) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 7 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project aries by apache.

the class MBeanHolder method create.

static <T> MBeanHolder create(final T mbean, final ObjectName requestedObjectName) {
    if (mbean instanceof DynamicMBean) {
        return new MBeanHolder(mbean, requestedObjectName);
    } else if (mbean == null) {
        return null;
    }
    Class<?> mbeanClass = mbean.getClass();
    // This is all in aid of getting new StandardMBean to work.
    @SuppressWarnings("unchecked") Class<T> mbeanInterface = (Class<T>) getMBeanInterface(mbeanClass);
    if (mbeanInterface == null) {
        return null;
    }
    if (mbeanInterface.getName().equals(mbeanClass.getName().concat("MBean")) || mbeanInterface.getName().equals(mbeanClass.getName().concat("MXBean"))) {
        return new MBeanHolder(mbean, requestedObjectName);
    }
    try {
        StandardMBean stdMbean = new RegistrableStandardEmitterMBean(mbean, mbeanInterface);
        return new MBeanHolder(stdMbean, requestedObjectName);
    } catch (NotCompliantMBeanException e) {
        LoggerFactory.getLogger(MBeanHolder.class).error("create: Cannot create StandardMBean for " + mbean + " of type " + mbeanClass + " for interface " + mbeanInterface, e);
        return null;
    }
}
Also used : DynamicMBean(javax.management.DynamicMBean) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RegistrableStandardEmitterMBean(org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)

Example 8 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project aries by apache.

the class Activator method registerMBeans.

protected void registerMBeans(MBeanServer mbeanServer) {
    // register BlueprintStateMBean to MBean server
    LOGGER.debug("Registering bundle state monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintStateName);
    try {
        StandardMBean blueprintState = new RegistrableStandardEmitterMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
        mbeanServer.registerMBean(blueprintState, blueprintStateName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintStateMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    }
    // register BlueprintMetadataMBean to MBean server
    LOGGER.debug("Registering bundle metadata monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintMetadataName);
    try {
        StandardMBean blueprintMetadata = new StandardMBean(new BlueprintMetadata(bundleContext), BlueprintMetadataMBean.class);
        mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintMetadataMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 9 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project aries by apache.

the class MBeanHolder method register.

void register(final MBeanServer server) {
    ObjectInstance instance;
    try {
        instance = server.registerMBean(mbean, requestedObjectName);
        registrations.put(server, instance.getObjectName());
    } catch (InstanceAlreadyExistsException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (MBeanRegistrationException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (NotCompliantMBeanException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectInstance(javax.management.ObjectInstance) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 10 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException in project aries by apache.

the class PackageStateMBeanHandler method open.

/**
     * @see org.apache.aries.jmx.MBeanHandler#open()
     */
public void open() {
    ServiceReference adminRef = context.getServiceReference(PackageAdmin.class.getCanonicalName());
    PackageAdmin packageAdmin = (PackageAdmin) context.getService(adminRef);
    PackageStateMBean packageState = new PackageState(context, packageAdmin);
    try {
        mbean = new StandardMBean(packageState, PackageStateMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
    }
    agentContext.registerMBean(this);
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) PackageStateMBean(org.osgi.jmx.framework.PackageStateMBean) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

NotCompliantMBeanException (javax.management.NotCompliantMBeanException)58 ObjectName (javax.management.ObjectName)37 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)29 MBeanRegistrationException (javax.management.MBeanRegistrationException)29 MBeanServer (javax.management.MBeanServer)26 MalformedObjectNameException (javax.management.MalformedObjectNameException)24 StandardMBean (javax.management.StandardMBean)15 InstanceNotFoundException (javax.management.InstanceNotFoundException)9 MBeanException (javax.management.MBeanException)5 ReflectionException (javax.management.ReflectionException)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 Logger (org.apache.aries.jmx.Logger)4 RegistrableStandardEmitterMBean (org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)4 IntrospectionException (javax.management.IntrospectionException)3 JMRuntimeException (javax.management.JMRuntimeException)3 ObjectInstance (javax.management.ObjectInstance)3 RuntimeOperationsException (javax.management.RuntimeOperationsException)3 PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)3 IOException (java.io.IOException)2