Search in sources :

Example 1 with IMessageChannel

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));
            }
        }
    };
}
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 IMessageChannel

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

Example 3 with IMessageChannel

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

Aggregations

IMessageChannel (org.jowidgets.message.api.IMessageChannel)3 CancelMessage (org.jowidgets.invocation.common.impl.CancelMessage)2 ICancelService (org.jowidgets.invocation.common.api.ICancelService)1 IResponseService (org.jowidgets.invocation.common.api.IResponseService)1 ResponseMessage (org.jowidgets.invocation.common.impl.ResponseMessage)1 Tuple (org.jowidgets.util.Tuple)1