QuickFIXJ MBeanServerInvocationHandler.newProxyInstance 错误的参数类型

QuickFIXJ MBeanServerInvocationHandler.newProxyInstance wrong argument type

在为 QFJ 构建 JMX 客户端服务时,我在使用不同的 MBean 接口时遇到错误。我需要调用 ConnectorAdminMBean 中的方法,但它不能绑定到 SessionAdminMBean 的方法。抛出的错误:

newProxyInstance() in MBeanServerInvocationHandler cannot be applied to: 
interfaceClass: (Expected) java.lang.Class<T> | (Actual) ConnectorAdminMBean.class

方法:

public static <T> T newProxyInstance(MBeanServerConnection connection,
                                         ObjectName objectName,
                                         Class<T> interfaceClass,
                                         boolean notificationBroadcaster) {
        return JMX.newMBeanProxy(connection, objectName, interfaceClass, notificationBroadcaster);
    }

已确认有效:

ObjectName mBeanBLBG = new ObjectName("org.quickfixj:type=Session,beginString=FIX.4.2,senderCompID=SCB,targetCompID=BLBG");
SessionAdminMBean mBeanBLBGProxy = MBeanServerInvocationHandler.newProxyInstance(jmxConnectionInstance.getmBeanServerConnection(), mBeanBLBG, SessionAdminMBean.class, true);

然而,当我尝试这样做时,它抛出了第三个参数错误的错误:

ObjectName mBeanConnector = new ObjectName("org.quickfixj:type=Connector,role=Initiator,id=1");
SessionAdminMBean mBeanConnectorProxy = MBeanServerInvocationHandler.newProxyInstance(jmxConnectionInstance.getmBeanServerConnection(), mBeanConnector, ConnectorAdminMBean.class, true);

我查看了各自的界面,但没有发现任何区别。

package org.quickfixj.jmx.mbean.session;
import java.io.IOException;
import javax.management.ObjectName;
import quickfix.SessionNotFound;
public interface SessionAdminMBean {
    String getBeginString();
    String getTargetCompID();
    String getTargetSubID();
    ...

与:

相比
package org.quickfixj.jmx.mbean.connector;
import java.io.IOException;
import javax.management.openmbean.TabularData;
public interface ConnectorAdminMBean {
    String getRole() throws IOException;
    void stop(boolean var1) throws IOException;
    void stop() throws IOException;
    TabularData getSessions() throws IOException;
    String getHostName() throws IOException;
    int getQueueSize();
}

请告知接口 ConnectorAdminMbean 无法绑定到 Class<\T> 的可能原因。谢谢!

问题已通过将参数 class 与 MBean 代理 class 匹配得到解决,即通过更改:

SessionAdminMBean mBeanConnectorProxy = MBeanServerInvocationHandler.newProxyInstance(jmxConnectionInstance.getmBeanServerConnection(), mBeanConnector, ConnectorAdminMBean.class, true);

ConnectorAdminMBean mBeanConnectorProxy = MBeanServerInvocationHandler.newProxyInstance(jmxConnectionInstance.getmBeanServerConnection(), mBeanConnector, ConnectorAdminMBean.class, true);