Search in sources :

Example 81 with MBeanAttributeInfo

use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.

the class InterfaceBasedMBeanInfoAssemblerMappedTests method testNickNameIsExposed.

@Test
public void testNickNameIsExposed() throws Exception {
    ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
    MBeanAttributeInfo attr = inf.getAttribute("NickName");
    assertNickName(attr);
}
Also used : ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 82 with MBeanAttributeInfo

use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.

the class InterfaceBasedMBeanInfoAssemblerMappedTests method testWithFallThrough.

@Test
public void testWithFallThrough() throws Exception {
    InterfaceBasedMBeanInfoAssembler assembler = getWithMapping("foobar", "org.springframework.jmx.export.assembler.ICustomJmxBean");
    assembler.setManagedInterfaces(new Class<?>[] { IAdditionalTestMethods.class });
    ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
    MBeanAttributeInfo attr = inf.getAttribute("NickName");
    assertNickName(attr);
}
Also used : ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 83 with MBeanAttributeInfo

use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.

the class MethodExclusionMBeanInfoAssemblerMappedTests method testNickNameIsExposed.

@Test
public void testNickNameIsExposed() throws Exception {
    ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
    MBeanAttributeInfo attr = inf.getAttribute("NickName");
    assertNotNull("Nick Name should not be null", attr);
    assertTrue("Nick Name should be writable", attr.isWritable());
    assertTrue("Nick Name should be readable", attr.isReadable());
}
Also used : ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 84 with MBeanAttributeInfo

use of javax.management.MBeanAttributeInfo in project spring-framework by spring-projects.

the class MethodExclusionMBeanInfoAssemblerNotMappedTests method testNickNameIsExposed.

@Test
public void testNickNameIsExposed() throws Exception {
    ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo();
    MBeanAttributeInfo attr = inf.getAttribute("NickName");
    assertNotNull("Nick Name should not be null", attr);
    assertTrue("Nick Name should be writable", attr.isWritable());
    assertTrue("Nick Name should be readable", attr.isReadable());
}
Also used : ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.junit.Test)

Example 85 with MBeanAttributeInfo

use of javax.management.MBeanAttributeInfo in project opennms by OpenNMS.

the class MBeanServerQuery method execute.

public QueryResult execute(MBeanServerConnection mbeanServerConnection) throws MBeanServerQueryException {
    try {
        if (filterCriteriaList.isEmpty()) {
            filterCriteriaList.add(new FilterCriteria());
        }
        // retrieve all Mbeans
        QueryResult queryResult = executeQuery(filterCriteriaList, mbeanServerConnection);
        queryResult.setTotalMBeanCount(mbeanServerConnection.getMBeanCount());
        // retrieve all ignoring Mbeans
        QueryResult ignoreResult = executeQuery(ignoreFilterList, mbeanServerConnection);
        // filter out all ignored attributes
        for (QueryResult.MBeanResult eachResult : ignoreResult.getMBeanResults()) {
            for (MBeanAttributeInfo eachAttribute : eachResult.attributeResult.attributes) {
                queryResult.remove(eachResult.objectName, eachAttribute);
            }
        }
        // now build the result
        if (!showEmptyMbeans) {
            queryResult.removeEmptyMBeanResults();
        }
        if (sort) {
            queryResult.sort();
        }
        if (fetchValues) {
            for (QueryResult.MBeanResult eachMbeanResult : queryResult.getMBeanResults()) {
                QueryResult.AttributeResult attributeResult = eachMbeanResult.attributeResult;
                for (MBeanAttributeInfo eachAttribute : attributeResult.attributes) {
                    if (eachAttribute.isReadable()) {
                        try {
                            Object value = mbeanServerConnection.getAttribute(eachMbeanResult.objectName, eachAttribute.getName());
                            attributeResult.setValue(eachAttribute, value);
                        } catch (Exception uoe) {
                            // while receiving the value an exception could occur, we mark
                            // the values as such.
                            attributeResult.setValue(eachAttribute, "ERROR: " + uoe.getMessage());
                        }
                    }
                }
            }
        }
        return queryResult;
    } catch (IOException | JMException e) {
        throw new MBeanServerQueryException(e);
    }
}
Also used : JMException(javax.management.JMException) IOException(java.io.IOException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) JMException(javax.management.JMException) IOException(java.io.IOException)

Aggregations

MBeanAttributeInfo (javax.management.MBeanAttributeInfo)106 MBeanInfo (javax.management.MBeanInfo)75 ObjectName (javax.management.ObjectName)45 MBeanOperationInfo (javax.management.MBeanOperationInfo)24 Test (org.junit.Test)21 MBeanServer (javax.management.MBeanServer)15 ArrayList (java.util.ArrayList)13 AttributeNotFoundException (javax.management.AttributeNotFoundException)12 ReflectionException (javax.management.ReflectionException)12 ModelMBeanAttributeInfo (javax.management.modelmbean.ModelMBeanAttributeInfo)11 IOException (java.io.IOException)10 AttributeList (javax.management.AttributeList)10 Attribute (javax.management.Attribute)9 InstanceNotFoundException (javax.management.InstanceNotFoundException)9 IntrospectionException (javax.management.IntrospectionException)9 MBeanParameterInfo (javax.management.MBeanParameterInfo)9 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)9 HashMap (java.util.HashMap)8 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)7 MBeanException (javax.management.MBeanException)7