Search in sources :

Example 66 with MBeanInfo

use of javax.management.MBeanInfo in project Payara by payara.

the class GenericTest method checkObjectNameReturnValue.

void checkObjectNameReturnValue(MBeanServerConnection conn, ObjectName callee, MBeanOperationInfo operationInfo, ObjectName resultOfCall) throws Exception {
    try {
        printVerbose("checking MBean info for: " + resultOfCall);
        final MBeanInfo mbeanInfo = conn.getMBeanInfo(resultOfCall);
    } catch (InstanceNotFoundException e) {
        trace("WARNING: MBean " + resultOfCall + " returned from " + operationInfo.getReturnType() + " " + operationInfo.getName() + "() does not exist");
    } catch (Exception e) {
        trace("WARNING: MBean " + resultOfCall + " returned from " + operationInfo.getReturnType() + " " + operationInfo.getName() + "() can't supply MBeanInfo: " + getExceptionMsg(e));
        if (e instanceof IOException) {
            throw (IOException) e;
        }
    }
}
Also used : MBeanInfo(javax.management.MBeanInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException)

Example 67 with MBeanInfo

use of javax.management.MBeanInfo in project Payara by payara.

the class LBTest method testGetLoadBalancerConfigMap.

public void testGetLoadBalancerConfigMap() {
    if (testGetLoadBalancerConfigMap == false) {
        return;
    }
    try {
        Map map = getDomainConfig().getLoadBalancersConfig().getLoadBalancerConfigMap();
        // System.out.println("Here is a list of Load Balancer Config MBeans in DAS: ");
        // System.out.println(map);
        ObjectName objName = new ObjectName("amx:j2eeType=X-LoadBalancerConfig,name=test-load-balancer");
        MBeanInfo minfo = getConnection().getMBeanInfo(objName);
        MBeanAttributeInfo[] mattrsinfo = minfo.getAttributes();
        /*
            for (MBeanAttributeInfo mattrinfo : mattrsinfo) 
            {
                System.out.println("Attribute Name is : " + mattrinfo.getName());
            }
            */
        String[] attrsNames = (String[]) getConnection().getAttribute(objName, "AttributeNames");
        /*for (String attrName : attrsNames) 
                System.out.println("Actual Attribute Name is : " + attrName);            
            System.out.println("AttributeNames are : " + attrsNames);
            System.out.println("MBeanInfo is \n"+minfo);*/
        String attrName = (String) getConnection().getAttribute(objName, "LbConfigName");
        System.out.println("attrName is = " + attrName);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : MBeanInfo(javax.management.MBeanInfo) Map(java.util.Map) HashMap(java.util.HashMap) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ObjectName(javax.management.ObjectName)

Example 68 with MBeanInfo

use of javax.management.MBeanInfo in project Payara by payara.

the class AMXTest method checkMaps.

/**
 *     Verify that a proxy getAbcMap(...) Attribute or operation has an appropriate
 *     MBean getAbcObjectNameMap() method.
 */
public void checkMaps(final ObjectName objectName) throws Exception {
    final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
    if (proxy instanceof Container) {
        final Method[] methods = getInterfaceClass(proxy).getMethods();
        final MBeanInfo mbeanInfo = Util.getExtra(proxy).getMBeanInfo();
        for (int methodIdx = 0; methodIdx < methods.length; ++methodIdx) {
            final Method method = methods[methodIdx];
            final String methodName = method.getName();
            if (isMapGetter(method)) {
                if (methodName.endsWith(OBJECTNAME_MAP_SUFFIX)) {
                    warning("method should exist in MBeanInfo, not interface: " + methodName);
                    continue;
                }
                // verify that a corresponding peer method exists and
                // has the right return type and same number and type of parameters
                final String peerMethodName = StringUtil.replaceSuffix(methodName, MAP_SUFFIX, OBJECTNAME_MAP_SUFFIX);
                checkCompatibleOperationExists(Util.getObjectName(proxy), method, peerMethodName, mbeanInfo);
            } else if (isMapGetterName(methodName)) {
                warning("operation " + methodName + " does not return a Map!");
            }
        }
    }
}
Also used : Container(com.sun.appserv.management.base.Container) MBeanInfo(javax.management.MBeanInfo) Method(java.lang.reflect.Method) AMX(com.sun.appserv.management.base.AMX)

Example 69 with MBeanInfo

use of javax.management.MBeanInfo in project Payara by payara.

the class BulkAccessTest method testBulkGetMBeanOperationInfos.

public void testBulkGetMBeanOperationInfos() throws Exception {
    final long start = now();
    final ObjectName[] objectNames = getTestUtil().getAllAMXArray();
    final Object[] infos = getBulkAccess().bulkGetMBeanOperationInfo(objectNames);
    // now verify that getting it singly yields the same result.
    final MBeanServerConnection conn = getConnection();
    for (int i = 0; i < infos.length; ++i) {
        final MBeanOperationInfo[] bulkOperations = (MBeanOperationInfo[]) infos[i];
        final MBeanInfo info = conn.getMBeanInfo(objectNames[i]);
        assert (ArrayUtil.arraysEqual(info.getOperations(), bulkOperations));
    }
    printElapsed("testBulkGetMBeanOperationInfos", objectNames.length, start);
}
Also used : MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanServerConnection(javax.management.MBeanServerConnection) ObjectName(javax.management.ObjectName)

Example 70 with MBeanInfo

use of javax.management.MBeanInfo in project Payara by payara.

the class BulkAccessTest method testBulkGetMBeanAttributeNames.

public void testBulkGetMBeanAttributeNames() throws Exception {
    final long start = now();
    final ObjectName[] objectNames = getTestUtil().getAllAMXArray();
    final Object[] nameArrays = getBulkAccess().bulkGetAttributeNames(objectNames);
    for (int i = 0; i < nameArrays.length; ++i) {
        final String[] bulkNames = (String[]) nameArrays[i];
        final MBeanInfo info = getConnection().getMBeanInfo(objectNames[i]);
        final String[] names = JMXUtil.getAttributeNames(info.getAttributes());
        assert (ArrayUtil.arraysEqual(names, bulkNames));
    }
    printElapsed("testBulkGetMBeanAttributeNames", objectNames.length, start);
}
Also used : MBeanInfo(javax.management.MBeanInfo) ObjectName(javax.management.ObjectName)

Aggregations

MBeanInfo (javax.management.MBeanInfo)154 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)87 ObjectName (javax.management.ObjectName)79 MBeanOperationInfo (javax.management.MBeanOperationInfo)38 MBeanServer (javax.management.MBeanServer)27 Test (org.junit.Test)27 Attribute (javax.management.Attribute)19 ArrayList (java.util.ArrayList)17 IntrospectionException (javax.management.IntrospectionException)16 ReflectionException (javax.management.ReflectionException)16 HashMap (java.util.HashMap)15 InstanceNotFoundException (javax.management.InstanceNotFoundException)15 IOException (java.io.IOException)12 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)12 MBeanParameterInfo (javax.management.MBeanParameterInfo)12 MBeanServerConnection (javax.management.MBeanServerConnection)10 MalformedObjectNameException (javax.management.MalformedObjectNameException)10 AttributeList (javax.management.AttributeList)9 AttributeNotFoundException (javax.management.AttributeNotFoundException)9 Descriptor (javax.management.Descriptor)8