use of org.jowidgets.invocation.common.impl.ResponseMessage in project jo-client-platform by jo-source.
the class InvocationClientImpl method getResponseService.
@Override
public IResponseService getResponseService() {
return new IResponseService() {
@Override
public void response(final Object requestId, final Object response) {
Assert.paramNotNull(requestId, "requestId");
final TimeStampedObject<Tuple<Object, IMessageChannel>> request = interimRequests.remove(requestId);
if (request != null) {
final Tuple<Object, IMessageChannel> tuple = request.getObject();
final ResponseMessage message = new ResponseMessage(requestId, response);
tuple.getSecond().send(message, new ExceptionCallback(invocationClientServiceRegistry, tuple.getFirst()));
} else {
throw new IllegalStateException("The request id '" + requestId + "' is not known");
}
}
};
}
use of org.jowidgets.invocation.common.impl.ResponseMessage in project jo-client-platform by jo-source.
the class InvocationServerMessageReceiver method onMessage.
@Override
public void onMessage(final Object message, final IMessageChannel replyChannel) {
if (message instanceof MethodInvocationMessage) {
final MethodInvocationMessage invocationMessage = (MethodInvocationMessage) message;
final Object invocationId = invocationMessage.getInvocationId();
invocationServer.registerInvocation(invocationId, replyChannel);
final IExceptionCallback exceptionCallback = new IExceptionCallback() {
@Override
public void exception(final Throwable throwable) {
invocationServer.unregisterInvocation(invocationId);
invocationServerServiceRegistry.onCancel(invocationId);
}
};
replyChannel.send(new AcknowledgeMessage(invocationId), exceptionCallback);
invocationServerServiceRegistry.onMethodInvocation((MethodInvocationMessage) message);
} else if (message instanceof CancelMessage) {
final CancelMessage cancelMessage = (CancelMessage) message;
invocationServerServiceRegistry.onCancel(cancelMessage);
invocationServer.unregisterInvocation(cancelMessage.getInvocationId());
} else if (message instanceof ResponseMessage) {
invocationServerServiceRegistry.onResponse((ResponseMessage) message);
}
}
Aggregations