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);
}
}
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<Statistics|Configuration>,name=<cacheName>"
*/
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);
}
}
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;
}
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);
}
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();
}
Aggregations