use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class InMemoryClientConnector method transmit.
@Override
public List<Command> transmit(final List<Command> commands) {
LOG.trace("transmitting {} commands", commands.size());
if (serverConnector == null) {
LOG.warn("no server connector wired for in-memory connector");
return Collections.EMPTY_LIST;
}
if (sleepMillis > 0) {
try {
Thread.sleep(sleepMillis);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
List<Command> result = new LinkedList<Command>();
for (Command command : commands) {
LOG.trace("processing {}", command);
// there is no need for encoding since we are in-memory
result.addAll(serverConnector.receive(command));
}
return result;
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class AbstractDolphinBasedTest method createServerModelStore.
protected ServerModelStore createServerModelStore() {
DefaultInMemoryConfig config = new DefaultInMemoryConfig(DirectExecutor.getInstance());
config.getServerConnector().registerDefaultActions();
ServerModelStore store = config.getServerModelStore();
List<Command> commands = new ArrayList<>();
store.setCurrentResponse(commands);
return store;
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class StoreAttributeActionTests method setUp.
@BeforeMethod
public void setUp() throws Exception {
serverModelStore = new ServerModelStore();
serverModelStore.setCurrentResponse(new ArrayList<Command>());
registry = new ActionRegistry();
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class DolphinContext method handle.
public List<Command> handle(final List<Command> commands) {
active = true;
try {
final List<Command> results = new LinkedList<>();
for (final Command command : commands) {
results.addAll(serverConnector.receive(command));
hasResponseCommands = !results.isEmpty();
}
return results;
} finally {
active = false;
}
}
use of com.canoo.dp.impl.remoting.legacy.communication.Command in project dolphin-platform by canoo.
the class DolphinContext method registerCommand.
protected <T extends Command> void registerCommand(final ActionRegistry registry, final Class<T> commandClass, final Consumer<T> handler) {
Assert.requireNonNull(registry, "registry");
Assert.requireNonNull(commandClass, "commandClass");
Assert.requireNonNull(handler, "handler");
registry.register(commandClass, new CommandHandler() {
@Override
public void handleCommand(final Command command, final List response) {
LOG.trace("Handling {} for DolphinContext {}", commandClass.getSimpleName(), getId());
handler.accept((T) command);
}
});
}
Aggregations