Search in sources :

Example 26 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project caffeine by ben-manes.

the class JmxRegistration method getObjectName.

/** Returns the object name of the management bean. */
private static ObjectName getObjectName(Cache<?, ?> cache, MBeanType type) {
    String cacheManagerName = sanitize(cache.getCacheManager().getURI().toString());
    String cacheName = sanitize(cache.getName());
    try {
        String name = String.format("javax.cache:type=Cache%s,CacheManager=%s,Cache=%s", type, cacheManagerName, cacheName);
        return new ObjectName(name);
    } catch (MalformedObjectNameException e) {
        String msg = String.format("Illegal ObjectName for cacheManager=[%s], cache=[%s]", cacheManagerName, cacheName);
        throw new CacheException(msg, e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CacheException(javax.cache.CacheException) ObjectName(javax.management.ObjectName)

Example 27 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project hazelcast by hazelcast.

the class MXBeanUtil method calculateObjectName.

/**
     * Creates an object name using the scheme.
     * "javax.cache:type=Cache&lt;Statistics|Configuration&gt;,name=&lt;cacheName&gt;"
     */
public static ObjectName calculateObjectName(String cacheManagerName, String name, boolean stats) {
    String cacheManagerNameSafe = mbeanSafe(cacheManagerName);
    String cacheName = mbeanSafe(name);
    try {
        String objectNameType = stats ? "Statistics" : "Configuration";
        return new ObjectName("javax.cache:type=Cache" + objectNameType + ",CacheManager=" + cacheManagerNameSafe + ",Cache=" + cacheName);
    } catch (MalformedObjectNameException e) {
        throw new CacheException("Illegal ObjectName for Management Bean. " + "CacheManager=[" + cacheManagerNameSafe + "], Cache=[" + cacheName + "]", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CacheException(javax.cache.CacheException) ObjectName(javax.management.ObjectName)

Example 28 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project ORCID-Source by ORCID.

the class OrcidEhcacheManagementService method createObjectName.

static ObjectName createObjectName(net.sf.ehcache.CacheManager cacheManager) {
    ObjectName objectName;
    try {
        int hashCode = OrcidEhcacheManagementService.class.getClassLoader().hashCode();
        String suffix = "_" + hashCode;
        String safeCacheManagerName = EhcacheHibernateMbeanNames.mbeanSafe(cacheManager.getName() + suffix);
        LOGGER.info("Cache manager name = {}", safeCacheManagerName);
        cacheManager.setName(safeCacheManagerName);
        objectName = new ObjectName("net.sf.ehcache:type=CacheManager,name=" + safeCacheManagerName);
    } catch (MalformedObjectNameException e) {
        throw new CacheException(e);
    }
    return objectName;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) CacheException(net.sf.ehcache.CacheException) ObjectName(javax.management.ObjectName)

Example 29 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project opennms by OpenNMS.

the class JmxDaemonStatusDao method getServiceHandle.

/** {@inheritDoc} */
@Override
public ServiceDaemon getServiceHandle(String service) {
    Set<ObjectName> mBeanNames;
    try {
        mBeanNames = queryMbeanServerForNames(new ObjectName("opennms:Name=" + service + ",*"), null);
    } catch (MalformedObjectNameException e) {
        throw new JmxObjectNameException("Object name 'opennms:Name=" + service + ",*' was malformed!", e);
    } catch (NullPointerException e) {
        throw new JmxObjectNameException("Object name param is null.", e);
    }
    ObjectName mBeanName = (ObjectName) DataAccessUtils.requiredUniqueResult(mBeanNames);
    return buildProxy(mBeanName);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 30 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project opennms by OpenNMS.

the class JmxDaemonStatusDao method buildProxy.

private ServiceDaemon buildProxy(ObjectName mBeanName) {
    MBeanProxyFactoryBean mBeanProxyFactoryBean = new MBeanProxyFactoryBean();
    try {
        mBeanProxyFactoryBean.setObjectName(mBeanName.getCanonicalName());
    } catch (MalformedObjectNameException e) {
        throw new JmxObjectNameException("Object name '" + mBeanName.getCanonicalName() + "' was malformed!", e);
    }
    mBeanProxyFactoryBean.setProxyInterface(ServiceDaemon.class);
    mBeanProxyFactoryBean.afterPropertiesSet();
    return (ServiceDaemon) mBeanProxyFactoryBean.getObject();
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanProxyFactoryBean(org.springframework.jmx.access.MBeanProxyFactoryBean) ServiceDaemon(org.opennms.netmgt.model.ServiceDaemon)

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