java类javax.management.openmbean.OpenType的实例源码

MXBeanIntrospector.java 文件源码 项目:openjdk-jdk10 阅读 26 收藏 0 点赞 0 评论 0
private static Descriptor typeDescriptor(OpenType<?> openType,
                                         Type originalType) {
    return new ImmutableDescriptor(
        new String[] {"openType",
                      "originalType"},
        new Object[] {openType,
                      originalTypeString(originalType)});
}
DefaultMXBeanMappingFactory.java 文件源码 项目:openjdk-jdk10 阅读 59 收藏 0 点赞 0 评论 0
private MXBeanMapping
    makeArrayOrCollectionMapping(Type collectionType, Type elementType,
                                 MXBeanMappingFactory factory)
        throws OpenDataException {

    final MXBeanMapping elementMapping = factory.mappingForType(elementType, factory);
    final OpenType<?> elementOpenType = elementMapping.getOpenType();
    final ArrayType<?> openType = ArrayType.getArrayType(elementOpenType);
    final Class<?> elementOpenClass = elementMapping.getOpenClass();

    final Class<?> openArrayClass;
    final String openArrayClassName;
    if (elementOpenClass.isArray())
        openArrayClassName = "[" + elementOpenClass.getName();
    else
        openArrayClassName = "[L" + elementOpenClass.getName() + ";";
    try {
        openArrayClass = Class.forName(openArrayClassName);
    } catch (ClassNotFoundException e) {
        throw openDataException("Cannot obtain array class", e);
    }

    if (collectionType instanceof ParameterizedType) {
        return new CollectionMapping(collectionType,
                                     openType, openArrayClass,
                                     elementMapping);
    } else {
        if (isIdentity(elementMapping)) {
            return new IdentityMapping(collectionType,
                                       openType);
        } else {
            return new ArrayMapping(collectionType,
                                      openType,
                                      openArrayClass,
                                      elementMapping);
        }
    }
}
CompositeAttributeResolvingStrategy.java 文件源码 项目:hashsdn-controller 阅读 25 收藏 0 点赞 0 评论 0
CompositeAttributeResolvingStrategy(
        final Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerTypes,
        final CompositeType openType, final Map<String, String> yangToJavaAttrMapping) {
    super(openType);
    this.innerTypes = innerTypes;
    this.yangToJavaAttrMapping = yangToJavaAttrMapping;
}
MerlinMXBean.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
static ArrayType make(int dims, OpenType baseType) {
    try {
        return new ArrayType(dims, baseType);
    } catch (OpenDataException e) {
        throw new Error(e);
    }
}
MerlinMXBean.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
static CompositeType make(String className,
                          String description,
                          String[] itemNames,
                          String[] itemDescriptions,
                          OpenType[] itemTypes) {
    try {
        return new CompositeType(className,
                                 description,
                                 itemNames,
                                 itemDescriptions,
                                 itemTypes);
    } catch (OpenDataException e) {
        throw new Error(e);
    }
}
JavaAttribute.java 文件源码 项目:hashsdn-controller 阅读 23 收藏 0 点赞 0 评论 0
private OpenType<?> getEnumType(final TypeDefinition<?> baseType) {
    final String fullyQualifiedName = this.typeProviderWrapper.getType(this.node, getTypeDefinition()).getFullyQualifiedName();
    final String[] items = {"instance"};
    final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();

    try {
        return new CompositeType(fullyQualifiedName, description, items, items, new OpenType[]{SimpleType.STRING});
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create enum type" + fullyQualifiedName + " as open type", e);
    }
}
CompositeAttributeMappingStrategy.java 文件源码 项目:hashsdn-controller 阅读 25 收藏 0 点赞 0 评论 0
protected Optional<?> mapInnerAttribute(final CompositeDataSupport compositeData, final String jmxName,
        final String description) {
    Object innerValue = compositeData.get(jmxName);

    AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = innerStrategies.get(jmxName);
    return attributeMappingStrategy.mapAttribute(innerValue);
}
JavaAttribute.java 文件源码 项目:hashsdn-controller 阅读 27 收藏 0 点赞 0 评论 0
public OpenType<?> getCompositeTypeForIdentity() {
    final String[] itemNames = new String[]{IdentityAttributeRef.QNAME_ATTR_NAME};
    final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
    final OpenType<?>[] itemTypes = new OpenType[]{SimpleType.STRING};

    try {
        return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
                + itemTypes, e);
    }
}
JavaAttribute.java 文件源码 项目:hashsdn-controller 阅读 27 收藏 0 点赞 0 评论 0
private OpenType<?> getArrayOpenTypeForSimpleType(final String innerTypeFullyQName, final SimpleType<?> innerSimpleType) {
    try {
        final ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(innerSimpleType, true)
                : new ArrayType<>(1, innerSimpleType);
        return arrayType;
    } catch (final OpenDataException e) {
        throw new RuntimeException("Unable to create " + ArrayType.class + " with inner element of type "
                + innerSimpleType, e);
    }
}
InstanceConfig.java 文件源码 项目:hashsdn-controller 阅读 29 收藏 0 点赞 0 评论 0
@SuppressWarnings("IllegalCatch")
private Map<String, Object> getMappedConfiguration(final ObjectName on, final EnumResolver enumResolver) {

    // TODO make field, mappingStrategies can be instantiated only once
    Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> mappingStrategies = new ObjectMapper()
            .prepareMapping(jmxToAttrConfig, enumResolver);

    Map<String, Object> toXml = Maps.newHashMap();

    for (Entry<String, AttributeIfc> configDefEntry : jmxToAttrConfig.entrySet()) {
        // Skip children runtime beans as they are mapped by InstanceRuntime
        if (configDefEntry.getValue() instanceof RuntimeBeanEntry) {
            continue;
        }
        Object value = configRegistryClient.getAttributeCurrentValue(on, configDefEntry.getKey());
        try {
            AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = mappingStrategies
                    .get(configDefEntry.getKey());
            Optional<?> attribute = attributeMappingStrategy.mapAttribute(value);
            if (!attribute.isPresent()) {
                continue;
            }
            toXml.put(configDefEntry.getValue().getAttributeYangName(), attribute.get());
        } catch (final RuntimeException e) {
            throw new IllegalStateException("Unable to map value " + value + " to attribute "
                    + configDefEntry.getKey(), e);
        }
    }
    return toXml;
}


问题


面经


文章

微信
公众号

扫码关注公众号