use of javax.management.StandardMBean 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);
}
use of javax.management.StandardMBean in project aries by apache.
the class PermissionAdminMBeanHandler method constructInjectMBean.
/**
* @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
*/
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
PermissionAdminMBean paMBean = new PermissionAdmin((org.osgi.service.permissionadmin.PermissionAdmin) targetService);
StandardMBean mbean = null;
try {
mbean = new StandardMBean(paMBean, PermissionAdminMBean.class);
} catch (NotCompliantMBeanException e) {
Logger logger = agentContext.getLogger();
logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
}
return mbean;
}
use of javax.management.StandardMBean in project aries by apache.
the class JMXAgentImpl method unregisterMBeans.
/**
* @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBeans(javax.management.MBeanServer)
*/
public synchronized void unregisterMBeans(final MBeanServer server) {
for (MBeanHandler mBeanHandler : mbeansHandlers.keySet()) {
if (mbeansHandlers.get(mBeanHandler) == Boolean.TRUE) {
try {
String name = mBeanHandler.getName();
StandardMBean mbean = mBeanHandler.getMbean();
if (mbean != null) {
logger.log(LogService.LOG_INFO, "Unregistering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
server.unregisterMBean(new ObjectName(name));
}
} catch (MBeanRegistrationException e) {
logger.log(LogService.LOG_ERROR, "Can't unregister MBean", e);
} catch (InstanceNotFoundException e) {
logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
} catch (MalformedObjectNameException e) {
logger.log(LogService.LOG_ERROR, "Try to unregister with no valid objectname", e);
} catch (NullPointerException e) {
logger.log(LogService.LOG_ERROR, "Name of objectname can't be null ", e);
} catch (Exception e) {
logger.log(LogService.LOG_ERROR, "Cannot unregister MBean: " + mBeanHandler, e);
}
}
}
mbeanServers.remove(server);
}
use of javax.management.StandardMBean 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.StandardMBean in project spring-framework by spring-projects.
the class JmxUtilsTests method isMBeanWithStandardMBeanWrapper.
@Test
void isMBeanWithStandardMBeanWrapper() throws NotCompliantMBeanException {
StandardMBean mbean = new StandardMBean(new JmxTestBean(), IJmxTestBean.class);
assertThat(JmxUtils.isMBean(mbean.getClass())).as("Standard MBean not detected correctly").isTrue();
}
Aggregations