Search in sources :

Example 1 with CancelMessage

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));
            }
        }
    };
}
Also used : CancelMessage(org.jowidgets.invocation.common.impl.CancelMessage) IMessageChannel(org.jowidgets.message.api.IMessageChannel) ICancelService(org.jowidgets.invocation.common.api.ICancelService)

Example 2 with CancelMessage

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));
    }
}
Also used : CancelMessage(org.jowidgets.invocation.common.impl.CancelMessage) IMessageChannel(org.jowidgets.message.api.IMessageChannel)

Example 3 with CancelMessage

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);
    }
}
Also used : CancelMessage(org.jowidgets.invocation.common.impl.CancelMessage) MethodInvocationMessage(org.jowidgets.invocation.common.impl.MethodInvocationMessage) AcknowledgeMessage(org.jowidgets.invocation.common.impl.AcknowledgeMessage) IExceptionCallback(org.jowidgets.message.api.IExceptionCallback) ResponseMessage(org.jowidgets.invocation.common.impl.ResponseMessage)

Aggregations

CancelMessage (org.jowidgets.invocation.common.impl.CancelMessage)3 IMessageChannel (org.jowidgets.message.api.IMessageChannel)2 ICancelService (org.jowidgets.invocation.common.api.ICancelService)1 AcknowledgeMessage (org.jowidgets.invocation.common.impl.AcknowledgeMessage)1 MethodInvocationMessage (org.jowidgets.invocation.common.impl.MethodInvocationMessage)1 ResponseMessage (org.jowidgets.invocation.common.impl.ResponseMessage)1 IExceptionCallback (org.jowidgets.message.api.IExceptionCallback)1