Пользовательские атрибуты JXM MXBean

У меня проблема с пользовательскими типами MXBean, и я не могу с ней справиться. Это моя структура Java, которая включает атрибут Map< enum, OtherThing>

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<?>

Что я делаю неправильно? В чем проблема?


person javinsnc    schedule 20.08.2014    source источник


Ответы (1)


Когда вы пишете:

public interface PVBean {
    public Map<EnumTP, EnumP[]> getMapP();
    public Map<EnumTP, EnumP[]> getMapC();
    public Map<EnumTP, EnumP[]> getMapT();
    public Map<EnumTP, EnumP[]> getMapV();
}

... какова область применения EnumTP?

person Renat Bekbolatov    schedule 20.08.2014
comment
EnumTP находится внутри PV (вверху). Это то, что ты имеешь в виду? - person javinsnc; 20.08.2014
comment
Интерфейс PVBean не имеет информации о том, что такое EnumTP, поскольку единственный EnumTP находится во внутренней области видимости PV. - person Renat Bekbolatov; 20.08.2014
comment
Я пропустил весь импорт для всех классов. PVBean имеет импорт EnumTP. Кроме того, тип EnumP — «enum», и я думал, что для типа перечисления больше ничего не нужно (например, String или int). - person javinsnc; 20.08.2014
comment
Кто-нибудь с такой же проблемой? - person javinsnc; 20.08.2014