Refine search
private void flushOnSSLHandshakeComplete() throws IOException { final FilterChain filterChain = context.getFilterChain(); final int idx = filterChain.indexOfType(SSLFilter.class); assert (idx != -1); final SSLFilter filter = (SSLFilter) filterChain.get(idx); final Connection c = context.getConnection(); filter.addHandshakeListener(new SSLBaseFilter.HandshakeListener() { public void onStart(Connection connection) { } @Override public void onFailure(final Connection connection, final Throwable t) { connection.closeWithReason(Exceptions.makeIOException(t)); } public void onComplete(Connection connection) { if (c.equals(connection)) { filter.removeHandshakeListener(this); feederFlush(c); } } }); filter.handshake(context.getConnection(), null); }
@Override public void onRemoved(final FilterChain filterChain) { if (optimizedTransportFilter != null) { final int sslTransportFilterIdx = filterChain.indexOf(optimizedTransportFilter); if (sslTransportFilterIdx >= 0) { SSLTransportFilterWrapper wrapper = (SSLTransportFilterWrapper) filterChain.get(sslTransportFilterIdx); filterChain.set(sslTransportFilterIdx, wrapper.wrappedFilter); } } }
public void fail(final Throwable error) { getFilterChain().fail(this, error); }
public HttpServerFilter getHttpServerFilter() { if (httpServerFilter == null) { final int idx = filterChain.indexOfType(HttpServerFilter.class); if (idx == -1) { return null; } httpServerFilter = (HttpServerFilter) filterChain.get(idx); } return httpServerFilter; }
public FilterChainContext copy() { final FilterChain p = getFilterChain(); final FilterChainContext newContext = p.obtainFilterChainContext(getConnection()); newContext.setOperation(getOperation()); newContext.setCloseable(getCloseable()); internalContext.softCopyTo(newContext.internalContext); newContext.setStartIdx(getStartIdx()); newContext.setEndIdx(getEndIdx()); newContext.setFilterIdx(getFilterIdx()); getAttributes().copyTo(newContext.getAttributes()); notifyCopy(this, newContext, copyListeners); return newContext; }
/** * Invoke this method to trigger processing to abtain certificates from * the remote peer. Do not fire this event down stream manually. * * Register a {@link CompletionHandler} with the returned * {@link GrizzlyFuture} to be notified when the result is available * to prevent blocking. * * @param ctx the current {@link FilterChainContext} * * @return a {@link GrizzlyFuture} representing the processing of * the remote peer certificates. */ public GrizzlyFuture<Object[]> trigger(final FilterChainContext ctx) { ctx.getFilterChain().fireEventDownstream(ctx.getConnection(), this, null); return certsFuture; }
public void flush(final CompletionHandler completionHandler) { final FilterChainContext newContext = getFilterChain().obtainFilterChainContext(getConnection()); newContext.operation = Operation.EVENT; newContext.closeable = closeable; newContext.event = TransportFilter.createFlushEvent(completionHandler); newContext.transportFilterContext.configureBlocking(transportFilterContext.isBlocking()); newContext.addressHolder = addressHolder; newContext.startIdx = filterIdx - 1; newContext.filterIdx = filterIdx - 1; newContext.endIdx = -1; getAttributes().copyTo(newContext.getAttributes()); ProcessorExecutor.execute(newContext.internalContext); }
private void setIdleTimeout(final FilterChainContext ctx) { final FilterChain filterChain = ctx.getFilterChain(); if (filterChain.indexOfType(IdleTimeoutFilter.class) >= 0) { IdleTimeoutFilter.setCustomTimeout(ctx.getConnection(), wsTimeoutMS, TimeUnit.MILLISECONDS); } }
@Override public final int defaultStartIdx(FilterChainContext context) { if (context.getFilterIdx() != FilterChainContext.NO_FILTER_INDEX) { return context.getFilterIdx(); } final int idx = context.getFilterChain().size() - 1; context.setFilterIdx(idx); return idx; }
public FilterChainContext createContext(final Connection connection, final Operation operation) { FilterChain filterChain = (FilterChain) connection.getProcessor(); final FilterChainContext ctx = filterChain.obtainFilterChainContext(connection); final int idx = filterChain.indexOf(this); ctx.setOperation(operation); ctx.setFilterIdx(idx); ctx.setStartIdx(idx); return ctx; }
@Override public FilterChain build() { final FilterChain fc = new DefaultFilterChain(); fc.addAll(patternFilterChain); return fc; } }
/** * Returns {@link FilterChain} instance, if it's interested in processing * passed {@link IOEvent}, or <tt>null</tt> otherwise. * * @param ioEvent {@link IOEvent} to process. * @param connection {@link Connection}, where {@link IOEvent} occured. * * @return {@link FilterChain} instance, if it's interested in processing * passed {@link IOEvent}, or <tt>null</tt> otherwise. */ @Override public Processor select(IOEvent ioEvent, Connection connection) { FilterChain chain = builder.build(); if (chain.isInterested(ioEvent)) { return chain; } return null; } }
/** * Registers new {@link PUProtocol}. * * @param puProtocol {@link PUProtocol} */ public void register(final PUProtocol puProtocol) { final Filter filter = puProtocol.getFilterChain().get(0); if (filter != backChannelFilter) { throw new IllegalStateException("The first Filter in the protocol should be the BackChannelFilter"); } protocols.add(puProtocol); }
void sendMessageUpstream(final Http2Stream stream, final HttpPacket message) { final FilterChainContext upstreamContext = http2StreamChain.obtainFilterChainContext(connection, stream); final HttpContext httpContext = message.getHttpHeader() .getProcessingState().getHttpContext(); httpContext.attach(upstreamContext); sendMessageUpstream(stream, message, upstreamContext); }
public void testEventDownstream() throws Exception { final Connection connection = new TCPNIOConnection(TCPNIOTransportBuilder.newInstance().build(), null); counterAttr.set(connection, new AtomicInteger(3)); final FilterChain chain = FilterChainBuilder.stateless() .add(new EventCounterFilter(0)) .add(new EventCounterFilter(1)) .add(new EventCounterFilter(2)) .add(new EventCounterFilter(3)) .build(); final FutureImpl<FilterChainContext> resultFuture = Futures.createSafeFuture(); chain.fireEventDownstream(connection, DEC_EVENT, Futures.toCompletionHandler(resultFuture)); resultFuture.get(10, TimeUnit.SECONDS); }
public FilterChainContext copy() { final FilterChain p = getFilterChain(); final FilterChainContext newContext = p.obtainFilterChainContext(getConnection()); newContext.setOperation(getOperation()); newContext.setCloseable(getCloseable()); internalContext.softCopyTo(newContext.internalContext); newContext.setStartIdx(getStartIdx()); newContext.setEndIdx(getEndIdx()); newContext.setFilterIdx(getFilterIdx()); getAttributes().copyTo(newContext.getAttributes()); notifyCopy(this, newContext, copyListeners); return newContext; }
/** * Invoke this method to trigger processing to abtain certificates from * the remote peer. Do not fire this event down stream manually. * * Register a {@link CompletionHandler} with the returned * {@link GrizzlyFuture} to be notified when the result is available * to prevent blocking. * * @param ctx the current {@link FilterChainContext} * * @return a {@link GrizzlyFuture} representing the processing of * the remote peer certificates. */ public GrizzlyFuture<Object[]> trigger(final FilterChainContext ctx) { ctx.getFilterChain().fireEventDownstream(ctx.getConnection(), this, null); return certsFuture; }
public void flush(final CompletionHandler completionHandler) { final FilterChainContext newContext = getFilterChain().obtainFilterChainContext(getConnection()); newContext.operation = Operation.EVENT; newContext.closeable = closeable; newContext.event = TransportFilter.createFlushEvent(completionHandler); newContext.transportFilterContext.configureBlocking(transportFilterContext.isBlocking()); newContext.addressHolder = addressHolder; newContext.startIdx = filterIdx - 1; newContext.filterIdx = filterIdx - 1; newContext.endIdx = -1; getAttributes().copyTo(newContext.getAttributes()); ProcessorExecutor.execute(newContext.internalContext); }
protected void setIdleTimeout(final FilterChainContext ctx) { final FilterChain filterChain = ctx.getFilterChain(); if (filterChain.indexOfType(IdleTimeoutFilter.class) >= 0) { IdleTimeoutFilter.setCustomTimeout(ctx.getConnection(), wsTimeoutMS, TimeUnit.MILLISECONDS); } } }
@Override public final int defaultStartIdx(FilterChainContext context) { if (context.getFilterIdx() != FilterChainContext.NO_FILTER_INDEX) { return context.getFilterIdx(); } final int idx = context.getFilterChain().size() - 1; context.setFilterIdx(idx); return idx; }