Reputation: 56912
I have the following Camel route:
RequestToOrderTransform requestToOrderTransform =
new RequestToOrderTransform();
from("ghttp:///processOrder")
.transform(requestToOrderTransform)
.bean(OrderProcessor.class)
.to("direct:endOfRoute");
It uses Camel-GAE to receive an HttpServletRequest
from a GAE servlet (processOrder
), then transforms the request into an Order
POJO, and finally processes that order (OrderProcessor
).
I would like to write my own org.apache.camel.Expression
(requestToOrderTransform
) and so far I have the skeleton/framework:
public class RequestToOrderTransform implements Expression {
@Override
public <T> T evaluate(Exchange arg0, Class<T> arg1) {
// ???
return null;
}
}
In here, somehow, I have to transform an HttpServletRequest
(which I believe is what I get from the GAE servlet consumer) into my own Order
POJO. But I'm not sure how to obtain the HttpServletRequest
in the first place. Once I have the request I can extract out the necessary params and then instantiate my new order instance. But then I'm not sure what to do with the Order
so that Camel knows to route it and not the original HttpServletRequest
.
So I ask:
HttpServletRequest
(or whatever object I get from the GAE servlet endpoint)?Order
instance so that Camel uses it as the unit to route (on to the OrderProcessor
bean)?Thanks in advance!
Upvotes: 0
Views: 2342
Reputation: 22279
Writing an expression seems like a bad way to go, when all you really is implementing is a message translator. But any way, just grab the body as string an do whatever with it.
arg0.getIn().getBody(String.class)
I'm not sure what data you get from GAE in this case, but if it's structured (json,xml,flat files, csv), you might want to look at the various data formats that does string to java object conversion for you.
Upvotes: 2