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));
}
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);
}
Aggregations