While there is nothing wrong with the approach they thought about I think that Apache Camel would give them a more powerful setup to what they were looking for.
So, here is a sample configuration, that I created as a demo project, using Apache Camel Jetty component enabling HTTP endpoints.
In our Apache Camel route definition (using the Spring XML approach in this case) we'll have to define the Jetty endpoint similar to this:
<route id="Jetty_Sample">
<from uri="jetty:http://localhost:8888/myBookService"/>
where we basically specify the address we'll be consuming HTTP requests. There are many options we can use to fine tuning the Jetty component but we'll keep it with only the required information for simplicity.
Then, the next step is going to be a regular approach to any other route we have developed so far. In this example, we're going to use a LOG component and then a custom Process pointing to a simple Java bean where we perform the processing of every request.
<log logName="HTTP LOG" loggingLevel="INFO" message="HTTP REQUEST: ${in.header.bookid}"/>
<process ref="myBookService"/>
package com.fusesource.fusebyexample;
import org.apache.camel.Processor;
import org.apache.camel.Exchange;
public class myBookService implements Processor {
public void process(Exchange exchange) throws Exception {
// Grab the booked header value
String bookId = (String) exchange.getIn().getHeader("bookid");
// send a html response
exchange.getOut().setBody("<html><body>Book " + bookId + " is Camel in Action.</body></html>");
}
}
The last thing we need to add to our Apache Camel context file is the bean definition which could be simply like the line below:
<bean class="com.fusesource.fusebyexample.myBookService" id="myBookService"/>
That's all we need... To test the integration use case described above, we can simply run the Camel route, open any web browser and hit the following URL:
http://localhost:8888/myBookService?bookid=91942
where the Camel route will log the following in the console:
HTTP LOG INFO HTTP REQUEST: 91942
If you want to use a simple HTML form, here is something to easily test the Camel route...
<html>
<body>
<form action="http://localhost:8888/myBookService">
Book ID: <input text name="bookId"/>
<input type="submit" value="Submit">
</form>
</body>
</html>
I've also included the test HTML form on the source code package of this configuration available here:
Enjoy the ride!