use of javax.management.MBeanInfo 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();
}
}
use of javax.management.MBeanInfo in project Activiti by Activiti.
the class JobExecutorMBeanTest method testAnnotations.
@Test
public void testAnnotations() throws MalformedObjectNameException, JMException {
ModelMBean modelBean = assembler.assemble(jobExecutorMbean, new ObjectName("domain", "key", "value"));
assertNotNull(modelBean);
MBeanInfo beanInfo = modelBean.getMBeanInfo();
assertNotNull(beanInfo);
assertNotNull(beanInfo.getOperations());
assertEquals(2, beanInfo.getOperations().length);
int counter = 0;
for (MBeanOperationInfo op : beanInfo.getOperations()) {
if (op.getName().equals("setJobExecutorActivate")) {
counter++;
assertEquals("set job executor activate", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.Boolean", op.getSignature()[0].getType());
}
}
assertEquals(1, counter);
// check attributes
assertNotNull(beanInfo.getAttributes());
assertEquals(1, beanInfo.getAttributes().length);
counter = 0;
for (MBeanAttributeInfo attr : beanInfo.getAttributes()) {
if (attr.getName().equals("JobExecutorActivated")) {
counter++;
assertEquals("check if the job executor is activated", attr.getDescription());
assertEquals("boolean", attr.getType());
}
}
assertEquals(1, counter);
}
use of javax.management.MBeanInfo in project Activiti by Activiti.
the class ProcessDefinitionsTest method testAnnotations.
@Test
public void testAnnotations() throws MalformedObjectNameException, JMException {
ModelMBean modelBean = assembler.assemble(processDefinitionsMBean, new ObjectName("domain", "key", "value"));
assertNotNull(modelBean);
MBeanInfo beanInfo = modelBean.getMBeanInfo();
assertNotNull(beanInfo);
assertNotNull(beanInfo.getOperations());
assertEquals(9, beanInfo.getOperations().length);
int counter = 0;
for (MBeanOperationInfo op : beanInfo.getOperations()) {
if (op.getName().equals("deleteDeployment")) {
counter++;
assertEquals("delete deployment", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
} else if (op.getName().equals("suspendProcessDefinitionById")) {
counter++;
assertEquals("Suspend given process ID", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
} else if (op.getName().equals("activatedProcessDefinitionById")) {
counter++;
assertEquals("Activate given process ID", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
} else if (op.getName().equals("suspendProcessDefinitionByKey")) {
counter++;
assertEquals("Suspend given process ID", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
} else if (op.getName().equals("activatedProcessDefinitionByKey")) {
counter++;
assertEquals("Activate given process ID", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(1, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
} else if (op.getName().equals("deployProcessDefinition")) {
counter++;
assertEquals("Deploy Process Definition", op.getDescription());
assertEquals("void", op.getReturnType());
assertEquals(2, op.getSignature().length);
assertEquals("java.lang.String", op.getSignature()[0].getType());
assertEquals("java.lang.String", op.getSignature()[1].getType());
}
}
assertEquals(6, counter);
// check attributes
assertNotNull(beanInfo.getAttributes());
assertEquals(2, beanInfo.getAttributes().length);
counter = 0;
for (MBeanAttributeInfo attr : beanInfo.getAttributes()) {
if (attr.getName().equals("ProcessDefinitions")) {
counter++;
assertEquals("List of Process definitions", attr.getDescription());
assertEquals("java.util.List", attr.getType());
} else if (attr.getName().equals("Deployments")) {
counter++;
assertEquals("List of deployed Processes", attr.getDescription());
assertEquals("java.util.List", attr.getType());
}
}
assertEquals(2, counter);
}
use of javax.management.MBeanInfo 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.MBeanInfo 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;
}
Aggregations