本文整理汇总了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);
}
}
示例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);
}
示例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);
}