javax.management.openmbean.OpenDataException Java Examples

The following examples show how to use javax.management.openmbean.OpenDataException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StackTraceElementCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // stackTraceElementItemNames!
    final Object[] stackTraceElementItemValues = {
        ste.getClassName(),
        ste.getMethodName(),
        ste.getFileName(),
        new Integer(ste.getLineNumber()),
        new Boolean(ste.isNativeMethod()),
    };
    try {
        return new CompositeDataSupport(stackTraceElementCompositeType,
                                        stackTraceElementItemNames,
                                        stackTraceElementItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #2
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: DefaultMXBeanMappingFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #4
Source File: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #5
Source File: DefaultMXBeanMappingFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
@Override
final Object toNonNullOpenValue(Object value)
        throws OpenDataException {
    final Collection<?> valueCollection = (Collection<?>) value;
    if (valueCollection instanceof SortedSet<?>) {
        Comparator<?> comparator =
            ((SortedSet<?>) valueCollection).comparator();
        if (comparator != null) {
            final String msg =
                "Cannot convert SortedSet with non-null comparator: " +
                comparator;
            throw openDataException(msg, new IllegalArgumentException(msg));
        }
    }
    final Object[] openArray = (Object[])
        Array.newInstance(getOpenClass().getComponentType(),
                          valueCollection.size());
    int i = 0;
    for (Object o : valueCollection)
        openArray[i++] = elementMapping.toOpenValue(o);
    return openArray;
}
 
Example #6
Source File: StackTraceElementCompositeData.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // stackTraceElementItemNames!
    final Object[] stackTraceElementItemValues = {
        ste.getClassName(),
        ste.getMethodName(),
        ste.getFileName(),
        new Integer(ste.getLineNumber()),
        new Boolean(ste.isNativeMethod()),
    };
    try {
        return new CompositeDataSupport(stackTraceElementCompositeType,
                                        stackTraceElementItemNames,
                                        stackTraceElementItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #7
Source File: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
final Object toNonNullOpenValue(Object value)
        throws OpenDataException {
    final Collection<?> valueCollection = (Collection<?>) value;
    if (valueCollection instanceof SortedSet<?>) {
        Comparator<?> comparator =
            ((SortedSet<?>) valueCollection).comparator();
        if (comparator != null) {
            final String msg =
                "Cannot convert SortedSet with non-null comparator: " +
                comparator;
            throw openDataException(msg, new IllegalArgumentException(msg));
        }
    }
    final Object[] openArray = (Object[])
        Array.newInstance(getOpenClass().getComponentType(),
                          valueCollection.size());
    int i = 0;
    for (Object o : valueCollection)
        openArray[i++] = elementMapping.toOpenValue(o);
    return openArray;
}
 
Example #8
Source File: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #9
Source File: DefaultMXBeanMappingFactory.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #10
Source File: MemoryUsageCompositeData.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // memoryUsageItemNames!
    final Object[] memoryUsageItemValues = {
        new Long(usage.getInit()),
        new Long(usage.getUsed()),
        new Long(usage.getCommitted()),
        new Long(usage.getMax()),
    };

    try {
        return new CompositeDataSupport(memoryUsageCompositeType,
                                        memoryUsageItemNames,
                                        memoryUsageItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #11
Source File: LockInfoCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // lockInfoItemNames!
    final Object[] lockInfoItemValues = {
        new String(lock.getClassName()),
        new Integer(lock.getIdentityHashCode()),
    };

    try {
        return new CompositeDataSupport(lockInfoCompositeType,
                                        lockInfoItemNames,
                                        lockInfoItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw Util.newException(e);
    }
}
 
Example #12
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
final Object toNonNullOpenValue(Object value)
        throws OpenDataException {
    final Collection<?> valueCollection = (Collection<?>) value;
    if (valueCollection instanceof SortedSet<?>) {
        Comparator<?> comparator =
            ((SortedSet<?>) valueCollection).comparator();
        if (comparator != null) {
            final String msg =
                "Cannot convert SortedSet with non-null comparator: " +
                comparator;
            throw openDataException(msg, new IllegalArgumentException(msg));
        }
    }
    final Object[] openArray = (Object[])
        Array.newInstance(getOpenClass().getComponentType(),
                          valueCollection.size());
    int i = 0;
    for (Object o : valueCollection)
        openArray[i++] = elementMapping.toOpenValue(o);
    return openArray;
}
 
Example #13
Source File: MemoryUsageCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // memoryUsageItemNames!
    final Object[] memoryUsageItemValues = {
        new Long(usage.getInit()),
        new Long(usage.getUsed()),
        new Long(usage.getCommitted()),
        new Long(usage.getMax()),
    };

    try {
        return new CompositeDataSupport(memoryUsageCompositeType,
                                        memoryUsageItemNames,
                                        memoryUsageItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #14
Source File: MemoryNotifInfoCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // memoryNotifInfoItemNames!
    final Object[] memoryNotifInfoItemValues = {
        memoryNotifInfo.getPoolName(),
        MemoryUsageCompositeData.toCompositeData(memoryNotifInfo.getUsage()),
        new Long(memoryNotifInfo.getCount()),
    };

    try {
        return new CompositeDataSupport(memoryNotifInfoCompositeType,
                                        memoryNotifInfoItemNames,
                                        memoryNotifInfoItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #15
Source File: MemoryNotifInfoCompositeData.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // memoryNotifInfoItemNames!
    final Object[] memoryNotifInfoItemValues = {
        memoryNotifInfo.getPoolName(),
        MemoryUsageCompositeData.toCompositeData(memoryNotifInfo.getUsage()),
        new Long(memoryNotifInfo.getCount()),
    };

    try {
        return new CompositeDataSupport(memoryNotifInfoCompositeType,
                                        memoryNotifInfoItemNames,
                                        memoryNotifInfoItemValues);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #16
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #17
Source File: SlowQueryReportJmx.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * JMX operation - returns all the queries we have collected.
 * @return - the slow query report as composite data.
 */
@Override
public CompositeData[] getSlowQueriesCD() throws OpenDataException {
    CompositeDataSupport[] result = null;
    ConcurrentHashMap<String,QueryStats> queries = perPoolStats.get(poolName);
    if (queries!=null) {
        Set<Map.Entry<String,QueryStats>> stats = queries.entrySet();
        if (stats!=null) {
            result = new CompositeDataSupport[stats.size()];
            Iterator<Map.Entry<String,QueryStats>> it = stats.iterator();
            int pos = 0;
            while (it.hasNext()) {
                Map.Entry<String,QueryStats> entry = it.next();
                QueryStats qs = entry.getValue();
                result[pos++] = qs.getCompositeData(getCompositeType());
            }
        }
    }
    return result;
}
 
Example #18
Source File: SlowQueryReport.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
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);
}
 
Example #19
Source File: GcInfoCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Map<String, MemoryUsage>
        getMemoryUsageAfterGc(CompositeData cd) {
    try {
        TabularData td = (TabularData) cd.get(MEMORY_USAGE_AFTER_GC);
        //return (Map<String,MemoryUsage>)
        return cast(memoryUsageMapType.toJavaTypeData(td));
    } catch (InvalidObjectException | OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #20
Source File: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #21
Source File: GcInfoCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Map<String, MemoryUsage>
        getMemoryUsageBeforeGc(CompositeData cd) {
    try {
        TabularData td = (TabularData) cd.get(MEMORY_USAGE_BEFORE_GC);
        return cast(memoryUsageMapType.toJavaTypeData(td));
    } catch (InvalidObjectException | OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #22
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
final Object toNonNullOpenValue(Object javaValue)
        throws OpenDataException {
    MXBeanLookup lookup = lookupNotNull(OpenDataException.class);
    ObjectName name = lookup.mxbeanToObjectName(javaValue);
    if (name == null)
        throw new OpenDataException("No name for object: " + javaValue);
    return name;
}
 
Example #23
Source File: MonitorInfoCompositeData.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected CompositeData getCompositeData() {
    // CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
    // monitorInfoItemNames!

    int len = monitorInfoItemNames.length;
    Object[] values = new Object[len];
    CompositeData li = LockInfoCompositeData.toCompositeData(lock);

    for (int i = 0; i < len; i++) {
        String item = monitorInfoItemNames[i];
        if (item.equals(LOCKED_STACK_FRAME)) {
            StackTraceElement ste = lock.getLockedStackFrame();
            values[i] = (ste != null ? StackTraceElementCompositeData.
                                           toCompositeData(ste)
                                     : null);
        } else if (item.equals(LOCKED_STACK_DEPTH)) {
            values[i] = new Integer(lock.getLockedStackDepth());
        } else {
            values[i] = li.get(item);
        }
    }

    try {
        return new CompositeDataSupport(monitorInfoCompositeType,
                                        monitorInfoItemNames,
                                        values);
    } catch (OpenDataException e) {
        // Should never reach here
        throw new AssertionError(e);
    }
}
 
Example #24
Source File: ConvertingMethod.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
final Object[] toOpenParameters(MXBeanLookup lookup, Object[] params)
        throws OpenDataException {
    if (paramConversionIsIdentity || params == null)
        return params;
    final Object[] oparams = new Object[params.length];
    for (int i = 0; i < params.length; i++)
        oparams[i] = paramMappings[i].toOpenValue(params[i]);
    return oparams;
}
 
Example #25
Source File: ConvertingMethod.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static ConvertingMethod from(Method m) {
    try {
        return new ConvertingMethod(m);
    } catch (OpenDataException ode) {
        final String msg = "Method " + m.getDeclaringClass().getName() +
            "." + m.getName() + " has parameter or return type that " +
            "cannot be translated into an open type";
        throw new IllegalArgumentException(msg, ode);
    }
}
 
Example #26
Source File: DefaultMXBeanMappingFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Get the converter for the given Java type, creating it if necessary. */
@Override
public synchronized MXBeanMapping mappingForType(Type objType,
                                                 MXBeanMappingFactory factory)
        throws OpenDataException {
    if (inProgress.containsKey(objType)) {
        throw new OpenDataException(
                "Recursive data structure, including " + typeName(objType));
    }

    MXBeanMapping mapping;

    mapping = getMapping(objType);
    if (mapping != null)
        return mapping;

    inProgress.put(objType, objType);
    try {
        mapping = makeMapping(objType, factory);
    } catch (OpenDataException e) {
        throw openDataException("Cannot convert type: " + typeName(objType), e);
    } finally {
        inProgress.remove(objType);
    }

    putMapping(objType, mapping);
    return mapping;
}
 
Example #27
Source File: MXBeanLookup.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
synchronized ObjectName mxbeanToObjectName(Object mxbean)
throws OpenDataException {
    String wrong;
    if (mxbean instanceof Proxy) {
        InvocationHandler ih = Proxy.getInvocationHandler(mxbean);
        if (ih instanceof MBeanServerInvocationHandler) {
            MBeanServerInvocationHandler mbsih =
                    (MBeanServerInvocationHandler) ih;
            if (mbsih.getMBeanServerConnection().equals(mbsc))
                return mbsih.getObjectName();
            else
                wrong = "proxy for a different MBeanServer";
        } else
            wrong = "not a JMX proxy";
    } else {
        ObjectName name = mxbeanToObjectName.get(mxbean);
        if (name != null)
            return name;
        wrong = "not an MXBean registered in this MBeanServer";
    }
    String s = (mxbean == null) ?
        "null" : "object of type " + mxbean.getClass().getName();
    throw new OpenDataException(
            "Could not convert " + s + " to an ObjectName: " + wrong);
    // Message will be strange if mxbean is null but it is not
    // supposed to be.
}
 
Example #28
Source File: DefaultMXBeanMappingFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** Get the converter for the given Java type, creating it if necessary. */
@Override
public synchronized MXBeanMapping mappingForType(Type objType,
                                                 MXBeanMappingFactory factory)
        throws OpenDataException {
    if (inProgress.containsKey(objType)) {
        throw new OpenDataException(
                "Recursive data structure, including " + typeName(objType));
    }

    MXBeanMapping mapping;

    mapping = getMapping(objType);
    if (mapping != null)
        return mapping;

    inProgress.put(objType, objType);
    try {
        mapping = makeMapping(objType, factory);
    } catch (OpenDataException e) {
        throw openDataException("Cannot convert type: " + typeName(objType), e);
    } finally {
        inProgress.remove(objType);
    }

    putMapping(objType, mapping);
    return mapping;
}
 
Example #29
Source File: MXBeanLookup.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
synchronized ObjectName mxbeanToObjectName(Object mxbean)
throws OpenDataException {
    String wrong;
    if (mxbean instanceof Proxy) {
        InvocationHandler ih = Proxy.getInvocationHandler(mxbean);
        if (ih instanceof MBeanServerInvocationHandler) {
            MBeanServerInvocationHandler mbsih =
                    (MBeanServerInvocationHandler) ih;
            if (mbsih.getMBeanServerConnection().equals(mbsc))
                return mbsih.getObjectName();
            else
                wrong = "proxy for a different MBeanServer";
        } else
            wrong = "not a JMX proxy";
    } else {
        ObjectName name = mxbeanToObjectName.get(mxbean);
        if (name != null)
            return name;
        wrong = "not an MXBean registered in this MBeanServer";
    }
    String s = (mxbean == null) ?
        "null" : "object of type " + mxbean.getClass().getName();
    throw new OpenDataException(
            "Could not convert " + s + " to an ObjectName: " + wrong);
    // Message will be strange if mxbean is null but it is not
    // supposed to be.
}
 
Example #30
Source File: ConvertingMethod.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private ConvertingMethod(Method m) throws OpenDataException {
    this.method = m;
    MXBeanMappingFactory mappingFactory = MXBeanMappingFactory.DEFAULT;
    returnMapping =
            mappingFactory.mappingForType(m.getGenericReturnType(), mappingFactory);
    Type[] params = m.getGenericParameterTypes();
    paramMappings = new MXBeanMapping[params.length];
    boolean identity = true;
    for (int i = 0; i < params.length; i++) {
        paramMappings[i] = mappingFactory.mappingForType(params[i], mappingFactory);
        identity &= DefaultMXBeanMappingFactory.isIdentity(paramMappings[i]);
    }
    paramConversionIsIdentity = identity;
}