private static void addNumericAttributes(MBeanAttributeInfo attribute, Object value, Set<String> attributeNames) { String attributeType = attribute.getType(); if (numericAttributeTypes.contains(attributeType) || attributeType.equals("java.lang.Object") && value instanceof Number) { attributeNames.add(attribute.getName()); } else if (attributeType.equals("java.lang.String") && value instanceof String) { try { Double.parseDouble((String) value); attributeNames.add(attribute.getName()); } catch (NumberFormatException e) { // log exception at debug level logger.debug(e.getMessage(), e); } } else if (attributeType.equals(CompositeData.class.getName())) { Object openType = attribute.getDescriptor().getFieldValue("openType"); CompositeType compositeType = null; if (openType instanceof CompositeType) { compositeType = (CompositeType) openType; } else if (openType == null && value instanceof CompositeDataSupport) { compositeType = ((CompositeDataSupport) value).getCompositeType(); } if (compositeType != null) { attributeNames .addAll(getCompositeTypeAttributeNames(attribute, value, compositeType)); } } }
private MBeanAttributeInfo[] getWrappedAttributeInfo(MBeanInfo pMBeanInfo) { MBeanAttributeInfo origAttrInfo[] = pMBeanInfo.getAttributes(); MBeanAttributeInfo attrInfo[] = new MBeanAttributeInfo[origAttrInfo.length]; for (int i = 0; i < origAttrInfo.length; i++) { MBeanAttributeInfo aInfo = origAttrInfo[i]; String clazz = aInfo.getType(); String attrType; if (isDirectlySupported(clazz)) { attrType = clazz; } else { attrType = STRING_TYPE; // Remember type for later conversion when setting an attribute attributeInfoMap.put(aInfo.getName(), aInfo); } attrInfo[i] = new MBeanAttributeInfo( aInfo.getName(), attrType, aInfo.getDescription(), aInfo.isReadable(), aInfo.isWritable(), aInfo.isIs(), aInfo.getDescriptor()); } return attrInfo; }
} else { Object obj = attributeInfo.getDescriptor().getFieldValue("openType"); if (obj != null && obj instanceof OpenType) { openType = (OpenType) obj;
public static boolean isAttribute(final MBeanAttributeInfo info) { final String value = (String) info.getDescriptor().getFieldValue(DESC_KIND); return value == null || Attribute.class.getName().equals(value); }
public static boolean isElement(final MBeanAttributeInfo info) { final String value = (String) info.getDescriptor().getFieldValue(DESC_KIND); return Element.class.getName().equals(value); }
public static String xmlName(final MBeanAttributeInfo info, final String defaultValue) { final String value = (String) info.getDescriptor().getFieldValue(DESC_XML_NAME); return value == null ? defaultValue : value; }
public static boolean isKey(final MBeanAttributeInfo info) { return (Boolean) info.getDescriptor().getFieldValue(DESC_KEY); }
public static String defaultValue(final MBeanAttributeInfo info) { return (String) info.getDescriptor().getFieldValue(DESC_DEFAULT_VALUE); }
@Nullable protected AttributeDefinition findDefinitionFor(@Nonnull ObjectName objectName, @Nonnull MBeanAttributeInfo info) { final Descriptor descriptor = info.getDescriptor(); final OpenType<?> openType = (OpenType<?>) descriptor.getFieldValue("openType"); return findDefinitionFor(objectName, info, info.getName(), openType); }
protected CompositeType getCompositeTypeForAttribute(final MBeanServerConnection serverConnection, final ObjectName objectName, final MBeanAttributeInfo attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException { final CompositeType result = (CompositeType) attribute.getDescriptor().getFieldValue("openType"); if (result != null) { return result; } final CompositeData data = (CompositeData) serverConnection.getAttribute(objectName, attribute.getName()); if (data != null) { return data.getCompositeType(); } return null; }
protected CompositeType getCompositeTypeForAttribute(final MBeanServerConnection serverConnection, final ObjectName objectName, final MBeanAttributeInfo attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException { final CompositeType result = (CompositeType) attribute.getDescriptor().getFieldValue("openType"); if (result != null) { return result; } final CompositeData data = (CompositeData) serverConnection.getAttribute(objectName, attribute.getName()); if (data != null) { return data.getCompositeType(); } return null; }
@Override public void accept(final ManagedResourceConnector connector) throws AttributeNotFoundException { for (final MBeanAttributeInfo attributeInfo : connector.getMBeanInfo().getAttributes()) if (Objects.equals(attributeInfo.getName(), super.attributeName)) { metadata = DescriptorUtils.asDictionary(attributeInfo.getDescriptor()); return; } throw JMExceptionUtils.attributeNotFound(super.attributeName); }
@Override public String getDescription(final MBeanAttributeInfo info) { final Descriptor descriptor = info.getDescriptor(); if (descriptor != null && descriptor.getFieldValue("Description") != null) { return (String) descriptor.getFieldValue("Description"); } else { return info.getDescription(); } }
public NestedMBeanAttribute(String prefix, MBeanAttribute delegate) { this.delegate = delegate; MBeanAttributeInfo delegateInfo = delegate.getInfo(); this.info = new MBeanAttributeInfo(prefix + "." + delegateInfo.getName(), delegateInfo.getType(), delegateInfo.getDescription(), delegateInfo.isReadable(), delegateInfo.isWritable(), delegateInfo.isIs(), delegateInfo.getDescriptor()); }
public NestedMBeanAttribute(String prefix, MBeanAttribute delegate) { this.delegate = delegate; MBeanAttributeInfo delegateInfo = delegate.getInfo(); this.info = new MBeanAttributeInfo(prefix + "." + delegateInfo.getName(), delegateInfo.getType(), delegateInfo.getDescription(), delegateInfo.isReadable(), delegateInfo.isWritable(), delegateInfo.isIs(), delegateInfo.getDescriptor()); }
public NestedMBeanAttribute(String prefix, MBeanAttribute delegate) { this.delegate = delegate; MBeanAttributeInfo delegateInfo = delegate.getInfo(); this.info = new MBeanAttributeInfo(prefix + "." + delegateInfo.getName(), delegateInfo.getType(), delegateInfo.getDescription(), delegateInfo.isReadable(), delegateInfo.isWritable(), delegateInfo.isIs(), delegateInfo.getDescriptor()); }
private AttributeRepresentation(MBeanAttributeInfo attributeInfo, Object value, ObjectMapper objectMapper) { if (canSerialize(value, objectMapper)) { this.value = value; readable = attributeInfo.isReadable(); writable = attributeInfo.isWritable(); } else { this.value = null; readable = false; writable = false; } name = attributeInfo.getName(); type = attributeInfo.getType(); description = attributeInfo.getDescription(); descriptor = toMap(attributeInfo.getDescriptor()); }
private AttributeRepresentation(MBeanAttributeInfo attributeInfo, Object value, ObjectMapper objectMapper) { if (canSerialize(value, objectMapper)) { this.value = value; readable = attributeInfo.isReadable(); writable = attributeInfo.isWritable(); } else { this.value = null; readable = false; writable = false; } name = attributeInfo.getName(); type = attributeInfo.getType(); description = attributeInfo.getDescription(); descriptor = toMap(attributeInfo.getDescriptor()); }
private AttributeRepresentation(MBeanAttributeInfo attributeInfo, Object value, ObjectMapper objectMapper) { if (canSerialize(value, objectMapper)) { this.value = value; readable = attributeInfo.isReadable(); writable = attributeInfo.isWritable(); } else { this.value = null; readable = false; writable = false; } name = attributeInfo.getName(); type = attributeInfo.getType(); description = attributeInfo.getDescription(); descriptor = toMap(attributeInfo.getDescriptor()); }
private AttributeRepresentation(MBeanAttributeInfo attributeInfo, Object value, ObjectMapper objectMapper) { if (canSerialize(value, objectMapper)) { this.value = value; readable = attributeInfo.isReadable(); writable = attributeInfo.isWritable(); } else { this.value = null; readable = false; writable = false; } name = attributeInfo.getName(); type = attributeInfo.getType(); description = attributeInfo.getDescription(); descriptor = toMap(attributeInfo.getDescriptor()); }