当前位置: 首页>>代码示例>>Java>>正文


Java MXBeanMappingFactory类代码示例

本文整理汇总了Java中com.sun.jmx.mbeanserver.MXBeanMappingFactory的典型用法代码示例。如果您正苦于以下问题:Java MXBeanMappingFactory类的具体用法?Java MXBeanMappingFactory怎么用?Java MXBeanMappingFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MXBeanMappingFactory类属于com.sun.jmx.mbeanserver包,在下文中一共展示了MXBeanMappingFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OpenMethod

import com.sun.jmx.mbeanserver.MXBeanMappingFactory; //导入依赖的package包/类
public OpenMethod(Method m) {
  try {
    final MXBeanMappingFactory mapping = MXBeanMappingFactory.DEFAULT;
    final Type[] params = m.getGenericParameterTypes();
    final MXBeanMapping[] paramConverters = new MXBeanMapping[params.length];
    boolean skipParamsConversion = true;
    // using reflection since isIdentity method is package protected
    final Method identityCheck = DefaultMXBeanMappingFactory.class
        .getDeclaredMethod("isIdentity", MXBeanMapping.class);
    identityCheck.setAccessible(true);
    for (int i = 0; i < params.length; i++) {
      paramConverters[i] = mapping.mappingForType(params[i], mapping);
      if (skipParamsConversion) {
        skipParamsConversion = (Boolean)identityCheck.invoke(null,
            paramConverters[i]);
      }
    }
    // null converters denotes no conversion required for the case when
    // all parameter conversions are identity converters
    this.paramConverters = skipParamsConversion ? null : paramConverters;
    this.returnValConverter = mapping.mappingForType(
        m.getGenericReturnType(), mapping);
  } catch (OpenDataException ode) {
    throw new IllegalArgumentException("Failed getting converter of " +
        "parameter or return value to open type for given method: " + m, ode);
  } catch (Exception e) {
    throw new IllegalStateException("Exception getting converter of " +
        "parameter or return value to open type of given method: " + m, e);
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:OpenMethod.java

示例2: invoke

import com.sun.jmx.mbeanserver.MXBeanMappingFactory; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:CompositeDataInvocationHandler.java

示例3: invoke

import com.sun.jmx.mbeanserver.MXBeanMappingFactory; //导入依赖的package包/类
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.  */
            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);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:50,代码来源:CompositeDataInvocationHandler.java


注:本文中的com.sun.jmx.mbeanserver.MXBeanMappingFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。