开发者

JMX MXBean enum handling conversion errors

When using an enum as the value component of a Map in an MXBean it appears I am having difficulty with conversion of the enum.

public enum MyEnum {
    EnumVal1, EnumVal2, EnumVal3
};

public interface MyMXBean {
    Map<String,MyEnum> getEnumMap();
}

MyMXBean proxy = JMX.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), new ObjectName("MyMXBeanObjectName"), MyMXBean.class);
MyEnum retval = proxy.getEnumMap().get("key");

The exception I am receiving in this situation is (edit: have since realised that this exception is due to the fact that the tabularDataSupport is expecting an Object[] as the key parameter.)

java.lang.String cannot be cast to [Ljava.lang.Object;

So the question I 开发者_JAVA技巧have is, is my understanding that enum types should implicitly convert when using JMX proxies incorrect, or am I missing something in terms of extracting the information?

Should the proxy invocation be the same as the interface invocation given that the proxy is supposed to represent the original interface?


The issue is that you are selecting the MBean proxy rather than the MXBean proxy.

Try using

MyMXBean proxy = JMX.newMXBeanProxy(ManagementFactory.getPlatformMBeanServer(), new ObjectName("MyMXBeanObjectName"), MyMXBean.class); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜