use of org.jowidgets.message.api.IMessageChannel in project jo-client-platform by jo-source.
the class InvocationClientImpl method getCancelService.
@Override
public ICancelService getCancelService() {
return new ICancelService() {
@Override
public void canceled(final Object invocationId) {
Assert.paramNotNull(invocationId, "invocationId");
final TimeStampedObject<IMessageChannel> ackInvocation = acknowledgedInvocations.get(invocationId);
if (ackInvocation != null) {
final CancelMessage message = new CancelMessage(invocationId);
ackInvocation.getObject().send(message, new ExceptionCallback(invocationClientServiceRegistry, invocationId));
canceledInvocations.remove(invocationId);
} else {
canceledInvocations.put(invocationId, new TimeStampedObject<Object>(invocationId));
}
}
};
}
use of org.jowidgets.message.api.IMessageChannel 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.message.api.IMessageChannel in project jo-client-platform by jo-source.
the class InvocationClientImpl method registerAcknowledge.
void registerAcknowledge(final Object invocationId, final IMessageChannel replyChannel) {
if (canceledInvocations.remove(invocationId) != null) {
final CancelMessage message = new CancelMessage(invocationId);
replyChannel.send(message, new ExceptionCallback(invocationClientServiceRegistry, invocationId));
} else {
acknowledgedInvocations.put(invocationId, new TimeStampedObject<IMessageChannel>(replyChannel));
}
}
Aggregations