class TestHandler implements LogicalHandler<LogicalMessageContext> {
public boolean handleMessage(LogicalMessageContext ctx) {
try {
Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
LogicalMessage msg = ctx.getMessage();
JAXBContext jaxbContext = JAXBContext
.newInstance(ObjectFactory.class,
org.apache.hello_world_xml_http.wrapped.types.ObjectFactory.class);
Object payload = ((JAXBElement<?>)msg.getPayload(jaxbContext)).getValue();
org.apache.handlers.types.AddNumbers req =
(org.apache.handlers.types.AddNumbers)payload;
assertEquals(10, req.getArg0());
assertEquals(20, req.getArg1());
req.setArg0(11);
req.setArg1(21);
ObjectFactory of = new ObjectFactory();
of.createAddNumbers(req);
msg.setPayload(of.createAddNumbers(req), jaxbContext);
} else {
LogicalMessage msg = ctx.getMessage();
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Object payload = ((JAXBElement<?>)msg.getPayload(jaxbContext)).getValue();
org.apache.handlers.types.AddNumbersResponse res =
(org.apache.handlers.types.AddNumbersResponse)payload;
assertEquals(333, res.getReturn());
res.setReturn(222);
ObjectFactory of = new ObjectFactory();
msg.setPayload(of.createAddNumbersResponse(res), jaxbContext);
}
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());