gpt4 book ai didi

java - QuickFIXJ MBeanServerIncationHandler.newProxyInstance 参数类型错误

转载 作者:行者123 更新时间:2023-11-30 06:21:02 25 4
gpt4 key购买 nike

在为 QFJ 构建 JMX 客户端服务时,我在使用不同的 MBean 接口(interface)时遇到了错误。我需要调用 ConnectorAdminMBean 中的方法,但它无法绑定(bind)到 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 接口(interface)无法绑定(bind)到 Class<\T> 的可能原因。谢谢!

最佳答案

通过将参数类与 MBean 代理类匹配来解决问题,即通过更改:

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

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

关于java - QuickFIXJ MBeanServerIncationHandler.newProxyInstance 参数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48143968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com