/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.http.server.reactive.boot;

import reactor.core.util.ReactiveState;
import reactor.io.buffer.Buffer;
import reactor.io.net.ReactiveNet;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
import org.springframework.util.Assert;

/**
 * @author Stephane Maldini
 */
public class ReactorHttpServer extends HttpServerSupport
		implements InitializingBean, HttpServer, ReactiveState.FeedbackLoop, ReactiveState.ActiveUpstream {

	private ReactorHttpHandlerAdapter reactorHandler;

	private reactor.io.net.http.HttpServer<Buffer, Buffer> reactorServer;

	private boolean running;

	@Override
	public boolean isRunning() {
		return this.running;
	}

	@Override
	public void afterPropertiesSet() throws Exception {

		Assert.notNull(getHttpHandler());
		this.reactorHandler = new ReactorHttpHandlerAdapter(getHttpHandler());

		this.reactorServer = (getPort() != -1 ? ReactiveNet.httpServer(getPort()) :
				ReactiveNet.httpServer());
	}

	@Override
	public Object delegateInput() {
		return reactorServer;
	}

	@Override
	public Object delegateOutput() {
		return reactorServer;
	}

	@Override
	public boolean isStarted() {
		return running;
	}

	@Override
	public boolean isTerminated() {
		return !running;
	}

	@Override
	public void start() {
		if (!this.running) {
			try {
				this.reactorServer.startAndAwait(reactorHandler);
				this.running = true;
			}
			catch (InterruptedException ex) {
				throw new IllegalStateException(ex);
			}
		}
	}

	@Override
	public void stop() {
		if (this.running) {
			this.reactorServer.shutdown();
			this.running = false;
		}
	}

}

@@ -695,25 +695,63 @@
 ore.
-util.ReactiveStat
+trait.Completable;%0Aimport reactor.core.trait.Connectabl
 e;%0Ai
@@ -1133,64 +1133,32 @@
 er, 
-ReactiveState.FeedbackLoop, ReactiveState.ActiveUpstream
+Connectable, Completable
  %7B%0A%0A
@@ -1690,24 +1690,25 @@
  Object 
-delega
+connec
 te
+d
 Input() 
@@ -1767,16 +1767,17 @@
 ect 
-delega
+connec
 te
+d
 Outp
@@ -2304,10 +2304,67 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09@Override%0A%09public Object upstream() %7B%0A%09%09return null;%0A%09%7D%0A
 %7D%0A

fix signature