* Call the {@link LineHandler}
*/
@SuppressWarnings("unchecked")
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
ProtocolSession pSession = (ProtocolSession) ctx.getAttachment();
LinkedList<LineHandler> lineHandlers = chain.getHandlers(LineHandler.class);
LinkedList<ProtocolHandlerResultHandler> resultHandlers = chain.getHandlers(ProtocolHandlerResultHandler.class);
if (lineHandlers.size() > 0) {
ChannelBuffer buf = (ChannelBuffer) e.getMessage();
byte[] line;
if (buf.hasArray()) {
line = buf.array();
} else {
// copy the ChannelBuffer to a byte array to process the LineHandler
line = new byte[buf.capacity()];
buf.getBytes(0, line);
}
LineHandler lHandler= (LineHandler) lineHandlers.getLast();
long start = System.currentTimeMillis();
Response response = lHandler.onLine(pSession,line);
long executionTime = System.currentTimeMillis() - start;
for (int i = 0; i < resultHandlers.size(); i++) {
// Disable till PROTOCOLS-37 is implemented
if (response instanceof FutureResponse) {
pSession.getLogger().debug("ProtocolHandlerResultHandler are not supported for FutureResponse yet");
break;
}
response = resultHandlers.get(i).onResponse(pSession, response, executionTime, lHandler);
}
if (response != null) {