use of javax.management.StandardMBean in project tomcat by apache.
the class BasicDataSource method jmxRegister.
private void jmxRegister() {
// Return immediately if this DataSource has already been registered
if (registeredJmxObjectName != null) {
return;
}
// Return immediately if no JMX name has been specified
final String requestedName = getJmxName();
if (requestedName == null) {
return;
}
registeredJmxObjectName = registerJmxObjectName(requestedName, null);
try {
final StandardMBean standardMBean = new StandardMBean(this, DataSourceMXBean.class);
registeredJmxObjectName.registerMBean(standardMBean);
} catch (final NotCompliantMBeanException e) {
log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored.");
}
}
use of javax.management.StandardMBean 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.StandardMBean in project aries by apache.
the class ProvisioningServiceMBeanHandlerTest method testConstructInjectMBean.
@Test
public void testConstructInjectMBean() {
BundleContext bundleContext = mock(BundleContext.class);
Logger agentLogger = mock(Logger.class);
JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger);
ProvisioningService provService = mock(ProvisioningService.class);
ProvisioningServiceMBeanHandler handler = new ProvisioningServiceMBeanHandler(agentContext);
StandardMBean mbean = handler.constructInjectMBean(provService);
assertNotNull(mbean);
}
use of javax.management.StandardMBean in project aries by apache.
the class UserAdminMBeanHandler method constructInjectMBean.
/**
* @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
*/
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
UserAdminMBean uaMBean = new UserAdmin((org.osgi.service.useradmin.UserAdmin) targetService);
StandardMBean mbean = null;
try {
mbean = new StandardMBean(uaMBean, UserAdminMBean.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 ConfigurationAdminMBeanHandlerTest method testConstructInjectMBean.
@Test
public void testConstructInjectMBean() {
BundleContext bundleContext = mock(BundleContext.class);
Logger agentLogger = mock(Logger.class);
JMXAgentContext agentContext = new JMXAgentContext(bundleContext, null, agentLogger);
ConfigurationAdmin cAdmin = mock(ConfigurationAdmin.class);
ConfigurationAdminMBeanHandler handler = new ConfigurationAdminMBeanHandler(agentContext);
StandardMBean mbean = handler.constructInjectMBean(cAdmin);
assertNotNull(mbean);
}
Aggregations