本文整理汇总了Java中javax.management.openmbean.OpenType类的典型用法代码示例。如果您正苦于以下问题:Java OpenType类的具体用法?Java OpenType怎么用?Java OpenType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenType类属于javax.management.openmbean包,在下文中一共展示了OpenType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeTabularMapping
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private MXBeanMapping
makeTabularMapping(Type objType, boolean sortedMap,
Type keyType, Type valueType,
MXBeanMappingFactory factory)
throws OpenDataException {
final String objTypeName = typeName(objType);
final MXBeanMapping keyMapping = factory.mappingForType(keyType, factory);
final MXBeanMapping valueMapping = factory.mappingForType(valueType, factory);
final OpenType<?> keyOpenType = keyMapping.getOpenType();
final OpenType<?> valueOpenType = valueMapping.getOpenType();
final CompositeType rowType =
new CompositeType(objTypeName,
objTypeName,
keyValueArray,
keyValueArray,
new OpenType<?>[] {keyOpenType, valueOpenType});
final TabularType tabularType =
new TabularType(objTypeName, objTypeName, rowType, keyArray);
return new TabularMapping(objType, sortedMap, tabularType,
keyMapping, valueMapping);
}
示例2: isTypeMatched
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private static boolean isTypeMatched(OpenType<?> ot1, OpenType<?> ot2) {
if (ot1 instanceof CompositeType) {
if (! (ot2 instanceof CompositeType))
return false;
if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
return false;
} else if (ot1 instanceof TabularType) {
if (! (ot2 instanceof TabularType))
return false;
if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
return false;
} else if (ot1 instanceof ArrayType) {
if (! (ot2 instanceof ArrayType))
return false;
if (!isTypeMatched((ArrayType<?>) ot1, (ArrayType<?>) ot2)) {
return false;
}
} else if (!ot1.equals(ot2)) {
return false;
}
return true;
}
示例3: getVersionedArrayType
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private ArrayType<?> getVersionedArrayType(ArrayType<?> type, String version)
throws OpenDataException
{
if (type.isPrimitiveArray()) {
return type;
}
OpenType<?> ot = getVersionedType(
type.getElementOpenType(),
version
);
if (ot instanceof SimpleType) {
return new ArrayType<>((SimpleType<?>)ot, type.isPrimitiveArray());
} else {
return new ArrayType<>(type.getDimension(), ot);
}
}
示例4: getOpenType
import javax.management.openmbean.OpenType; //导入依赖的package包/类
@Override
public OpenType<?> getOpenType() {
final TypeDefinition<?> baseTypeDefinition = getBaseType(this.typeProviderWrapper, this.typeDefinition);
final Type baseType = this.typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition);
if (isArray()) {
return getArrayType();
} else if (isEnum()) {
return getEnumType(baseTypeDefinition);
} else if (isUnion()) {
return getCompositeTypeForUnion(baseTypeDefinition);
} else if (isDerivedType(baseType, getType())) {
return getCompositeType(baseType, baseTypeDefinition);
} else if (isIdentityRef()) {
return getCompositeTypeForIdentity();
}
return getSimpleType(getType());
}
示例5: getCompositeType
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private OpenType<?> getCompositeType(final Type baseType, final TypeDefinition<?> baseTypeDefinition) {
final SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
final String innerItemName = this.typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
final String[] itemNames = new String[]{innerItemName};
final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
final OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
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);
}
}
示例6: resolveConfiguration
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private void resolveConfiguration(final InstanceConfigElementResolved mappedConfig,
final ServiceRegistryWrapper depTracker, final EnumResolver enumResolver) {
// TODO make field, resolvingStrategies can be instantiated only once
Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> resolvingStrategies = new ObjectResolver(
depTracker).prepareResolving(yangToAttrConfig, enumResolver);
for (Entry<String, AttributeConfigElement> configDefEntry : mappedConfig.getConfiguration().entrySet()) {
AttributeConfigElement value = configDefEntry.getValue();
String attributeName = configDefEntry.getKey();
try {
AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy = resolvingStrategies
.get(attributeName);
LOG.trace("Trying to set value {} of attribute {} with {}", value, attributeName,
attributeResolvingStrategy);
value.resolveValue(attributeResolvingStrategy, attributeName);
value.setJmxName(yangToAttrConfig.get(attributeName).getUpperCaseCammelCase());
} catch (final DocumentedException e) {
throw new IllegalStateException("Unable to resolve value " + value + " to attribute " + attributeName,
e);
}
}
}
示例7: getOpenType
import javax.management.openmbean.OpenType; //导入依赖的package包/类
@Override
public CompositeType getOpenType() {
final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
final FunctionImpl functionImpl = new FunctionImpl();
final Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
final OpenType<?>[] itemTypes = Collections2.transform(
jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
new OpenType<?>[] {});
final String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
final CompositeType compositeType = new CompositeType(
getUpperCaseCammelCase(), description, itemNames,
itemNames, itemTypes);
return compositeType;
} catch (final OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for "
+ this, e);
}
}
示例8: getOpenType
import javax.management.openmbean.OpenType; //导入依赖的package包/类
public static OpenType<?> getOpenType(Object o)
{
if(o instanceof Long)
{
return SimpleType.LONG;
}
else if(o instanceof String)
{
return SimpleType.STRING;
}
else if(o instanceof Date)
{
return SimpleType.DATE;
}
else if(o instanceof Integer)
{
return SimpleType.INTEGER;
}
else if(o instanceof Boolean)
{
return SimpleType.BOOLEAN;
}
else if(o instanceof Double)
{
return SimpleType.DOUBLE;
}
else if(o instanceof Float)
{
return SimpleType.FLOAT;
}
else
{
throw new IllegalArgumentException();
}
}
示例9: caseJavaIdentityRefAttribute
import javax.management.openmbean.OpenType; //导入依赖的package包/类
@Override
protected AttributeReadingStrategy caseJavaIdentityRefAttribute(final OpenType<?> openType) {
Preconditions.checkState(openType instanceof CompositeType);
Set<String> keys = ((CompositeType) openType).keySet();
Preconditions.checkState(keys.size() == 1, "Unexpected number of elements for open type %s, should be 1",
openType);
String mappingKey = keys.iterator().next();
return new SimpleIdentityRefAttributeReadingStrategy(getLastAttribute().getNullableDefault(), mappingKey,
identityMap);
}
示例10: getBaseGcInfoItemTypes
import javax.management.openmbean.OpenType; //导入依赖的package包/类
static synchronized OpenType[] getBaseGcInfoItemTypes() {
if (baseGcInfoItemTypes == null) {
OpenType<?> memoryUsageOpenType = memoryUsageMapType.getOpenType();
baseGcInfoItemTypes = new OpenType<?>[] {
SimpleType.LONG,
SimpleType.LONG,
SimpleType.LONG,
SimpleType.LONG,
memoryUsageOpenType,
memoryUsageOpenType,
};
}
return baseGcInfoItemTypes;
}
示例11: isTypeMatched
import javax.management.openmbean.OpenType; //导入依赖的package包/类
/**
* Compares two CompositeTypes and returns true if
* all items in type1 exist in type2 and their item types
* are the same.
*/
protected static boolean isTypeMatched(CompositeType type1, CompositeType type2) {
if (type1 == type2) return true;
// We can't use CompositeType.isValue() since it returns false
// if the type name doesn't match.
Set<String> allItems = type1.keySet();
// Check all items in the type1 exist in type2
if (!type2.keySet().containsAll(allItems))
return false;
for (String item: allItems) {
OpenType<?> ot1 = type1.getType(item);
OpenType<?> ot2 = type2.getType(item);
if (ot1 instanceof CompositeType) {
if (! (ot2 instanceof CompositeType))
return false;
if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2))
return false;
} else if (ot1 instanceof TabularType) {
if (! (ot2 instanceof TabularType))
return false;
if (!isTypeMatched((TabularType) ot1, (TabularType) ot2))
return false;
} else if (!ot1.equals(ot2)) {
return false;
}
}
return true;
}
示例12: typeDescriptor
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private static Descriptor typeDescriptor(OpenType<?> openType,
Type originalType) {
return new ImmutableDescriptor(
new String[] {"openType",
"originalType"},
new Object[] {openType,
originalTypeString(originalType)});
}
示例13: makeArrayOrCollectionMapping
import javax.management.openmbean.OpenType; //导入依赖的package包/类
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);
}
}
}
示例14: makeCallerChain
import javax.management.openmbean.OpenType; //导入依赖的package包/类
/**
* Will call all getter methods on payload that are defined in the given interfaces
*/
public static Map makeCallerChain ( Object payload, Class... ifaces ) throws OpenDataException, NoSuchMethodException, InstantiationException,
IllegalAccessException, InvocationTargetException, Exception, ClassNotFoundException {
CompositeType rt = new CompositeType("a", "b", new String[] {
"a"
}, new String[] {
"a"
}, new OpenType[] {
javax.management.openmbean.SimpleType.INTEGER
});
TabularType tt = new TabularType("a", "b", rt, new String[] {
"a"
});
TabularDataSupport t1 = new TabularDataSupport(tt);
TabularDataSupport t2 = new TabularDataSupport(tt);
// we need to make payload implement composite data
// it's very likely that there are other proxy impls that could be used
AdvisedSupport as = new AdvisedSupport();
as.setTarget(payload);
InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections
.getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as);
InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt));
CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl();
invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler);
invocationHandler.setDefaultHandler(delegateInvocationHandler);
final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces);
JSONObject jo = new JSONObject();
Map m = new HashMap();
m.put("t", cdsProxy);
Reflections.setFieldValue(jo, "properties", m);
Reflections.setFieldValue(jo, "properties", m);
Reflections.setFieldValue(t1, "dataMap", jo);
Reflections.setFieldValue(t2, "dataMap", jo);
return Gadgets.makeMap(t1, t2);
}
示例15: makeTabularConverter
import javax.management.openmbean.OpenType; //导入依赖的package包/类
private static OpenTypeConverter makeTabularConverter(Type objType, boolean sortedMap,
Type keyType, Type valueType) throws OpenDataException {
final String objTypeName = objType.toString();
final OpenTypeConverter keyConverter = toConverter(keyType);
final OpenTypeConverter valueConverter = toConverter(valueType);
final OpenType keyOpenType = keyConverter.getOpenType();
final OpenType valueOpenType = valueConverter.getOpenType();
final CompositeType rowType = new CompositeType(objTypeName, objTypeName, keyValueArray,
keyValueArray, new OpenType[] {keyOpenType, valueOpenType});
final TabularType tabularType = new TabularType(objTypeName, objTypeName, rowType, keyArray);
return new TableConverter(objType, sortedMap, tabularType, keyConverter, valueConverter);
}