@SuppressWarnings({"unchecked"})
public void callback(Message message) {
Object[] parms = message.get(Object[].class, "MethodParms");
if ((parms == null && targetTypes.length != 0) || (parms.length != targetTypes.length)) {
throw new MessageDeliveryFailure("wrong number of arguments sent to endpoint. (received: "
+ (parms == null ? 0 : parms.length) + "; required: " + targetTypes.length + ")");
}
for (int i = 0; i < parms.length; i++) {
if (parms[i] != null && !targetTypes[i].isAssignableFrom(parms[i].getClass())) {
if (canConvert(targetTypes[i], parms[i].getClass())) {
parms[i] = convert(parms[i], targetTypes[i]);
} else {
throw new MessageDeliveryFailure("type mismatch in method parameters");
}
}
}
try {
createConversation(message)
.subjectProvided().signalling()
.with("MethodReply", method.invoke(genericSvc, parms))
.noErrorHandling().sendNowWith(bus);
}
catch (Exception e) {
throw new MessageDeliveryFailure("error invoking endpoint", e);
}
}