}
return AutoBeanCodex.encode(bean).getPayload();
}
public void processPayload(final Receiver<Void> receiver, String payload) {
ResponseMessage response =
AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, ResponseMessage.class, payload).as();
if (response.getGeneralFailure() != null) {
ServerFailureMessage failure = response.getGeneralFailure();
ServerFailure fail =
new ServerFailure(failure.getMessage(), failure.getExceptionType(), failure
.getStackTrace(), failure.isFatal());
fail(receiver, fail);
return;
}
// Process violations and then stop
if (response.getViolations() != null) {
Set<ConstraintViolation<?>> errors = new HashSet<ConstraintViolation<?>>();
for (ViolationMessage message : response.getViolations()) {
errors.add(new MyConstraintViolation(message));
}
violation(receiver, errors);
return;
}
// Process operations
processReturnOperations(response);
// Send return values
Set<Throwable> causes = null;
for (int i = 0, j = state.invocations.size(); i < j; i++) {
try {
if (response.getStatusCodes().get(i)) {
state.invocations.get(i).onSuccess(response.getInvocationResults().get(i));
} else {
ServerFailureMessage failure =
AutoBeanCodex.decode(MessageFactoryHolder.FACTORY, ServerFailureMessage.class,
response.getInvocationResults().get(i)).as();
state.invocations.get(i).onFail(
new ServerFailure(failure.getMessage(), failure.getExceptionType(), failure
.getStackTrace(), failure.isFatal()));
}
} catch (Throwable t) {