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);
}
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;
}
}
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);
}
}
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);
}
}
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);
}
Aggregations