Search in sources :

Example 61 with Provider

use of com.google.inject.Provider in project che by eclipse.

the class BootstrapController method startComponents.

private void startComponents(final Iterator<Map.Entry<String, Provider<Component>>> componentIterator) {
    if (componentIterator.hasNext()) {
        Map.Entry<String, Provider<Component>> entry = componentIterator.next();
        final String componentName = entry.getKey();
        try {
            Provider<Component> componentProvider = entry.getValue();
            final Component component = componentProvider.get();
            component.start(new Callback<Component, Exception>() {

                @Override
                public void onSuccess(Component result) {
                    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                        @Override
                        public void execute() {
                            startComponents(componentIterator);
                        }
                    });
                }

                @Override
                public void onFailure(Exception reason) {
                    Log.error(getClass(), "Unable to start " + componentName, reason);
                    initializationFailed(reason.getMessage());
                }
            });
        } catch (Exception e) {
            Log.error(getClass(), "Unable to start " + componentName, e);
            initializationFailed(e.getMessage());
        }
    } else {
        startExtensionsAndDisplayUI();
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) WsAgentComponent(org.eclipse.che.ide.api.component.WsAgentComponent) Component(org.eclipse.che.ide.api.component.Component) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) OperationException(org.eclipse.che.api.promises.client.OperationException) Provider(com.google.inject.Provider)

Example 62 with Provider

use of com.google.inject.Provider in project che by eclipse.

the class PomReconcilerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    File localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    projectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    ClasspathManager classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, projectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(projectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 63 with Provider

use of com.google.inject.Provider in project che by eclipse.

the class WorkspaceTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier), eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ArrayList(java.util.ArrayList) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 64 with Provider

use of com.google.inject.Provider in project che by eclipse.

the class ClasspathManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = (level, message, throwable) -> {
        System.out.println(message);
        if (throwable != null) {
            throwable.printStackTrace();
        }
    };
    localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) JsonObject(com.google.gson.JsonObject) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Assert.assertNull(org.testng.Assert.assertNull) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) Mock(org.mockito.Mock) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) AfterMethod(org.testng.annotations.AfterMethod) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) IProject(org.eclipse.core.resources.IProject) BaseTest(org.eclipse.che.plugin.maven.server.BaseTest) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaCore(org.eclipse.jdt.core.JavaCore) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Assert.assertNotNull(org.testng.Assert.assertNotNull) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) File(java.io.File) IoUtil(org.eclipse.che.commons.lang.IoUtil) IType(org.eclipse.jdt.core.IType) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) List(java.util.List) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Assert.assertTrue(org.testng.Assert.assertTrue) Collections(java.util.Collections) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 65 with Provider

use of com.google.inject.Provider in project che by eclipse.

the class ProjectWizardPresenter method getWizardForProjectType.

/** Creates or returns project wizard for the specified projectType with the given dataObject. */
private ProjectWizard getWizardForProjectType(@NotNull ProjectTypeDto projectType, @NotNull MutableProjectConfig configDto) {
    if (wizardsCache.containsKey(projectType)) {
        return wizardsCache.get(projectType);
    }
    final ProjectWizardRegistrar wizardRegistrar = wizardRegistry.getWizardRegistrar(projectType.getId());
    if (wizardRegistrar == null) {
        // should never occur
        throw new IllegalStateException("WizardRegistrar for the project type " + projectType.getId() + " isn't registered.");
    }
    List<Provider<? extends WizardPage<MutableProjectConfig>>> pageProviders = wizardRegistrar.getWizardPages();
    final ProjectWizard projectWizard = createDefaultWizard(configDto, wizardMode);
    for (Provider<? extends WizardPage<MutableProjectConfig>> provider : pageProviders) {
        projectWizard.addPage(provider.get(), 1, false);
    }
    wizardsCache.put(projectType, projectWizard);
    return projectWizard;
}
Also used : MutableProjectConfig(org.eclipse.che.ide.api.project.MutableProjectConfig) WizardPage(org.eclipse.che.ide.api.wizard.WizardPage) ProjectWizard(org.eclipse.che.ide.projecttype.wizard.ProjectWizard) ProjectWizardRegistrar(org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar) Provider(com.google.inject.Provider)

Aggregations

Provider (com.google.inject.Provider)133 Injector (com.google.inject.Injector)72 AbstractModule (com.google.inject.AbstractModule)63 Module (com.google.inject.Module)44 Key (com.google.inject.Key)17 TypeLiteral (com.google.inject.TypeLiteral)10 ArrayList (java.util.ArrayList)10 ProvisionException (com.google.inject.ProvisionException)9 Dependency (com.google.inject.spi.Dependency)9 Map (java.util.Map)8 Before (org.junit.Before)7 CurrentUser (com.google.gerrit.server.CurrentUser)6 RequestContext (com.google.gerrit.server.util.RequestContext)6 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)6 InMemoryModule (com.google.gerrit.testutil.InMemoryModule)6 PrivateModule (com.google.inject.PrivateModule)6 Scope (com.google.inject.Scope)6 List (java.util.List)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 Annotation (java.lang.annotation.Annotation)5