當前位置: 首頁>>代碼示例>>Java>>正文


Java CompositeType類代碼示例

本文整理匯總了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);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:SlowQueryReport.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:GarbageCollectionNotifInfoCompositeData.java

示例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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:DefaultMXBeanMappingFactory.java

示例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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:DefaultMXBeanMappingFactory.java

示例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;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:21,代碼來源:UnionCompositeAttributeResolvingStrategy.java

示例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);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:CompositeConverter.java

示例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);
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:19,代碼來源:BaseOpenMBean.java

示例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))
    );
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:LazyCompositeData.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:DefaultMXBeanMappingFactory.java

示例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);
        }
    }
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:17,代碼來源:JavaAttribute.java

示例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);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:23,代碼來源:TOAttribute.java

示例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());
    }
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:41,代碼來源:JMXJsonServlet.java

示例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);
}
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:40,代碼來源:JSON1.java

示例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);
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:13,代碼來源:ObjectResolver.java

示例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;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:8,代碼來源:CompositeAttributeResolvingStrategy.java


注:本文中的javax.management.openmbean.CompositeType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。