renames
This commit is contained in:
parent
d7e835fa4f
commit
6f7b2751f2
|
@ -32,7 +32,7 @@ import org.hyperic.sigar.Sigar;
|
||||||
|
|
||||||
public class ReflectedMBean extends AbstractMBean {
|
public class ReflectedMBean extends AbstractMBean {
|
||||||
|
|
||||||
private Method getter;
|
private Method method;
|
||||||
private Map methods;
|
private Map methods;
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class ReflectedMBean extends AbstractMBean {
|
||||||
|
|
||||||
protected Class getMBeanClass() {
|
protected Class getMBeanClass() {
|
||||||
try {
|
try {
|
||||||
return getGetter().getReturnType();
|
return getMethod().getReturnType();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
@ -60,30 +60,31 @@ public class ReflectedMBean extends AbstractMBean {
|
||||||
MBEAN_ATTR_TYPE + "=" + getType();
|
MBEAN_ATTR_TYPE + "=" + getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Method getGetter() throws Exception {
|
protected Method getMethod() throws Exception {
|
||||||
if (this.getter == null) {
|
if (this.method == null) {
|
||||||
String getName = "get" + getType();
|
String getName = "get" + getType();
|
||||||
Class[] params = getGetterParams();
|
Class[] params = getMethodParamTypes();
|
||||||
this.getter =
|
this.method =
|
||||||
this.sigarImpl.getClass().getDeclaredMethod(getName,
|
this.sigarImpl.getClass().getDeclaredMethod(getName,
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
return this.getter;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class[] getGetterParams() {
|
protected Class[] getMethodParamTypes() {
|
||||||
return new Class[0];
|
return new Class[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getReflectedAttribute(String name)
|
private Object getReflectedAttribute(String name)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
Method getter = getGetter();
|
Method method = getMethod();
|
||||||
Class[] params = getGetterParams();
|
Object obj =
|
||||||
Object obj = getter.invoke(this.sigarImpl, params);
|
method.invoke(this.sigarImpl,
|
||||||
Method method =
|
getMethodParamTypes());
|
||||||
|
Method attr =
|
||||||
obj.getClass().getMethod("get" + name, new Class[0]);
|
obj.getClass().getMethod("get" + name, new Class[0]);
|
||||||
return method.invoke(obj, new Object[0]);
|
return attr.invoke(obj, new Object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getAttribute(String name)
|
public Object getAttribute(String name)
|
||||||
|
|
Loading…
Reference in New Issue