use of javax.management.openmbean.OpenType in project deltaspike by apache.
the class DeltaSpikeConfigInfo method getConfigEntries.
@Override
public TabularData getConfigEntries() {
ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(appConfigClassLoader);
List<ConfigEntry> configEntries = calculateConfigEntries();
String[] configArray = new String[configEntries.size()];
for (int i = 0; i < configEntries.size(); i++) {
ConfigEntry configEntry = configEntries.get(i);
configArray[i] = configEntry.getKey() + " = " + configEntry.getValue() + " - picked up from: " + configEntry.getFromConfigSource();
}
String typeName = "ConfigEntries";
OpenType<?>[] types = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING };
String[] keys = new String[] { "Key", "Value", "fromConfigSource" };
CompositeType ct = new CompositeType(typeName, typeName, keys, keys, types);
TabularType type = new TabularType(typeName, typeName, ct, keys);
TabularDataSupport configEntryInfo = new TabularDataSupport(type);
ConfigSource[] configSources = ConfigResolver.getConfigSources();
for (ConfigEntry configEntry : configEntries) {
configEntryInfo.put(new CompositeDataSupport(ct, keys, new Object[] { configEntry.getKey(), configEntry.getValue(), configEntry.getFromConfigSource() }));
}
return configEntryInfo;
} catch (OpenDataException e) {
throw new RuntimeException(e);
} finally {
// set back the original TCCL
Thread.currentThread().setContextClassLoader(originalCl);
}
}
use of javax.management.openmbean.OpenType in project jdk8u_jdk by JetBrains.
the class MXBeanIntrospector method getMBeanAttributeInfo.
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName, ConvertingMethod getter, ConvertingMethod setter) {
final boolean isReadable = (getter != null);
final boolean isWritable = (setter != null);
final boolean isIs = isReadable && getName(getter).startsWith("is");
final String description = attributeName;
final OpenType<?> openType;
final Type originalType;
if (isReadable) {
openType = getter.getOpenReturnType();
originalType = getter.getGenericReturnType();
} else {
openType = setter.getOpenParameterTypes()[0];
originalType = setter.getGenericParameterTypes()[0];
}
Descriptor descriptor = typeDescriptor(openType, originalType);
if (isReadable) {
descriptor = ImmutableDescriptor.union(descriptor, getter.getDescriptor());
}
if (isWritable) {
descriptor = ImmutableDescriptor.union(descriptor, setter.getDescriptor());
}
final MBeanAttributeInfo ai;
if (canUseOpenInfo(originalType)) {
ai = new OpenMBeanAttributeInfoSupport(attributeName, description, openType, isReadable, isWritable, isIs, descriptor);
} else {
ai = new MBeanAttributeInfo(attributeName, originalTypeString(originalType), description, isReadable, isWritable, isIs, descriptor);
}
return ai;
}
use of javax.management.openmbean.OpenType in project jdk8u_jdk by JetBrains.
the class GarbageCollectionNotifInfoCompositeData method getBaseGcNotifInfoCompositeType.
private static synchronized CompositeType getBaseGcNotifInfoCompositeType() {
if (baseGcNotifInfoCompositeType == null) {
try {
OpenType<?>[] baseGcNotifInfoItemTypes = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, GcInfoCompositeData.getBaseGcInfoCompositeType() };
baseGcNotifInfoCompositeType = new CompositeType("sun.management.BaseGarbageCollectionNotifInfoCompositeType", "CompositeType for Base GarbageCollectionNotificationInfo", gcNotifInfoItemNames, gcNotifInfoItemNames, baseGcNotifInfoItemTypes);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
}
return baseGcNotifInfoCompositeType;
}
use of javax.management.openmbean.OpenType in project jdk8u_jdk by JetBrains.
the class GcInfoBuilder method getGcInfoCompositeType.
// Returns the CompositeType for the GcInfo including
// the extension attributes
synchronized CompositeType getGcInfoCompositeType() {
if (gcInfoCompositeType != null)
return gcInfoCompositeType;
// First, fill with the attributes in the GcInfo
String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
int numGcInfoItems = gcInfoItemNames.length;
int itemCount = numGcInfoItems + gcExtItemCount;
allItemNames = new String[itemCount];
String[] allItemDescs = new String[itemCount];
OpenType<?>[] allItemTypes = new OpenType<?>[itemCount];
System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems);
// Then fill with the extension GC-specific attributes, if any.
if (gcExtItemCount > 0) {
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames, gcExtItemTypes, gcExtItemDescs);
System.arraycopy(gcExtItemNames, 0, allItemNames, numGcInfoItems, gcExtItemCount);
System.arraycopy(gcExtItemDescs, 0, allItemDescs, numGcInfoItems, gcExtItemCount);
for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) {
switch(gcExtItemTypes[j]) {
case 'Z':
allItemTypes[i] = SimpleType.BOOLEAN;
break;
case 'B':
allItemTypes[i] = SimpleType.BYTE;
break;
case 'C':
allItemTypes[i] = SimpleType.CHARACTER;
break;
case 'S':
allItemTypes[i] = SimpleType.SHORT;
break;
case 'I':
allItemTypes[i] = SimpleType.INTEGER;
break;
case 'J':
allItemTypes[i] = SimpleType.LONG;
break;
case 'F':
allItemTypes[i] = SimpleType.FLOAT;
break;
case 'D':
allItemTypes[i] = SimpleType.DOUBLE;
break;
default:
throw new AssertionError("Unsupported type [" + gcExtItemTypes[i] + "]");
}
}
}
CompositeType gict = null;
try {
final String typeName = "sun.management." + gc.getName() + ".GcInfoCompositeType";
gict = new CompositeType(typeName, "CompositeType for GC info for " + gc.getName(), allItemNames, allItemDescs, allItemTypes);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
gcInfoCompositeType = gict;
return gcInfoCompositeType;
}
use of javax.management.openmbean.OpenType in project jdk8u_jdk by JetBrains.
the class GarbageCollectionNotifInfoCompositeData method getCompositeTypeByBuilder.
private CompositeType getCompositeTypeByBuilder() {
final GcInfoBuilder builder = AccessController.doPrivileged(new PrivilegedAction<GcInfoBuilder>() {
public GcInfoBuilder run() {
try {
Class cl = Class.forName("com.sun.management.GcInfo");
Field f = cl.getDeclaredField("builder");
f.setAccessible(true);
return (GcInfoBuilder) f.get(gcNotifInfo.getGcInfo());
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
return null;
}
}
});
CompositeType gict = null;
synchronized (compositeTypeByBuilder) {
gict = compositeTypeByBuilder.get(builder);
if (gict == null) {
OpenType<?>[] gcNotifInfoItemTypes = new OpenType<?>[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, builder.getGcInfoCompositeType() };
try {
final String typeName = "sun.management.GarbageCollectionNotifInfoCompositeType";
gict = new CompositeType(typeName, "CompositeType for GC notification info", gcNotifInfoItemNames, gcNotifInfoItemNames, gcNotifInfoItemTypes);
compositeTypeByBuilder.put(builder, gict);
} catch (OpenDataException e) {
// shouldn't reach here
throw Util.newException(e);
}
}
}
return gict;
}
Aggregations