本文介绍了JXM MXBean定制属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对MXBean自定义类型有问题,我无法处理.这是我的java结构,涉及到Map< enum, OtherThing>
属性
I have a problem with MXBean custom types and I am not able to handle it. This is my java structure, that involves Map< enum, OtherThing>
attribute
PPV及其界面
public class PPV implements PPVMXBean {
public enum EnumPV {
PV1,
PV2;
}
public static Map<EnumPV, PV> list;
public Map<EnumPV, PV> getList() {
return list;
}
}
public interface PPVMXBean {
public Map<EnumPV, PV> getList();
}
PV及其界面
public class PV implements PVBean {
public enum EnumTP {
TP1,
TP2;
}
private Map<EnumTP, EnumP[]> mapP;
private Map<EnumTP, EnumP[]> mapC;
private Map<EnumTP, EnumP[]> mapT;
private Map<EnumTP, EnumP[]> mapV;
public Map<EnumTP, EnumP[]> getMapP() {
return mapP;
}
public Map<EnumTP, EnumP[]> getMapC() {
return mapC;
}
public Map<EnumTP, EnumP[]> getMapT() {
return mapT;
}
public Map<EnumTP, EnumP[]> getMapV() {
return mapV;
}
}
public interface PVBean {
public Map<EnumTP, EnumP[]> getMapP();
public Map<EnumTP, EnumP[]> getMapC();
public Map<EnumTP, EnumP[]> getMapT();
public Map<EnumTP, EnumP[]> getMapV();
}
枚举
public enum EnumP {
P1(1),
P2(2);
private int p;
EnumP (int pAux) {
p = pAux;
}
public int getP() {
return p;
}
}
有了这些,我得到:
...
Caused by: javax.management.NotCompliantMBeanException: com.example.PPVMXBean: Method com.example.PPVMXBean.getLista has parameter or return type that cannot be translated into an open type
...
Caused by: java.lang.IllegalArgumentException: Method com.example.PPVMXBean.getLista has parameter or return type that cannot be translated into an open type
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.util.Map<com.example.PPV$EnumPV, com.examplePV>
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: class com.example.PV
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.lang.Class<?>
...
Caused by: javax.management.openmbean.OpenDataException: Cannot convert type: java.lang.Class<?>
我做错了什么?问题出在哪里?
What am I doing wrong? Where is the problem?
推荐答案
编写时:
public interface PVBean {
public Map<EnumTP, EnumP[]> getMapP();
public Map<EnumTP, EnumP[]> getMapC();
public Map<EnumTP, EnumP[]> getMapT();
public Map<EnumTP, EnumP[]> getMapV();
}
... EnumTP 的范围如何?
... how is EnumTP in scope?
这篇关于JXM MXBean定制属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!