src/main/java/com/amlinv/jmxutil/polling/AttributeInjector.java
protected void copyOutAttributes(Object target, List<Attribute> jmxAttributeValues,
                                     Map<String, Method> attributeSetters, String identifierKey, Object identifier) {

        for (Attribute oneAttribute : jmxAttributeValues) {
            String attributeName = oneAttribute.getName();

            Method setter = attributeSetters.get(attributeName);
            Object value = oneAttribute.getValue();

            try {
                //
                // Automatically down-convert longs to integers as-needed.
                //
                if ((setter.getParameterTypes()[0].isAssignableFrom(Integer.class)) ||
                    (setter.getParameterTypes()[0].isAssignableFrom(int.class))) {
                    if (value instanceof Long) {
                        value = ((Long) value).intValue();
                    }
                }
                setter.invoke(target, value);
            } catch (InvocationTargetException invocationExc) {
                this.log.info("invocation exception storing mbean results: {}={}; attributeName={}", identifierKey,
                        identifier, attributeName, invocationExc);
            } catch (IllegalAccessException illegalAccessExc) {
                this.log.info("illegal access exception storing mbean results: {}={}; attributeName={}", identifierKey,
                        identifier, attributeName, illegalAccessExc);
            } catch (IllegalArgumentException illegalArgumentExc) {
                this.log.info("illegal argument exception storing mbean results: {}={}; attributeName={}",
                        identifierKey, identifier, attributeName, illegalArgumentExc);
            }
        }
    }
protected void copyOutAttributes(Object target, List<Attribute> jmxAttributeValues,
                                     Map<String, Method> attributeSetters, String identifierKey, Object identifier) {

        for (Attribute oneAttribute : jmxAttributeValues) {
            String attributeName = oneAttribute.getName();

            Method setter = attributeSetters.get(attributeName);
            Object value = oneAttribute.getValue();

            try {
                //
                // Automatically down-convert longs to integers as-needed.
                //
                if ((setter.getParameterTypes()[0].isAssignableFrom(Integer.class)) ||
                    (setter.getParameterTypes()[0].isAssignableFrom(int.class))) {
                    if (value instanceof Long) {
                        value = ((Long) value).intValue();
                    }
                }
                setter.invoke(target, value);
            } catch (InvocationTargetException invocationExc) {
                this.log.info("invocation exception storing mbean results: {}={}; attributeName={}", identifierKey,
                        identifier, attributeName, invocationExc);
            } catch (IllegalAccessException illegalAccessExc) {
                this.log.info("illegal access exception storing mbean results: {}={}; attributeName={}", identifierKey,
                        identifier, attributeName, illegalAccessExc);
            } catch (IllegalArgumentException illegalArgumentExc) {
                this.log.info("illegal argument exception storing mbean results: {}={}; attributeName={}",
                        identifierKey, identifier, attributeName, illegalArgumentExc);
            }
        }
    }
protected void copyOutAttributes ( Object target , List < Attribute > jmxAttributeValues , Map < String , Method > attributeSetters , String identifierKey , Object identifier ) { for ( Attribute oneAttribute : jmxAttributeValues ) { String attributeName = oneAttribute . getName ( ) ; Method setter = attributeSetters . get ( attributeName ) ; Object value = oneAttribute . getValue ( ) ; try { // // Automatically down-convert longs to integers as-needed. // if ( ( setter . getParameterTypes ( ) [ 0 ] . isAssignableFrom ( Integer . class ) ) || ( setter . getParameterTypes ( ) [ 0 ] . isAssignableFrom ( int . class ) ) ) { if ( value instanceof Long ) { value = ( ( Long ) value ) . intValue ( ) ; } } setter . invoke ( target , value ) ; } catch ( InvocationTargetException invocationExc ) { this . log . info ( "invocation exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , invocationExc ) ; } catch ( IllegalAccessException illegalAccessExc ) { this . log . info ( "illegal access exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , illegalAccessExc ) ; } catch ( IllegalArgumentException illegalArgumentExc ) { this . log . info ( "illegal argument exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , illegalArgumentExc ) ; } } }
Copy the values of the given attributes into the target object using the specified setter methods mapped by
attribute name.

@param target object into which values are injected.
@param jmxAttributeValues values of the attributes to inject.
@param attributeSetters map of attribute name to setter used to determine how to inject each attribute's value.
@param identifierKey key, or name, of the identifier - used only for logging purposes.
@param identifier identifier to include in the output - used only for logging purposes.
Copy the values of the given attributes into the target object using the specified setter methods mapped by attribute name .