@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
{
if (e.getMessage() instanceof HessianRPCReplyMessage)
{
final HessianRPCReplyMessage message = (HessianRPCReplyMessage) e.getMessage();
{
final Long id = message.getCallId();
if (id != null)
{
final HessianProxyFuture future = (HessianProxyFuture) _openCalls.get(id);
if (future == null)
{
ahessianLogger.warn("no future found for call-id " + id);
return;
}
if (message.getCompleted() == null || Boolean.TRUE.equals(message.getCompleted()))
if ((!future.hasCallbacks()))
{
_openCalls.remove(id);
}
if (_doneListener != null && _openCalls.isEmpty())
_doneListener.run();
if (future != null)
// setting message in future may fire listeners -> run
// in separate thread
_executor.execute(new Runnable()
{
public void run()
{
future.set(message);
// check in case this was a callback
if (future.isDone())
if (!future.hasCallbacks())
{
_openCalls.remove(id);
}
}
});
else
ahessianLogger.warn("no future for call reply " + id + " " + message.getValue());
}
else
ahessianLogger.warn("message missing id " + message);
}