/** * Excute the pattern matching algorithm to determine if a the current * connection must be suspended or not, and when. * * @param ctx The current {@link Context} * @return true if the ProtocolChain should continue its execution, * false if the connection has been suspended. * @throws java.io.IOException */ public boolean postExecute(Context ctx) throws IOException { log("<----- " + ctx.getKeyRegistrationState()); if (!suspendedKeys.isEmpty() && ctx.getKeyRegistrationState() == KeyRegistrationState.REGISTER){ suspend(ctx,false); return false; } return true; }
public boolean handle(Context context, PUProtocolRequest protocolRequest) throws IOException { ProtocolChain protocolChain = pcih.poll(); try { try { protocolChain.execute(context); } catch (Exception e) { Controller.logger().log(Level.WARNING, "Error executing custom filter chain", e); } } finally { pcih.offer(protocolChain); } return context.getKeyRegistrationState() != Context.KeyRegistrationState.CANCEL; }
/** * If no bytes were available, close the connection by cancelling the * SelectionKey. If bytes were available, register the SelectionKey * for new bytes. * * @return <tt>true</tt> if the previous ProtocolFilter postExecute method * needs to be invoked. */ public boolean postExecute(Context ctx) throws IOException { if (ctx.getKeyRegistrationState() == Context.KeyRegistrationState.CANCEL){ ctx.getSelectorHandler().getSelectionKeyHandler(). cancel(ctx.getSelectionKey()); } else if (ctx.getKeyRegistrationState() == Context.KeyRegistrationState.REGISTER){ saveSecuredBufferRemainders(ctx.getSelectionKey()); ctx.getSelectorHandler().register(ctx.getSelectionKey(), SelectionKey.OP_READ); ctx.setKeyRegistrationState(Context.KeyRegistrationState.NONE); } return true; }
context.getKeyRegistrationState() == Context.KeyRegistrationState.CANCEL) { protocolHandler.expireKey(selectionKey);
if (sh.getSuspendWhen() == Suspend.BEFORE){ suspend(ctx,true); log("-----> " + ctx.getKeyRegistrationState()); return false;
context.getKeyRegistrationState() == Context.KeyRegistrationState.CANCEL) { protocolHandler.expireKey(selectionKey);
if (ctx.getKeyRegistrationState() != Context.KeyRegistrationState.NONE){ ctx.setAttribute(ProtocolFilter.SUCCESSFUL_READ,
ctx.getSelectorHandler(); final SelectionKey key = ctx.getSelectionKey(); final Context.KeyRegistrationState state = ctx.getKeyRegistrationState(); final Protocol protocol = ctx.getProtocol();
if (context.getKeyRegistrationState() != Context.KeyRegistrationState.CANCEL) {