use of javax.management.MBeanAttributeInfo in project opennms by OpenNMS.
the class QueryCommand method prettyPrint.
private void prettyPrint(QueryResult result) {
for (QueryResult.MBeanResult eachMBeanResult : result.getMBeanResults()) {
MBeanInfo mbeanInfo = eachMBeanResult.mbeanInfo;
ObjectName objectName = eachMBeanResult.objectName;
QueryResult.AttributeResult attributeResult = eachMBeanResult.attributeResult;
LOG.info(String.format("%s", objectName));
LOG.info(String.format("\tdescription: %s", toString(mbeanInfo.getDescription())));
LOG.info(String.format("\tclass name: %s", mbeanInfo.getClassName()));
LOG.info(String.format("\tattributes: (%d/%d)", attributeResult.attributes.size(), attributeResult.totalCount));
for (MBeanAttributeInfo eachAttribute : attributeResult.attributes) {
LOG.info(String.format("\t\t%s", eachAttribute.getName()));
LOG.info(String.format("\t\t\tid: %s", toAttributeId(objectName, eachAttribute)));
LOG.info(String.format("\t\t\tdescription: %s", toString(eachAttribute.getDescription())));
LOG.info(String.format("\t\t\ttype: %s", eachAttribute.getType()));
LOG.info(String.format("\t\t\tisReadable: %s", eachAttribute.isReadable()));
LOG.info(String.format("\t\t\tisWritable: %s", eachAttribute.isWritable()));
LOG.info(String.format("\t\t\tisIs: %s", eachAttribute.isIs()));
if (includeValues) {
LOG.info(String.format("\t\t\tvalue: %s", toString(attributeResult.getValue(eachAttribute))));
}
}
}
if (filter != null && !filter.isEmpty()) {
LOG.info(String.format("Your query '%s' shows %d/%d MBeans.", filter, result.getMBeanResults().size(), result.getTotalMBeanCount()));
} else {
LOG.info(String.format("There are %d registered MBeans", result.getTotalMBeanCount()));
}
if (ignoreFilter != null && !ignoreFilter.isEmpty()) {
LOG.info(String.format("While querying, the following query was used to exclude MBeans/Attributes: '%s'", ignoreFilter));
}
}
use of javax.management.MBeanAttributeInfo in project opennms by OpenNMS.
the class MBeanServerQuery method executeQuery.
private static QueryResult executeQuery(List<FilterCriteria> filterCriteriaList, MBeanServerConnection mbeanServerConnection) throws IOException, JMException {
QueryResult result = new QueryResult();
for (FilterCriteria eachFilterCriteria : filterCriteriaList) {
ObjectName query = eachFilterCriteria.objectName != null ? new ObjectName(eachFilterCriteria.objectName) : null;
Set<ObjectName> tmpObjectNames = mbeanServerConnection.queryNames(query, null);
// Now we filter the MBeans attributes (Default: show all)
for (ObjectName eachObjectName : tmpObjectNames) {
MBeanInfo mbeanInfo = mbeanServerConnection.getMBeanInfo(eachObjectName);
result.put(eachObjectName, mbeanInfo);
result.setAttributeTotalCount(eachObjectName, mbeanInfo.getAttributes().length);
for (MBeanAttributeInfo eachAttribute : mbeanInfo.getAttributes()) {
if (eachFilterCriteria.matches(eachAttribute)) {
result.put(eachObjectName, eachAttribute);
}
}
}
}
return result;
}
use of javax.management.MBeanAttributeInfo in project Entitas-Java by Rubentxu.
the class VisualDebbuger method start.
@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("VisualDebbuger.fxml"));
Parent root = loader.load();
primaryStage.setTitle("CodeGenerator");
primaryStage.setScene(new Scene(root, 560, 575));
primaryStage.setResizable(false);
primaryStage.show();
stage = primaryStage;
client = new JmxClient("localhost", 1313);
Set<ObjectName> names = client.getBeanNames();
beanNames.setText(names.stream().map(n -> n.getKeyPropertyListString()).reduce(String::concat).get());
// MBeanAttributeInfo[] attributeInfos =
// client.getAttributesInfo(objectName);
// MBeanOperationInfo[] operationInfos =
// client.getOperationsInfo(objectName);
}
use of javax.management.MBeanAttributeInfo in project tdi-studio-se by Talend.
the class AttributeContentProvider method refresh.
/**
* Refreshes the content provider.
*
* @param jvm The JVM
* @param objectName The object name
* @throws JvmCoreException
*/
protected void refresh(IActiveJvm jvm, ObjectName objectName) throws JvmCoreException {
MBeanInfo mBeanInfo = null;
List<AttributeNode> nodes = new ArrayList<AttributeNode>();
try {
mBeanInfo = jvm.getMBeanServer().getMBeanInfo(objectName);
} catch (JvmCoreException e) {
attributeRootNodes = nodes;
throw e;
}
if (mBeanInfo == null) {
attributeRootNodes = nodes;
return;
}
AttributeParser parser = new AttributeParser();
for (MBeanAttributeInfo attributeInfo : mBeanInfo.getAttributes()) {
String name = attributeInfo.getName();
Object value = getAttributeValue(jvm, objectName, name);
AttributeNode attributeNode = null;
for (AttributeNode node : attributeRootNodes) {
if (node.getName().equals(name)) {
attributeNode = node;
attributeNode.setValue(value);
break;
}
}
if (attributeNode == null) {
attributeNode = new AttributeNode(name, null, value);
}
parser.refreshAttribute(attributeNode);
attributeNode.setWritable(attributeInfo.isWritable());
nodes.add(attributeNode);
}
Collections.sort(nodes, new Comparator<AttributeNode>() {
@Override
public int compare(AttributeNode o1, AttributeNode o2) {
return o1.getName().compareTo(o2.getName());
}
});
attributeRootNodes = nodes;
}
use of javax.management.MBeanAttributeInfo in project tesb-studio-se by Talend.
the class OpenRuntimeInfoAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
MBeanServerConnection mbsc;
try {
mbsc = JMXUtil.createJMXconnection();
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
//$NON-NLS-1$
String JOB_MBEAN = "TalendAgent:type=O.S. Informations";
ObjectName objectJob = new ObjectName(JOB_MBEAN);
MBeanInfo info = mbsc.getMBeanInfo(objectJob);
MBeanAttributeInfo[] attrInfo = info.getAttributes();
for (int i = 0; i < attrInfo.length; i++) {
try {
Map<String, String> attributeMap = new HashMap<String, String>();
String attributeName = attrInfo[i].getName();
//$NON-NLS-1$
attributeMap.put("name", attributeName);
String attributeDesc = attrInfo[i].getType();
//$NON-NLS-1$
attributeMap.put("desc", attributeDesc);
String attributeValue = mbsc.getAttribute(objectJob, attributeName).toString();
attributeMap.put(attributeName, attributeValue);
//$NON-NLS-1$
attributeMap.put("value", attributeValue);
list.add(attributeMap);
} catch (Exception e) {
e.printStackTrace();
}
}
RuntimeInfoDialog dlg = new RuntimeInfoDialog(list);
dlg.open();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations