/* package */ public void configureContext(Context ctx,SelectorHandler selectorHandler){ ctx.setSelectorHandler(selectorHandler); ctx.setPipeline(selectorHandler.pipeline()); ctx.setAsyncQueueReader(selectorHandler.getAsyncQueueReader()); ctx.setAsyncQueueWriter(selectorHandler.getAsyncQueueWriter()); }
/** * Invoke a CallbackHandler via a Context instance. * @param context {@link Context} * @throws java.io.IOException */ protected void invokeCallbackHandler(CallbackHandler callbackHandler, Context context) throws IOException { IOEvent<Context>ioEvent = new IOEvent.DefaultIOEvent<Context>(context); context.setIOEvent(ioEvent); // Added because of incompatibility with Grizzly 1.6.0 context.setSelectorHandler(this); try { CallbackHandlerContextTask task = CallbackHandlerContextTask.poll(); task.setCallBackHandler(callbackHandler); boolean isRunInSeparateThread = true; if (callbackHandler instanceof CallbackHandlerDescriptor) { isRunInSeparateThread = ((CallbackHandlerDescriptor) callbackHandler). isRunInSeparateThread(context.getCurrentOpType()); } context.execute(task, isRunInSeparateThread); } catch (PipelineFullException ex) { throw new IOException(ex.getMessage()); } }
serverCtx.setController(this); serverCtx.setSelectorHandler(selectorHandler);
/** * Polls {@link Context} from pool and initializes it. * * @param serverContext {@link Controller} context * @param key {@link SelectionKey} * @return {@link Context} */ protected Context pollContext(final Context serverContext, final SelectionKey key, final Context.OpType opType) { ProtocolChain protocolChain = instanceHandler != null ? instanceHandler.poll() : serverContext.getController().getProtocolChainInstanceHandler().poll(); final Context context = serverContext.getController().pollContext(key, opType); context.setSelectionKey(key); context.setSelectorHandler(this); context.setAsyncQueueReader(asyncQueueReader); context.setAsyncQueueWriter(asyncQueueWriter); context.setProtocolChain(protocolChain); return context; }