Java Code Examples for com.sun.jmx.mbeanserver.MXBeanMapping#fromOpenValue()

The following examples show how to use com.sun.jmx.mbeanserver.MXBeanMapping#fromOpenValue() . 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: CompositeDataInvocationHandler.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 2
Source File: CompositeDataInvocationHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 3
Source File: CompositeDataInvocationHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 4
Source File: CompositeDataInvocationHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 5
Source File: CompositeDataInvocationHandler.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 6
Source File: CompositeDataInvocationHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 7
Source File: CompositeDataInvocationHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 8
Source File: CompositeDataInvocationHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 9
Source File: CompositeDataInvocationHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 10
Source File: CompositeDataInvocationHandler.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 11
Source File: CompositeDataInvocationHandler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 12
Source File: CompositeDataInvocationHandler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 13
Source File: CompositeDataInvocationHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 14
Source File: CompositeDataInvocationHandler.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 15
Source File: CompositeDataInvocationHandler.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}
 
Example 16
Source File: CompositeDataInvocationHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    final String methodName = method.getName();

    // Handle the methods from java.lang.Object
    if (method.getDeclaringClass() == Object.class) {
        if (methodName.equals("toString") && args == null)
            return "Proxy[" + compositeData + "]";
        else if (methodName.equals("hashCode") && args == null)
            return compositeData.hashCode() + 0x43444948;
        else if (methodName.equals("equals") && args.length == 1
            && method.getParameterTypes()[0] == Object.class)
            return equals(proxy, args[0]);
        else {
            /* Either someone is calling invoke by hand, or
               it is a non-final method from Object overriden
               by the generated Proxy.  At the time of writing,
               the only non-final methods in Object that are not
               handled above are finalize and clone, and these
               are not overridden in generated proxies.  */
            // this plain Method.invoke is called only if the declaring class
            // is Object and so it's safe.
            return method.invoke(this, args);
        }
    }

    String propertyName = DefaultMXBeanMappingFactory.propertyName(method);
    if (propertyName == null) {
        throw new IllegalArgumentException("Method is not getter: " +
                                           method.getName());
    }
    Object openValue;
    if (compositeData.containsKey(propertyName))
        openValue = compositeData.get(propertyName);
    else {
        String decap = DefaultMXBeanMappingFactory.decapitalize(propertyName);
        if (compositeData.containsKey(decap))
            openValue = compositeData.get(decap);
        else {
            final String msg =
                "No CompositeData item " + propertyName +
                (decap.equals(propertyName) ? "" : " or " + decap) +
                " to match " + methodName;
            throw new IllegalArgumentException(msg);
        }
    }
    MXBeanMapping mapping =
        MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                               MXBeanMappingFactory.DEFAULT);
    return mapping.fromOpenValue(openValue);
}