Search in sources :

Example 1 with WsAgentComponent

use of org.eclipse.che.ide.api.component.WsAgentComponent in project che by eclipse.

the class BootstrapController method startWsAgentComponents.

private void startWsAgentComponents(final Iterator<Provider<WsAgentComponent>> componentProviderIterator) {
    if (componentProviderIterator.hasNext()) {
        Provider<WsAgentComponent> componentProvider = componentProviderIterator.next();
        final WsAgentComponent component = componentProvider.get();
        component.start(new Callback<WsAgentComponent, Exception>() {

            @Override
            public void onSuccess(WsAgentComponent result) {
                startWsAgentComponents(componentProviderIterator);
            }

            @Override
            public void onFailure(Exception reason) {
                Log.error(component.getClass(), reason);
                initializationFailed(reason.getMessage());
            }
        });
    }
}
Also used : WsAgentComponent(org.eclipse.che.ide.api.component.WsAgentComponent) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with WsAgentComponent

use of org.eclipse.che.ide.api.component.WsAgentComponent in project che by eclipse.

the class BootstrapController method startWsAgentComponents.

@Inject
private void startWsAgentComponents(EventBus eventBus, final Map<String, Provider<WsAgentComponent>> components) {
    eventBus.addHandler(WorkspaceStartedEvent.TYPE, new WorkspaceStartedEvent.Handler() {

        @Override
        public void onWorkspaceStarted(WorkspaceStartedEvent event) {
            workspaceService.getWorkspace(event.getWorkspace().getId()).then(new Operation<WorkspaceDto>() {

                @Override
                public void apply(WorkspaceDto ws) throws OperationException {
                    MachineDto devMachineDto = ws.getRuntime().getDevMachine();
                    DevMachine devMachine = new DevMachine(devMachineDto);
                    if (appContext instanceof AppContextImpl) {
                        ((AppContextImpl) appContext).setProjectsRoot(Path.valueOf(devMachineDto.getRuntime().projectsRoot()));
                    }
                    wsAgentStateControllerProvider.get().initialize(devMachine);
                    wsAgentURLModifier.initialize(devMachine);
                    SortedMap<String, Provider<WsAgentComponent>> sortedComponents = new TreeMap<>();
                    sortedComponents.putAll(components);
                    startWsAgentComponents(sortedComponents.values().iterator());
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError err) throws OperationException {
                    Log.error(getClass(), err.getCause());
                    initializationFailed(err.getMessage());
                }
            });
        }
    });
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) WorkspaceStartedEvent(org.eclipse.che.ide.api.workspace.event.WorkspaceStartedEvent) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Operation(org.eclipse.che.api.promises.client.Operation) AppContextImpl(org.eclipse.che.ide.context.AppContextImpl) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) SortedMap(java.util.SortedMap) WsAgentComponent(org.eclipse.che.ide.api.component.WsAgentComponent) OperationException(org.eclipse.che.api.promises.client.OperationException) Inject(com.google.inject.Inject)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)2 WsAgentComponent (org.eclipse.che.ide.api.component.WsAgentComponent)2 Inject (com.google.inject.Inject)1 SortedMap (java.util.SortedMap)1 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)1 Operation (org.eclipse.che.api.promises.client.Operation)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)1 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)1 WorkspaceStartedEvent (org.eclipse.che.ide.api.workspace.event.WorkspaceStartedEvent)1 AppContextImpl (org.eclipse.che.ide.context.AppContextImpl)1