Search in sources :

Example 16 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project archaius by Netflix.

the class ConfigJMXManager method getJMXObjectName.

private static ObjectName getJMXObjectName(AbstractConfiguration config, ConfigMBean bean) throws Exception {
    try {
        Class<? extends ConfigMBean> c = bean.getClass();
        String className = c.getName();
        int lastDot = className.lastIndexOf('.');
        ObjectName name = new ObjectName("Config-" + className.substring(0, lastDot) + ":class=" + className.substring(lastDot + 1));
        return name;
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException("MalformedObjectNameException", e);
    } catch (NullPointerException e) {
        throw new RuntimeException("NullPointerException", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 17 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project quasar by puniverse.

the class JMXActorMonitor method unregisterMBean.

public void unregisterMBean() {
    try {
        if (registered) {
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name));
            MonitoringServices.getInstance().removePerfNotificationListener(this);
        }
        this.registered = false;
    } catch (InstanceNotFoundException | MBeanRegistrationException | MalformedObjectNameException ex) {
        ex.printStackTrace();
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 18 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project quasar by puniverse.

the class JMXFibersMonitor method unregister.

@SuppressWarnings({ "CallToPrintStackTrace", "CallToThreadDumpStack" })
@Override
public void unregister() {
    try {
        if (registered) {
            MonitoringServices.getInstance().removePerfNotificationListener(this);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(mbeanName));
        }
        this.registered = false;
    } catch (InstanceNotFoundException ex) {
        ex.printStackTrace();
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 19 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project quasar by puniverse.

the class SimpleMBean method registerMBean.

protected void registerMBean() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName mxbeanName = new ObjectName(name);
        mbs.registerMBean(this, mxbeanName);
        this.registered = true;
    } catch (InstanceAlreadyExistsException ex) {
        throw new RuntimeException(ex);
    } catch (MBeanRegistrationException ex) {
        ex.printStackTrace();
    } catch (NotCompliantMBeanException ex) {
        throw new AssertionError(ex);
    } catch (MalformedObjectNameException ex) {
        throw new AssertionError(ex);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 20 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException 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)

Aggregations

MalformedObjectNameException (javax.management.MalformedObjectNameException)123 ObjectName (javax.management.ObjectName)115 MBeanServer (javax.management.MBeanServer)34 MBeanRegistrationException (javax.management.MBeanRegistrationException)32 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)27 InstanceNotFoundException (javax.management.InstanceNotFoundException)26 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)25 IOException (java.io.IOException)22 ArrayList (java.util.ArrayList)14 MBeanException (javax.management.MBeanException)7 ReflectionException (javax.management.ReflectionException)7 HashMap (java.util.HashMap)6 StandardMBean (javax.management.StandardMBean)5 CacheServiceMBean (org.apache.cassandra.service.CacheServiceMBean)5 Map (java.util.Map)4 HashSet (java.util.HashSet)3 CacheException (javax.cache.CacheException)3 Group (org.apache.catalina.Group)3 User (org.apache.catalina.User)3 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)3