public ConnectorHandler acquireConnectorHandler(Protocol protocol){ ConnectorHandler ch = null; SelectorHandler selectorHandler = controller.getSelectorHandler(protocol); if (selectorHandler != null) { ch = selectorHandler.acquireConnectorHandler(); ch.setController(controller); } return ch; }
protected void afterCall() { SelectionKey currentKey = context.getSelectionKey(); SelectionKeyHandler selectionKeyHandler = context. getSelectorHandler().getSelectionKeyHandler(); selectionKeyHandler.postProcess(currentKey); }
/** * Cancel the current {@link SelectionKey} */ public void cancelKey(SelectionKey key){ selectorHandler.getSelectionKeyHandler().cancel(key); }
@Override public void onRead(IOEvent<Context> ioEvent) { // We don't expect any read, so if any data comes - we suppose it's "close" notification final Context context = ioEvent.attachment(); final SelectionKey selectionKey = context.getSelectionKey(); // close the channel context.getSelectorHandler().addPendingKeyCancel(selectionKey); }
protected void beforeCall() { SelectionKey currentKey = context.getSelectionKey(); SelectionKeyHandler selectionKeyHandler = context. getSelectorHandler().getSelectionKeyHandler(); selectionKeyHandler.process(currentKey); }
public boolean postExecute(Context ctx) throws IOException { if (isInitilizedOk) { final ProtocolChain chain = ctx.getProtocolChain(); chain.removeFilter(this); ctx.setAttribute(ProtocolChain.PROTOCOL_CHAIN_POST_INSTRUCTION, ProtocolChainInstruction.REINVOKE); } return true; } }
/* package */ public void configureContext(Context ctx,SelectorHandler selectorHandler){ ctx.setSelectorHandler(selectorHandler); ctx.setPipeline(selectorHandler.pipeline()); ctx.setAsyncQueueReader(selectorHandler.getAsyncQueueReader()); ctx.setAsyncQueueWriter(selectorHandler.getAsyncQueueWriter()); }
protected Object doCall() throws Exception { context.getProtocolChain().execute(context); return null; }
public void releaseConnectorHandler(ConnectorHandler connectorHandler){ SelectorHandler selectorHandler = controller.getSelectorHandler(connectorHandler.protocol()); if (selectorHandler != null) { selectorHandler.releaseConnectorHandler(connectorHandler); } } }
public void recycle() { if (context != null) { context.getController().returnContext(context); } context = null; }
/** * Registers <code>SSLConnectorHandler<code>'s {@link SelectionKey} * to listen channel operations. * @param ops interested channel operations */ private void registerSelectionKeyFor(int ops) { SelectionKey key = getSelectionKey(); selectorHandler.register(key, ops); }
/** * {@inheritDoc} */ @Override public void process(SelectionKey key) { super.process(key); removeExpirationStamp(key); }
/** * {@inheritDoc} */ @Override public void postProcess(SelectionKey key) { super.postProcess(key); addExpirationStamp(key); }
/** * {@inheritDoc} */ @Override public void copyTo(Copyable copy) { super.copyTo(copy); SelectorThreadHandler copyHandler = (SelectorThreadHandler) copy; copyHandler.selectorThread = selectorThread; }
@Override public void copyTo(Copyable copy) { super.copyTo(copy); SSLSelectorThreadHandler copyHandler = (SSLSelectorThreadHandler) copy; copyHandler.selectorThread = selectorThread; }
/** * {@inheritDoc} */ public void close(SelectionKey key) { cancel(key); }
/** * Return an instance of a {@link ConnectorHandler} based on the * Protocol requested. */ public ConnectorHandler acquireConnectorHandler(Protocol protocol){ return connectorHandlerPool.acquireConnectorHandler(protocol); }
/** * Return a {@link ConnectorHandler} to the pool of ConnectorHandler. * Any reference to the returned must not be re-used as that instance * can always be acquired again, causing unexpected results. */ public void releaseConnectorHandler(ConnectorHandler connectorHandler){ connectorHandlerPool.releaseConnectorHandler(connectorHandler); }
@Override public void recycle() { callBackHandler = null; super.recycle(); }
/** * Cancel the current {@link SelectionKey} */ public void cancelKey(SelectionKey key){ selectorHandler.getSelectionKeyHandler().cancel(key); }