use of javax.management.MBeanConstructorInfo in project felix by apache.
the class MBeanIntrospector method createMBeanConstructorInfo.
private MBeanConstructorInfo[] createMBeanConstructorInfo(MBeanMetaData metadata, MBeanDescription descrs) {
Class mbeanClass = metadata.mbean.getClass();
Constructor[] ctors = mbeanClass.getConstructors();
MBeanConstructorInfo[] constructors = new MBeanConstructorInfo[ctors.length];
for (int i = 0; i < ctors.length; ++i) {
Constructor constructor = ctors[i];
String descr = descrs == null ? null : descrs.getConstructorDescription(constructor);
Class[] params = constructor.getParameterTypes();
MBeanParameterInfo[] paramsInfo = new MBeanParameterInfo[params.length];
for (int j = 0; j < params.length; ++j) {
Class param = params[j];
String paramName = descrs == null ? null : descrs.getConstructorParameterName(constructor, j);
String paramDescr = descrs == null ? null : descrs.getConstructorParameterDescription(constructor, j);
paramsInfo[j] = new MBeanParameterInfo(paramName, param.getName(), paramDescr);
}
String ctorName = constructor.getName();
MBeanConstructorInfo info = new MBeanConstructorInfo(ctorName.substring(ctorName.lastIndexOf('.') + 1), descr, paramsInfo);
constructors[i] = info;
}
return constructors;
}
use of javax.management.MBeanConstructorInfo in project jdk8u_jdk by JetBrains.
the class MBeanIntrospector method findConstructors.
private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
Constructor<?>[] cons = c.getConstructors();
MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
for (int i = 0; i < cons.length; i++) {
final String descr = "Public constructor of the MBean";
mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
}
return mbc;
}
use of javax.management.MBeanConstructorInfo in project Payara by payara.
the class MBeanConstructorInfoStringifier method stringify.
@Override
public String stringify(Object o) {
final MBeanConstructorInfo constructor = (MBeanConstructorInfo) o;
final String name = constructor.getName();
final int lastDot = name.lastIndexOf('.');
final String abbreviatedName = name.substring(lastDot + 1, name.length());
final String params = "(" + paramsToString(constructor.getSignature(), mOptions) + ")";
return (abbreviatedName + params);
}
use of javax.management.MBeanConstructorInfo in project tomcat by apache.
the class ManagedBean method getMBeanInfo.
/**
* Create and return a <code>ModelMBeanInfo</code> object that
* describes this entire managed bean.
* @return the MBean info
*/
MBeanInfo getMBeanInfo() {
// Return our cached information (if any)
mBeanInfoLock.readLock().lock();
try {
if (info != null) {
return info;
}
} finally {
mBeanInfoLock.readLock().unlock();
}
mBeanInfoLock.writeLock().lock();
try {
if (info == null) {
// Create subordinate information descriptors as required
AttributeInfo[] attrs = getAttributes();
MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[attrs.length];
for (int i = 0; i < attrs.length; i++) {
attributes[i] = attrs[i].createAttributeInfo();
}
OperationInfo[] opers = getOperations();
MBeanOperationInfo[] operations = new MBeanOperationInfo[opers.length];
for (int i = 0; i < opers.length; i++) {
operations[i] = opers[i].createOperationInfo();
}
NotificationInfo[] notifs = getNotifications();
MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[notifs.length];
for (int i = 0; i < notifs.length; i++) {
notifications[i] = notifs[i].createNotificationInfo();
}
// Construct and return a new ModelMBeanInfo object
info = new MBeanInfo(getClassName(), getDescription(), attributes, new MBeanConstructorInfo[] {}, operations, notifications);
}
return info;
} finally {
mBeanInfoLock.writeLock().unlock();
}
}
use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.
the class TestLoggingMXBean method testGetMBeanInfo.
@Test
public final void testGetMBeanInfo() {
MBeanInfo mbi;
try {
mbi = mbs.getMBeanInfo(objName);
} catch (InstanceNotFoundException e) {
Assert.fail("Unexpected InstanceNotFoundException: " + e.getMessage());
return;
} catch (ReflectionException e) {
Assert.fail("Unexpected ReflectionException: " + e.getMessage());
return;
} catch (IntrospectionException e) {
Assert.fail("Unexpected IntrospectionException: " + e.getMessage());
return;
}
AssertJUnit.assertNotNull(mbi);
// Now make sure that what we got back is what we expected.
// Class name
AssertJUnit.assertEquals(lb.getClass().getName(), mbi.getClassName());
// No public constructors
MBeanConstructorInfo[] constructors = mbi.getConstructors();
AssertJUnit.assertNotNull(constructors);
AssertJUnit.assertEquals(0, constructors.length);
// Three public operations
MBeanOperationInfo[] operations = mbi.getOperations();
AssertJUnit.assertNotNull(operations);
AssertJUnit.assertEquals(3, operations.length);
// No notifications
MBeanNotificationInfo[] notifications = mbi.getNotifications();
AssertJUnit.assertNotNull(notifications);
AssertJUnit.assertEquals(0, notifications.length);
// Print out the description here.
logger.debug("MBean description for " + lb.getClass().getName() + ": " + mbi.getDescription());
// One attribute - not writable.
MBeanAttributeInfo[] attributes = mbi.getAttributes();
AssertJUnit.assertNotNull(attributes);
AssertJUnit.assertEquals(2, attributes.length);
for (MBeanAttributeInfo attribute : attributes) {
String attributeName = attribute.getName();
String attributeType = attribute.getType();
switch(attributeName) {
case "LoggerNames":
AssertJUnit.assertEquals(String[].class.getName(), attributeType);
break;
case "ObjectName":
AssertJUnit.assertEquals(ObjectName.class.getName(), attributeType);
break;
default:
Assert.fail("Unexpected attribute: " + attributeName + " of type " + attributeType);
break;
}
AssertJUnit.assertTrue(attribute.isReadable());
AssertJUnit.assertFalse(attribute.isWritable());
}
}
Aggregations