use of javax.management.MBeanInfo in project Payara by payara.
the class ToolsImpl method info.
public String info(final Collection<ObjectName> objectNames) {
final Set<String> alreadyDone = new HashSet<String>();
final StringBuffer buf = new StringBuffer();
if (objectNames.size() != 0) {
final String NL = StringUtil.NEWLINE();
for (final ObjectName objectName : objectNames) {
final MBeanInfo mbeanInfo = getProxyFactory().getMBeanInfo(objectName);
if (mbeanInfo == null) {
continue;
}
// Don't generate info if we've seen that type/class combination already
final String type = Util.getTypeProp(objectName);
final String classname = mbeanInfo.getClassName();
if (alreadyDone.contains(type) && alreadyDone.contains(classname)) {
continue;
}
alreadyDone.add(type);
alreadyDone.add(classname);
buf.append("MBeanInfo for " + objectName + NL);
// buf.append(JMXUtil.toString(mbeanInfo) + NL + NL );
buf.append(java(objectName));
buf.append(NL + NL + NL + NL);
}
}
buf.append("Matched " + objectNames.size() + " mbean(s).");
return buf.toString();
}
use of javax.management.MBeanInfo in project Payara by payara.
the class MBeanInfoStringifier method stringify.
public String stringify(Object o) {
String result = "";
final MBeanInfo info = (MBeanInfo) o;
final MBeanOperationInfo[] operations = info.getOperations();
final MBeanAttributeInfo[] attributes = info.getAttributes();
final MBeanConstructorInfo[] constructors = info.getConstructors();
final MBeanNotificationInfo[] notifications = info.getNotifications();
final String description = info.getDescription();
result = "Summary: " + operations.length + " operations, " + attributes.length + " attributes, " + constructors.length + " constructors, " + notifications.length + " notifications" + (description == null ? "" : ", \"" + description + "\"");
final MBeanFeatureInfoStringifierOptions options = new MBeanFeatureInfoStringifierOptions(true, ",");
// Do formal terms like "Attributes" need to be I18n?
// Probabably not as they are part of a specification.
result = result + "\n\n- Attributes -" + stringifyArray(attributes, getMBeanAttributeInfoStringifier(options));
result = result + "\n\n- Operations -" + stringifyArray(operations, getMBeanOperationInfoStringifier(options));
result = result + "\n\n- Constructors -" + stringifyArray(constructors, getMBeanConstructorInfoStringifier(options));
result = result + "\n\n- Notifications -" + stringifyArray(notifications, getMBeanNotificationInfoStringifier(options));
return (result);
}
use of javax.management.MBeanInfo in project Payara by payara.
the class ConfigBeanJMXSupport method getDefaultValues.
public Map<String, String> getDefaultValues(final boolean useAttributeNames) {
final Map<String, String> m = new HashMap<String, String>();
final MBeanInfo info = getMBeanInfo();
for (final MBeanAttributeInfo attrInfo : info.getAttributes()) {
final String defaultValue = defaultValue(attrInfo);
// emit values that exist (only); null is of no use.
if (defaultValue != null) {
final String attrName = attrInfo.getName();
final String name = useAttributeNames ? attrName : xmlName(attrInfo, attrName);
m.put(name, defaultValue);
}
}
return m;
}
use of javax.management.MBeanInfo in project Payara by payara.
the class ConfigBeanJMXSupport method _getMBeanInfo.
private MBeanInfo _getMBeanInfo() {
final List<MBeanAttributeInfo> attrsList = new ArrayList<MBeanAttributeInfo>();
for (final AttributeMethodInfo info : mAttrInfos) {
attrsList.add(attributeToMBeanAttributeInfo(info));
}
for (final ElementMethodInfo e : mElementInfos) {
final MBeanAttributeInfo attrInfo = elementToMBeanAttributeInfo(e.method());
if (attrInfo != null) {
attrsList.add(attrInfo);
}
}
final MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[attrsList.size()];
attrsList.toArray(attrs);
final String classname = mIntf.getName();
final String description = "ConfigBean " + mIntf.getName();
final MBeanOperationInfo[] operations = toMBeanOperationInfos();
final Descriptor descriptor = descriptor();
final MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[] { ATTRIBUTE_CHANGE_NOTIF_INFO };
final MBeanInfo info = new MBeanInfo(classname, description, attrs, null, operations, notifications, descriptor);
return info;
}
use of javax.management.MBeanInfo in project Payara by payara.
the class ConfigBeanJMXSupport method getFromXMLNameMapping.
/**
* Return a Map from the xml name to the Attribute name.
*/
public Map<String, String> getFromXMLNameMapping() {
final Map<String, String> m = new HashMap<String, String>();
final MBeanInfo info = getMBeanInfo();
for (final MBeanAttributeInfo attrInfo : info.getAttributes()) {
m.put(xmlName(attrInfo, attrInfo.getName()), attrInfo.getName());
}
return m;
}
Aggregations