/** * Invokes {@link CommandCallback#onResult(CommandMessage, CommandResultMessage)} with given {@code result} on * the wrapped callback. * * @param result the result of the command */ public void reportResult(CommandResultMessage<R> result) { onResult(getMessage(), result); }
/** * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a * {@link CommandBusConnectorCommunicationException}. * * @param channelId the channel identifier */ public void cancelCallbacks(A channelId) { Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator(); while (callbacks.hasNext()) { CommandCallbackWrapper wrapper = callbacks.next(); if (wrapper.getChannelIdentifier().equals(channelId)) { wrapper.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException( String.format("Connection error while waiting for a response on command %s", wrapper.getMessage().getCommandName())))); callbacks.remove(); } } }
/** * Invokes {@link CommandCallback#onSuccess(CommandMessage, Object)} with given {@code result} on the wrapped * callback. * * @param result the result of the command */ public void success(R result) { onSuccess(getMessage(), result); }
/** * Invokes {@link CommandCallback#onFailure(CommandMessage, Throwable)} with given exception on the wrapped * callback. * * @param e cause for the failure */ public void fail(Throwable e) { onFailure(getMessage(), e); }
/** * Invokes {@link CommandCallback#onResult(CommandMessage, CommandResultMessage)} with given {@code result} on * the wrapped callback. * * @param result the result of the command */ public void reportResult(CommandResultMessage<R> result) { onResult(getMessage(), result); }
/** * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a * {@link CommandBusConnectorCommunicationException}. * * @param channelId the channel identifier */ public void cancelCallbacks(A channelId) { Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator(); while (callbacks.hasNext()) { CommandCallbackWrapper wrapper = callbacks.next(); if (wrapper.getChannelIdentifier().equals(channelId)) { wrapper.fail(new CommandBusConnectorCommunicationException( String.format("Connection error while waiting for a response on command %s", wrapper.getMessage().getCommandName()))); callbacks.remove(); } } }
/** * Removes all callbacks for a given channel. Registered callbacks will receive a failure response containing a * {@link CommandBusConnectorCommunicationException}. * * @param channelId the channel identifier */ public void cancelCallbacks(A channelId) { Iterator<CommandCallbackWrapper> callbacks = this.callbacks.values().iterator(); while (callbacks.hasNext()) { CommandCallbackWrapper wrapper = callbacks.next(); if (wrapper.getChannelIdentifier().equals(channelId)) { wrapper.reportResult(asCommandResultMessage(new CommandBusConnectorCommunicationException( String.format("Connection error while waiting for a response on command %s", wrapper.getMessage().getCommandName())))); callbacks.remove(); } } }