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);
}
});
}
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);
}
}
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;
}
Aggregations