package zero.downtime.soa.api;

import org.apache.camel.builder.RouteBuilder;
import org.eclipse.jetty.server.Server;

/**
 * @author magonzal
 * @version 1.0.0
 */
public class HelloServiceApi extends RouteBuilder {

	@Override
	public void configure() throws Exception {
		//@formatter:off
		restConfiguration().component("jetty")
			.host("localhost")
			.port(getRandomServerPort());

		rest("/rest-api")
			.get("/sync/{user}").to("direct-vm:hello")
			.get("/async/{user}").to("direct-vm:hello");
		//@formatter:on
	}

	/**
	 * Looks up an available port number on the host
	 * by creating a dummy Jetty Server.
	 *
	 * TODO: there's probably a better way to do this
	 *
	 * @return a port number available for use
	 * @throws Exception
	 */
	protected int getRandomServerPort() throws Exception {
		Server server = new Server(0);
		server.start();
		int port = server.getConnectors()[0].getLocalPort();
		server.stop();
		return port;
	}
}


@@ -123,24 +123,117 @@
 %0A * 
-@author mag
+Rest DSL uysing the jetty component to expose the Hello Service Add javadocAPI%0A *%0A * @author Mariano G
 onzal
+ez
 %0A * 
@@ -244,16 +244,28 @@
 sion 1.0
+%0A * @since 1
 .0%0A */%0Ap

Add javadoc