本文整理汇总了Java中javax.management.openmbean.CompositeType类的典型用法代码示例。如果您正苦于以下问题:Java CompositeType类的具体用法?Java CompositeType怎么用?Java CompositeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompositeType类属于javax.management.openmbean包,在下文中一共展示了CompositeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompositeData
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
public CompositeDataSupport getCompositeData(final CompositeType type) throws OpenDataException{
Object[] values = new Object[] {
query,
Integer.valueOf(nrOfInvocations),
Long.valueOf(maxInvocationTime),
Long.valueOf(maxInvocationDate),
Long.valueOf(minInvocationTime),
Long.valueOf(minInvocationDate),
Long.valueOf(totalInvocationTime),
Long.valueOf(failures),
Integer.valueOf(prepareCount),
Long.valueOf(prepareTime),
Long.valueOf(lastInvocation)
};
return new CompositeDataSupport(type,FIELD_NAMES,values);
}
示例2: getCompositeData
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// gcNotifInfoItemNames!
final Object[] gcNotifInfoItemValues;
gcNotifInfoItemValues = new Object[] {
gcNotifInfo.getGcName(),
gcNotifInfo.getGcAction(),
gcNotifInfo.getGcCause(),
GcInfoCompositeData.toCompositeData(gcNotifInfo.getGcInfo())
};
CompositeType gict = getCompositeTypeByBuilder();
try {
return new CompositeDataSupport(gict,
gcNotifInfoItemNames,
gcNotifInfoItemValues);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
示例3: CompositeMapping
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
CompositeMapping(Class<?> targetClass,
CompositeType compositeType,
String[] itemNames,
Method[] getters,
MXBeanMappingFactory factory) throws OpenDataException {
super(targetClass, compositeType);
assert(itemNames.length == getters.length);
this.itemNames = itemNames;
this.getters = getters;
this.getterMappings = new MXBeanMapping[getters.length];
for (int i = 0; i < getters.length; i++) {
Type retType = getters[i].getGenericReturnType();
getterMappings[i] = factory.mappingForType(retType, factory);
}
}
示例4: toNonNullOpenValue
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
@Override
final Object toNonNullOpenValue(Object value)
throws OpenDataException {
CompositeType ct = (CompositeType) getOpenType();
if (value instanceof CompositeDataView)
return ((CompositeDataView) value).toCompositeData(ct);
if (value == null)
return null;
Object[] values = new Object[getters.length];
for (int i = 0; i < getters.length; i++) {
try {
Object got = MethodUtil.invoke(getters[i], value, (Object[]) null);
values[i] = getterMappings[i].toOpenValue(got);
} catch (Exception e) {
throw openDataException("Error calling getter for " +
itemNames[i] + ": " + e, e);
}
}
return new CompositeDataSupport(ct, itemNames, values);
}
示例5: preprocessValueMap
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
@Override
protected Map<String, Object> preprocessValueMap(final Map<?, ?> valueMap) {
CompositeType openType = getOpenType();
Preconditions.checkArgument(
valueMap.size() == 1 && valueMap.containsKey(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION),
"Unexpected structure of incoming map, expecting one element under %s, but was %s",
JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION, valueMap);
Map<String, Object> newMap = Maps.newHashMap();
for (String key : openType.keySet()) {
if (openType.getDescription(key).equals(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION)) {
newMap.put(key, valueMap.get(JavaAttribute.DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION));
} else {
newMap.put(key, null);
}
}
return newMap;
}
示例6: toNonNullOpenValue
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
/**
* Converts to open value
*/
final Object toNonNullOpenValue(Object value) throws OpenDataException {
CompositeType ct = (CompositeType) getOpenType();
if (value instanceof CompositeDataView)
return ((CompositeDataView) value).toCompositeData(ct);
if (value == null)
return null;
Object[] values = new Object[getters.length];
for (int i = 0; i < getters.length; i++) {
try {
Object got = getters[i].invoke(value, (Object[]) null);
values[i] = getterConverters[i].toOpenValue(got);
} catch (Exception e) {
throw openDataException("Error calling getter for " + itemNames[i] + ": " + e, e);
}
}
return new CompositeDataSupport(ct, itemNames, values);
}
示例7: addOpenAttribute
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
protected void addOpenAttribute(String csDescription, Class cls, String csMethodName, CompositeType compositeType)
{
Method methodGet = MethodFinder.getMethod(cls, "get"+csMethodName);
boolean bCanGet = true;
if(methodGet == null)
bCanGet = false;
Method methodSet = MethodFinder.getMethod(cls, "set"+csMethodName, CompositeData.class);
boolean bCanSet = true;
if(methodSet == null)
bCanSet = false;
OpenMBeanAttributeInfoSupport attrOpen = new OpenMBeanAttributeInfoSupport(csMethodName, csDescription, compositeType, bCanGet, bCanSet, false);
OpenMBeanAttributeInfoWrapper attr = new OpenMBeanAttributeInfoWrapper(csMethodName, csDescription, attrOpen, methodGet, methodSet);
if(m_arrOpenMBeanAttributeInfosWrapper == null)
m_arrOpenMBeanAttributeInfosWrapper = new ArrayList<OpenMBeanAttributeInfoWrapper>();
m_arrOpenMBeanAttributeInfosWrapper.add(attr);
}
示例8: isTypeMatched
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
/**
* Compares two CompositeTypes and returns true if
* all items in type1 exist in type2 and their item types
* are the same.
* @param type1 the base composite type
* @param type2 the checked composite type
* @return {@code 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;
return allItems.stream().allMatch(
item -> isTypeMatched(type1.getType(item), type2.getType(item))
);
}
示例9: makeTabularMapping
import javax.management.openmbean.CompositeType; //导入依赖的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);
}
示例10: getCompositeType
import javax.management.openmbean.CompositeType; //导入依赖的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);
}
}
示例11: getOpenType
import javax.management.openmbean.CompositeType; //导入依赖的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);
}
}
示例12: writeObject
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
private void writeObject(JsonGenerator jg, Object value) throws IOException {
if(value == null) {
jg.writeNull();
} else {
Class<?> c = value.getClass();
if (c.isArray()) {
jg.writeStartArray();
int len = Array.getLength(value);
for (int j = 0; j < len; j++) {
Object item = Array.get(value, j);
writeObject(jg, item);
}
jg.writeEndArray();
} else if(value instanceof Number) {
Number n = (Number)value;
jg.writeNumber(n.toString());
} else if(value instanceof Boolean) {
Boolean b = (Boolean)value;
jg.writeBoolean(b);
} else if(value instanceof CompositeData) {
CompositeData cds = (CompositeData)value;
CompositeType comp = cds.getCompositeType();
Set<String> keys = comp.keySet();
jg.writeStartObject();
for(String key: keys) {
writeAttribute(jg, key, cds.get(key));
}
jg.writeEndObject();
} else if(value instanceof TabularData) {
TabularData tds = (TabularData)value;
jg.writeStartArray();
for(Object entry : tds.values()) {
writeObject(jg, entry);
}
jg.writeEndArray();
} else {
jg.writeString(value.toString());
}
}
}
示例13: makeCallerChain
import javax.management.openmbean.CompositeType; //导入依赖的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);
}
示例14: caseJavaUnionAttribute
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
@Override
protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseJavaUnionAttribute(final OpenType<?> openType) {
Preconditions.checkState(openType instanceof CompositeType, "Unexpected open type, expected %s but was %s");
CompositeType compositeType = (CompositeType) openType;
Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerMap = Maps.newHashMap();
Map<String, String> yangToJmxMapping = Maps.newHashMap();
fillMappingForComposite(compositeType, innerMap, yangToJmxMapping);
return new UnionCompositeAttributeResolvingStrategy(innerMap, compositeType, yangToJmxMapping);
}
示例15: CompositeAttributeResolvingStrategy
import javax.management.openmbean.CompositeType; //导入依赖的package包/类
CompositeAttributeResolvingStrategy(
final Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerTypes,
final CompositeType openType, final Map<String, String> yangToJavaAttrMapping) {
super(openType);
this.innerTypes = innerTypes;
this.yangToJavaAttrMapping = yangToJavaAttrMapping;
}