I use xsocket to implement a socket server, and the handler of xsocket need inject an bean to do something. But, the reference aliway be NULL, I had logged the setter method, the setter method had been excused and the bean is not null in the log.
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;
}
}
Is it because the Handler is a callback class? and do not init from spring? what should I do then?