use of javax.management.MBeanInfo in project jdk8u_jdk by JetBrains.
the class MXBeanInteropTest1 method doOperatingSystemMXBeanTest.
private final int doOperatingSystemMXBeanTest(MBeanServerConnection mbsc) {
int errorCount = 0;
System.out.println("---- OperatingSystemMXBean");
try {
ObjectName operationName = new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
MBeanInfo mbInfo = mbsc.getMBeanInfo(operationName);
errorCount += checkNonEmpty(mbInfo);
System.out.println("getMBeanInfo\t\t" + mbInfo);
OperatingSystemMXBean operation = null;
operation = JMX.newMXBeanProxy(mbsc, operationName, OperatingSystemMXBean.class);
System.out.println("getArch\t\t" + operation.getArch());
System.out.println("getAvailableProcessors\t\t" + operation.getAvailableProcessors());
System.out.println("getName\t\t" + operation.getName());
System.out.println("getVersion\t\t" + operation.getVersion());
System.out.println("---- OK\n");
} catch (Exception e) {
Utils.printThrowable(e, true);
errorCount++;
System.out.println("---- ERROR\n");
}
return errorCount;
}
use of javax.management.MBeanInfo in project wildfly by wildfly.
the class LogStoreProbeHandler method getMBeanValues.
private Map<String, String> getMBeanValues(MBeanServerConnection cnx, ObjectName on, String... attributeNames) throws InstanceNotFoundException, IOException, ReflectionException, IntrospectionException {
if (attributeNames == null) {
MBeanInfo info = cnx.getMBeanInfo(on);
MBeanAttributeInfo[] attributeArray = info.getAttributes();
int i = 0;
attributeNames = new String[attributeArray.length];
for (MBeanAttributeInfo ai : attributeArray) attributeNames[i++] = ai.getName();
}
AttributeList attributes = cnx.getAttributes(on, attributeNames);
Map<String, String> values = new HashMap<String, String>();
for (javax.management.Attribute attribute : attributes.asList()) {
Object value = attribute.getValue();
values.put(attribute.getName(), value == null ? "" : value.toString());
}
return values;
}
use of javax.management.MBeanInfo in project aries by apache.
the class RegistrableStandardEmitterMBean method getMBeanInfo.
/**
* @see javax.management.StandardMBean#getMBeanInfo()
*/
public MBeanInfo getMBeanInfo() {
MBeanInfo mbeanInfo = super.getMBeanInfo();
if (mbeanInfo != null) {
MBeanNotificationInfo[] notificationInfo;
Object impl = getImplementation();
if (impl instanceof NotificationEmitter) {
notificationInfo = ((NotificationEmitter) (impl)).getNotificationInfo();
} else {
notificationInfo = new MBeanNotificationInfo[0];
}
mbeanInfo = new MBeanInfo(mbeanInfo.getClassName(), mbeanInfo.getDescription(), mbeanInfo.getAttributes(), mbeanInfo.getConstructors(), mbeanInfo.getOperations(), notificationInfo);
}
return mbeanInfo;
}
use of javax.management.MBeanInfo in project lucene-solr by apache.
the class MetricsMap method getMBeanInfo.
@Override
public MBeanInfo getMBeanInfo() {
ArrayList<MBeanAttributeInfo> attrInfoList = new ArrayList<>();
Map<String, Object> stats = getValue(true);
if (useCachedStatsBetweenGetMBeanInfoCalls) {
cachedValue = stats;
}
try {
stats.forEach((k, v) -> {
Class type = v.getClass();
OpenType typeBox = determineType(type);
if (type.equals(String.class) || typeBox == null) {
attrInfoList.add(new MBeanAttributeInfo(k, String.class.getName(), null, true, false, false));
} else {
attrInfoList.add(new OpenMBeanAttributeInfoSupport(k, k, typeBox, true, false, false));
}
});
} catch (Exception e) {
// don't log issue if the core is closing
if (!(SolrException.getRootCause(e) instanceof AlreadyClosedException))
log.warn("Could not get attributes of MetricsMap: {}", this, e);
}
MBeanAttributeInfo[] attrInfoArr = attrInfoList.toArray(new MBeanAttributeInfo[attrInfoList.size()]);
return new MBeanInfo(getClass().getName(), "MetricsMap", attrInfoArr, null, null, null);
}
use of javax.management.MBeanInfo in project jackrabbit-oak by apache.
the class AnnotatedStandardMBeanTest method test.
@Test
public void test() throws Exception {
MBeanInfo info = server.getMBeanInfo(objectName);
assertEquals("MBean desc.", info.getDescription());
MBeanAttributeInfo a0 = findAttribute(info, "Getter");
assertEquals("getter", a0.getDescription());
MBeanAttributeInfo a1 = findAttribute(info, "It");
assertEquals("is", a1.getDescription());
MBeanAttributeInfo a2 = findAttribute(info, "Setter");
assertEquals("setter", a2.getDescription());
MBeanOperationInfo op0 = info.getOperations()[0];
assertEquals("run", op0.getDescription());
assertEquals(MBeanOperationInfo.INFO, op0.getImpact());
MBeanParameterInfo p0 = op0.getSignature()[0];
assertEquals("timeout", p0.getName());
assertEquals("how long?", p0.getDescription());
}
Aggregations