impleChannelUpstreamHandler;
/ **
* Date: 26.02.13
* Time: 23:51
*
* @ author DoSOfRR
* / class DataReader extends SimpleChannelUpstreamHandler {
@ Overridevoid messageReceived (final ChannelHandlerContext ctx, MessageEvent e) throws Exception {message=e.getMessage (); (message instanceof Session) {. getInstance (). putSession ((Session) message);
}
}
@ Overridevoid exceptionCaught (ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
/ / todo log exception.err.println («Err from:» + e.getChannel (). getRemoteAddress ());. getChannel (). close ();
}
}com.gmail.dosofredriver.ajax.serviceserver.server.handlers;com.gmail.dosofredriver.ajax.serviceserver.server.session.Session;org.jbossty.buffer.ChannelBuffer;org.jbossty.channel.Channel;org.jbossty.channel.ChannelHandlerContext;org.jbossty.handler.codec.oneone.OneToOneDecoder;java.nio.ByteBuffer;
/ **
* Date: 27.02.13
* Time: 2:07
*
* @ author DoSOfRR
* / class Decoder extends OneToOneDecoder {int length;
@ OverrideObject decode (ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {(msg instanceof ChannelBuffer) {data=ByteBuffer.wrap (((ChannelBuffer) msg). array ()); new Session (data, channel);
} null;
}
}com.gmail.dosofredriver.ajax.serviceserver.server.handlers;com.gmail.dosofredriver.ajax.serviceserver.server.session.Session;org.jbossty.buffer.ChannelBuffers;org.jbossty.channel.Channel;org.jbossty.channel.ChannelHandlerContext;org.jbossty.handler.codec.oneone.OneToOneEncoder;
/ **
* Date: 02.03.13
* Time: 19:06
*
* @ author DoSOfRR
* / class Encoder extends OneToOneEncoder {
@ OverrideObject encode (ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {(msg instanceof Session) {ChannelBuffers.wrappedBuffer (((Session) msg). getData ());
} else {ChannelBuffers.EMPTY_BUFFER;
} / / note the writer should manually close channel after the message walk through pipeline
}
}com.gmail.dosofredriver.ajax.serviceserver.service;com.gmail.dosofredriver.ajax.serviceserver.server.session.Session;com.gmail.dosofredriver.ajax.serviceserver.util.invoke.Invoker;com.gmail.dosofredriver.ajax.serviceserver.util.parser.Parser;java.nio.ByteBuffer;
/ **
* Date: 07.03.13
* Time: 21:19
*
* @ author DoSOfRR
* / class Service {static Session service (Session session) throws Exception {request=new String (session.getData (). array ());// Get AJAX requestresult=Invoker.invoke (Parser.parseRequest (request));// Parse it, and call application