void (final ChannelHandlerContext context, JavacRemoteProto.Message message) { // in case of REQUEST_ACK this is a process ID, otherwise this is a sessionId final UUID msgUuid = JavacProtoUtil.fromProtoUUID(message.getSessionId()); CompileSession session = mySessions.get(msgUuid); final ExternalJavacMessageHandler handler = session != null? session.myHandler : null; final JavacRemoteProto.Message.Type messageType = message.getMessageType(); JavacRemoteProto.Message reply = null; try { if (messageType == JavacRemoteProto.Message.Type.RESPONSE) { final JavacRemoteProto.Message.Response response = message.getResponse(); final JavacRemoteProto.Message.Response.Type responseType = response.getResponseType(); if (responseType == JavacRemoteProto.Message.Response.Type.REQUEST_ACK) { // in this case msgUuid is a process ID, so we need to save the channel, associated with the process final Channel channel = context.channel(); channel.attr(PROCESS_ID_KEY).set(msgUuid); synchronized (myConnections) { myConnections.put(msgUuid, channel); myConnections.notifyAll(); } return; } } if (handler != null) { final boolean terminateOk = handler.handleMessage(message); if (terminateOk) { session.setDone(); mySessions.remove(session.getId()); final ExternalJavacProcessHandler process = myRunningProcesses.get(session.getProcessId()); if (process != null) { process.unlock(); } } else if (session.isCancelRequested()) { reply = JavacProtoUtil.toMessage(msgUuid, JavacProtoUtil.createCancelRequest()); } } else { LOG.info("No message handler is registered to handle message " + messageType.name() + "; canceling the process"); reply = JavacProtoUtil.toMessage(msgUuid, JavacProtoUtil.createCancelRequest()); } } finally { if (reply != null) { context.channel().writeAndFlush(reply); } } }