Search in sources :

Example 31 with OpenType

use of javax.management.openmbean.OpenType in project Payara by payara.

the class OpenMBeanUtil method getStackTraceElementOpenType.

/**
 *    Get a CompositeType describing a CompositeData which has no elements.
 */
public static OpenType getStackTraceElementOpenType() throws OpenDataException {
    final String[] itemNames = new String[] { "ClassName", "FileName", "LineNumber", "IsNativeMethod" };
    final String[] descriptions = new String[] { "ClassName", "FileName", "LineNumber", "IsNativeMethod" };
    final OpenType[] openTypes = new OpenType[itemNames.length];
    openTypes[0] = SimpleType.STRING;
    openTypes[1] = SimpleType.STRING;
    openTypes[2] = SimpleType.INTEGER;
    openTypes[3] = SimpleType.BOOLEAN;
    return (new CompositeType(StackTraceElement.class.getName(), "StackTraceElement composite type", itemNames, descriptions, openTypes));
}
Also used : OpenType(javax.management.openmbean.OpenType) CompositeType(javax.management.openmbean.CompositeType)

Example 32 with OpenType

use of javax.management.openmbean.OpenType in project Payara by payara.

the class OpenMBeanUtil method getOpenType.

/**
 *    Get the OpenType of an Object, which must conform to OpenType requirements.
 */
public static OpenType getOpenType(final Object o) throws InvalidOpenTypeException, OpenDataException {
    if (o == null) {
        // no OpenType for a null
        throw new IllegalArgumentException();
    }
    OpenType type = getSimpleType(o.getClass());
    if (type == null) {
        final Class<?> theClass = o.getClass();
        if (theClass.isArray()) {
            final int dimensions = getArrayDimensions(theClass);
            final Class<?> elementClass = theClass.getComponentType();
            final SimpleType simpleType = getSimpleType(elementClass);
            if (simpleType != null) {
                type = newArrayType(dimensions, simpleType);
            } else {
                final Object element = getAnyArrayElement(o);
                if (CompositeData.class.isAssignableFrom(elementClass)) {
                    if (element == null) {
                        type = SimpleType.VOID;
                    } else {
                        type = newArrayType(dimensions, ((CompositeData) element).getCompositeType());
                    }
                } else if (TabularData.class.isAssignableFrom(elementClass)) {
                    if (element == null) {
                        type = SimpleType.VOID;
                    } else {
                        type = newArrayType(dimensions, TabularData.class.cast(element).getTabularType());
                    }
                }
            }
        } else if (o instanceof CompositeData) {
            type = ((CompositeData) o).getCompositeType();
        } else if (o instanceof TabularData) {
            type = ((TabularData) o).getTabularType();
        }
    }
    if (type == null) {
        throw new IllegalArgumentException(o.getClass().getName());
    }
    return (type);
}
Also used : SimpleType(javax.management.openmbean.SimpleType) OpenType(javax.management.openmbean.OpenType) CompositeData(javax.management.openmbean.CompositeData) TabularData(javax.management.openmbean.TabularData)

Aggregations

OpenType (javax.management.openmbean.OpenType)32 CompositeType (javax.management.openmbean.CompositeType)26 OpenDataException (javax.management.openmbean.OpenDataException)15 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)10 TabularType (javax.management.openmbean.TabularType)10 CompositeData (javax.management.openmbean.CompositeData)7 TabularDataSupport (javax.management.openmbean.TabularDataSupport)7 ObjectName (javax.management.ObjectName)6 ArrayType (javax.management.openmbean.ArrayType)6 GenericArrayType (java.lang.reflect.GenericArrayType)5 ParameterizedType (java.lang.reflect.ParameterizedType)5 MBeanServer (javax.management.MBeanServer)5 Method (java.lang.reflect.Method)4 Type (java.lang.reflect.Type)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)4 MBeanInfo (javax.management.MBeanInfo)4 Descriptor (javax.management.Descriptor)3 ImmutableDescriptor (javax.management.ImmutableDescriptor)3 JMException (javax.management.JMException)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)3