use of org.jowidgets.invocation.common.impl.CancelMessage 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.invocation.common.impl.CancelMessage 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));
}
}
use of org.jowidgets.invocation.common.impl.CancelMessage 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