package it.rafa.test; import java.io.IOException; import java.util.logging.Logger; import org.glassfish.grizzly.filterchain.BaseFilter; import org.glassfish.grizzly.filterchain.FilterChainContext; import org.glassfish.grizzly.filterchain.NextAction; public class MyCallerFilter extends BaseFilter { private static final Logger logger = Logger.getLogger(MyCallerFilter.class.getName()); public MyCallerFilter() { } /** * Handle just read operation, when some message has come and ready to be * processed. * * @param ctx Context of {@link FilterChainContext} processing * @return the next action * @throws java.io.IOException */ @Override public NextAction handleRead(FilterChainContext ctx) throws IOException { final Object peerAddress = ctx.getAddress(); final Object message = ctx.getMessage(); if(message instanceof MyMessage ) { logger.info( "handling a MyMessage..." ); MyMessage m = (MyMessage) message; byte[] body = m.getMsg(); logger.info("m="+ m ); byte[] res = JobExecution.exec( body ); MyMessage answer = new MyMessage( res.length, res ); ctx.write(answer); logger.info( "i wrote the MyMessage: "+answer ); } else { } return ctx.getStopAction(); } }