Search in sources :

Example 1 with InternalAttributesBean

use of com.canoo.dp.impl.remoting.InternalAttributesBean in project dolphin-platform by canoo.

the class ControllerProxyFactory method create.

public <T> CompletableFuture<ControllerProxy<T>> create(String name, String parentControllerId) {
    Assert.requireNonBlank(name, "name");
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final CreateControllerCommand createControllerCommand = new CreateControllerCommand();
    createControllerCommand.setControllerName(name);
    if (parentControllerId != null) {
        createControllerCommand.setParentControllerId(parentControllerId);
    }
    return dolphinCommandHandler.invokeDolphinCommand(createControllerCommand).thenApply(new Function<Void, ControllerProxy<T>>() {

        @Override
        public ControllerProxy<T> apply(Void aVoid) {
            return new ControllerProxyImpl<T>(bean.getControllerId(), (T) bean.getModel(), clientConnector, platformBeanRepository, ControllerProxyFactory.this, converters);
        }
    });
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand)

Example 2 with InternalAttributesBean

use of com.canoo.dp.impl.remoting.InternalAttributesBean in project dolphin-platform by canoo.

the class DolphinContext method onCreateController.

private void onCreateController(final String controllerName, final String parentControllerId) {
    Assert.requireNonBlank(controllerName, "controllerName");
    if (platformBeanRepository == null) {
        throw new IllegalStateException("An action was called before the init-command was sent.");
    }
    // TODO: Remove this. Should be handled by commands. See https://github.com/canoo/dolphin-platform/issues/522
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final String controllerId = controllerHandler.createController(controllerName, parentControllerId);
    bean.setControllerId(controllerId);
    Object model = controllerHandler.getControllerModel(controllerId);
    if (model != null) {
        bean.setModel(model);
    }
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean)

Example 3 with InternalAttributesBean

use of com.canoo.dp.impl.remoting.InternalAttributesBean in project dolphin-platform by canoo.

the class ControllerProxyImpl method destroy.

@Override
public CompletableFuture<Void> destroy() {
    if (destroyed) {
        throw new IllegalStateException("The controller was already destroyed");
    }
    destroyed = true;
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final CompletableFuture<Void> ret = new CompletableFuture<>();
    final DestroyControllerCommand destroyControllerCommand = new DestroyControllerCommand();
    destroyControllerCommand.setControllerId(controllerId);
    clientConnector.send(destroyControllerCommand, () -> {
        model = null;
        ret.complete(null);
    });
    return ret;
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean) CompletableFuture(java.util.concurrent.CompletableFuture) DestroyControllerCommand(com.canoo.dp.impl.remoting.commands.DestroyControllerCommand)

Aggregations

InternalAttributesBean (com.canoo.dp.impl.remoting.InternalAttributesBean)3 CreateControllerCommand (com.canoo.dp.impl.remoting.commands.CreateControllerCommand)1 DestroyControllerCommand (com.canoo.dp.impl.remoting.commands.DestroyControllerCommand)1 ControllerProxy (com.canoo.platform.remoting.client.ControllerProxy)1 CompletableFuture (java.util.concurrent.CompletableFuture)1