Search in sources :

Example 31 with Command

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;
}
Also used : Command(com.canoo.dp.impl.remoting.legacy.communication.Command) LinkedList(java.util.LinkedList)

Example 32 with Command

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;
}
Also used : Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ArrayList(java.util.ArrayList)

Example 33 with Command

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();
}
Also used : Command(com.canoo.dp.impl.remoting.legacy.communication.Command) ChangeAttributeMetadataCommand(com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand) ServerModelStore(com.canoo.dp.impl.server.legacy.ServerModelStore) ActionRegistry(com.canoo.dp.impl.server.legacy.communication.ActionRegistry) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 34 with Command

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;
    }
}
Also used : CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) DestroyContextCommand(com.canoo.dp.impl.remoting.commands.DestroyContextCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) DestroyControllerCommand(com.canoo.dp.impl.remoting.commands.DestroyControllerCommand) LinkedList(java.util.LinkedList)

Example 35 with Command

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);
        }
    });
}
Also used : CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) DestroyContextCommand(com.canoo.dp.impl.remoting.commands.DestroyContextCommand) CallActionCommand(com.canoo.dp.impl.remoting.commands.CallActionCommand) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand) InterruptLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) StartLongPollCommand(com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand) DestroyControllerCommand(com.canoo.dp.impl.remoting.commands.DestroyControllerCommand) List(java.util.List) LinkedList(java.util.LinkedList) CommandHandler(com.canoo.dp.impl.server.legacy.communication.CommandHandler)

Aggregations

Command (com.canoo.dp.impl.remoting.legacy.communication.Command)43 CreatePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand)25 ValueChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.ValueChangedCommand)23 Test (org.testng.annotations.Test)22 EmptyCommand (com.canoo.dp.impl.remoting.legacy.communication.EmptyCommand)19 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)18 StartLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.StartLongPollCommand)10 InterruptLongPollCommand (com.canoo.dp.impl.remoting.legacy.commands.InterruptLongPollCommand)8 ChangeAttributeMetadataCommand (com.canoo.dp.impl.remoting.legacy.communication.ChangeAttributeMetadataCommand)8 ArrayList (java.util.ArrayList)8 PresentationModelDeletedCommand (com.canoo.dp.impl.remoting.legacy.communication.PresentationModelDeletedCommand)7 CreateContextCommand (com.canoo.dp.impl.remoting.commands.CreateContextCommand)5 LinkedList (java.util.LinkedList)5 ServerModelStore (com.canoo.dp.impl.server.legacy.ServerModelStore)4 ClientAttribute (com.canoo.dp.impl.client.legacy.ClientAttribute)3 ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)3 DestroyContextCommand (com.canoo.dp.impl.remoting.commands.DestroyContextCommand)3 AttributeMetadataChangedCommand (com.canoo.dp.impl.remoting.legacy.communication.AttributeMetadataChangedCommand)3 DeletePresentationModelCommand (com.canoo.dp.impl.remoting.legacy.communication.DeletePresentationModelCommand)3 CommandHandler (com.canoo.dp.impl.server.legacy.communication.CommandHandler)3