use of com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand in project dolphin-platform by canoo.
the class ServerConnector method receive.
/**
* doesn't fail on missing commands
*/
public List<Command> receive(final Command command) {
Assert.requireNonNull(command, "command");
LOG.trace("Received command of type {}", command.getClass().getSimpleName());
// collecting parameter pattern
List<Command> response = new LinkedList();
if (!(command instanceof InterruptLongPollCommand)) {
// signal commands must not update thread-confined state
for (DolphinServerAction it : dolphinServerActions) {
// todo: can be deleted as soon as all action refer to the SMS
it.setDolphinResponse(response);
}
serverModelStore.setCurrentResponse(response);
}
List<CommandHandler> actions = registry.getActionsFor(command.getClass());
if (actions.isEmpty()) {
LOG.warn("There is no server action registered for received command type {}, known commands types are {}", command.getClass().getSimpleName(), registry.getActions().keySet());
return response;
}
// copying the list of actions allows an Action to unregister itself
// avoiding ConcurrentModificationException to be thrown by the loop
List<CommandHandler> actionsCopy = new ArrayList<CommandHandler>();
actionsCopy.addAll(actions);
try {
for (CommandHandler action : actionsCopy) {
action.handleCommand(command, response);
}
} catch (Exception exception) {
throw exception;
}
return response;
}
Aggregations