private static FilterChainContext obtainProtocolChainContext(
      final FilterChainContext ctx, final FilterChain completeProtocolFilterChain) {

    final FilterChainContext newFilterChainContext =
        completeProtocolFilterChain.obtainFilterChainContext(
            ctx.getConnection(),
            ctx.getStartIdx() + 1,
            completeProtocolFilterChain.size(),
            ctx.getFilterIdx() + 1);

    newFilterChainContext.setAddressHolder(ctx.getAddressHolder());
    newFilterChainContext.setMessage(ctx.getMessage());
    newFilterChainContext.getInternalContext().setIoEvent(ctx.getInternalContext().getIoEvent());
    ctx.getConnection().setProcessor(completeProtocolFilterChain);
    return newFilterChainContext;
  }
Пример #2
0
  /** Immediately shuts down the <code>HttpServer</code> instance. */
  public synchronized void shutdownNow() {

    if (state == State.STOPPED) {
      return;
    }
    state = State.STOPPED;

    try {

      if (serverConfig.isJmxEnabled()) {
        for (final JmxEventListener l : serverConfig.getJmxEventListeners()) {
          l.jmxDisabled();
        }
      }

      tearDownHttpHandler();

      final String[] names = listeners.keySet().toArray(new String[listeners.size()]);
      for (final String name : names) {
        removeListener(name);
      }

      delayedExecutor.stop();
      delayedExecutor.destroy();
      delayedExecutor = null;

      stopAuxThreadPool();

      if (serverConfig.isJmxEnabled()) {
        disableJMX();
      }

    } catch (Exception e) {
      LOGGER.log(Level.WARNING, null, e);
    } finally {
      for (final NetworkListener listener : listeners.values()) {
        final FilterChain filterChain = listener.getTransport().getFilterChain();
        filterChain.clear();
      }

      if (shutdownFuture != null) {
        shutdownFuture.result(this);
      }
    }
  }