0

我使用 xsocket 来实现一个套接字服务器,而 xsocket 的处理程序需要注入一个 bean 来做一些事情。但是,引用始终为 NULL,我已经记录了 setter 方法,setter 方法已被原谅,并且 bean 在日志中不为空。

public class SocketServerHandler implements IDataHandler, IConnectHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IDisconnectHandler, ApplicationContextAware {

private APIInvokeServer     apiInvokeServer;

@Override
public boolean onData(INonBlockingConnection connection) throws IOException, BufferUnderflowException,ClosedChannelException, MaxReadSizeExceededException {
    // read from connection
    String message = parseMessage(connection);

    final APIInvokeRequest invokeRequest;
    invokeRequest = apiInvokeServer.createInvokeRequest(trace);

    balabala...
}
public void setApiInvokeServer(APIInvokeServer apiInvokeServer) {
    OceanLog.system.error("--------setApiInvokeServer--------" + apiInvokeServer);
    this.apiInvokeServer = apiInvokeServer;
}
}

是因为 Handler 是一个回调类吗?并且不从春天开始?那我该怎么办?

4

0 回答 0