Search in sources :

Example 1 with InitModule

use of org.eclipse.che.inject.lifecycle.InitModule in project che by eclipse.

the class CheBootstrap method getModules.

@Override
protected List<Module> getModules() {
    // based on logic that getServletModule() is called BEFORE getModules() in the EverrestGuiceContextListener
    modules.add(new InitModule(PostConstruct.class));
    modules.add(new DestroyModule(PreDestroy.class, LOG_HANDLER));
    modules.add(new URIConverter());
    modules.add(new URLConverter());
    modules.add(new FileConverter());
    modules.add(new PathConverter());
    modules.add(new StringArrayConverter());
    modules.add(new PairConverter());
    modules.add(new PairArrayConverter());
    modules.addAll(ModuleScanner.findModules());
    Map<String, Set<String>> aliases = readConfigurationAliases();
    Module firstConfigurationPermutation = Modules.override(new WebInfConfiguration(aliases)).with(new ExtConfiguration(aliases));
    Module secondConfigurationPermutation = Modules.override(firstConfigurationPermutation).with(new CheSystemPropertiesConfigurationModule(aliases));
    Module lastConfigurationPermutation = Modules.override(secondConfigurationPermutation).with(new CheEnvironmentVariablesConfigurationModule(aliases));
    modules.add(lastConfigurationPermutation);
    return modules;
}
Also used : DestroyModule(org.eclipse.che.inject.lifecycle.DestroyModule) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) InitModule(org.eclipse.che.inject.lifecycle.InitModule) PreDestroy(javax.annotation.PreDestroy) Module(com.google.inject.Module) DestroyModule(org.eclipse.che.inject.lifecycle.DestroyModule) InitModule(org.eclipse.che.inject.lifecycle.InitModule) ServletModule(com.google.inject.servlet.ServletModule) AbstractModule(com.google.inject.AbstractModule) PostConstruct(javax.annotation.PostConstruct)

Example 2 with InitModule

use of org.eclipse.che.inject.lifecycle.InitModule in project che by eclipse.

the class CascadeRemovalTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    server = H2DBTestServer.startDefault();
    injector = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {

        @Override
        protected void configure() {
            install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class, SshPairImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").setExceptionHandler(H2ExceptionHandler.class).build());
            bind(EventService.class).in(Singleton.class);
            install(new InitModule(PostConstruct.class));
            bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
            bind(DBInitializer.class).asEagerSingleton();
            install(new UserJpaModule());
            install(new AccountModule());
            install(new SshJpaModule());
            install(new WorkspaceJpaModule());
            install(new MachineJpaModule());
            bind(WorkspaceManager.class);
            final WorkspaceRuntimes wR = mock(WorkspaceRuntimes.class);
            when(wR.hasRuntime(anyString())).thenReturn(false);
            bind(WorkspaceRuntimes.class).toInstance(wR);
            bind(AccountManager.class);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_snapshot")).toInstance(false);
            bind(Boolean.class).annotatedWith(Names.named("che.workspace.auto_restore")).toInstance(false);
            bind(WorkspaceSharedPool.class).toInstance(new WorkspaceSharedPool("cached", null, null));
        }
    });
    eventService = injector.getInstance(EventService.class);
    accountDao = injector.getInstance(AccountDao.class);
    userDao = injector.getInstance(UserDao.class);
    preferenceDao = injector.getInstance(PreferenceDao.class);
    profileDao = injector.getInstance(ProfileDao.class);
    sshDao = injector.getInstance(SshDao.class);
    snapshotDao = injector.getInstance(SnapshotDao.class);
    workspaceDao = injector.getInstance(WorkspaceDao.class);
}
Also used : EventService(org.eclipse.che.api.core.notification.EventService) UserJpaModule(org.eclipse.che.api.user.server.jpa.UserJpaModule) AccountDao(org.eclipse.che.account.spi.AccountDao) PreferenceDao(org.eclipse.che.api.user.server.spi.PreferenceDao) InitModule(org.eclipse.che.inject.lifecycle.InitModule) SshDao(org.eclipse.che.api.ssh.server.spi.SshDao) AbstractModule(com.google.inject.AbstractModule) WorkspaceSharedPool(org.eclipse.che.api.workspace.server.WorkspaceSharedPool) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) ProfileDao(org.eclipse.che.api.user.server.spi.ProfileDao) SnapshotDao(org.eclipse.che.api.machine.server.spi.SnapshotDao) UserDao(org.eclipse.che.api.user.server.spi.UserDao) DBInitializer(org.eclipse.che.core.db.DBInitializer) AccountModule(org.eclipse.che.account.api.AccountModule) MachineJpaModule(org.eclipse.che.api.machine.server.jpa.MachineJpaModule) WorkspaceRuntimes(org.eclipse.che.api.workspace.server.WorkspaceRuntimes) SshJpaModule(org.eclipse.che.api.ssh.server.jpa.SshJpaModule) PostConstruct(javax.annotation.PostConstruct) WorkspaceDao(org.eclipse.che.api.workspace.server.spi.WorkspaceDao) WorkspaceJpaModule(org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

AbstractModule (com.google.inject.AbstractModule)2 PostConstruct (javax.annotation.PostConstruct)2 InitModule (org.eclipse.che.inject.lifecycle.InitModule)2 Module (com.google.inject.Module)1 ServletModule (com.google.inject.servlet.ServletModule)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 PreDestroy (javax.annotation.PreDestroy)1 AccountModule (org.eclipse.che.account.api.AccountModule)1 AccountDao (org.eclipse.che.account.spi.AccountDao)1 EventService (org.eclipse.che.api.core.notification.EventService)1 MachineJpaModule (org.eclipse.che.api.machine.server.jpa.MachineJpaModule)1 SnapshotDao (org.eclipse.che.api.machine.server.spi.SnapshotDao)1 SshJpaModule (org.eclipse.che.api.ssh.server.jpa.SshJpaModule)1 SshDao (org.eclipse.che.api.ssh.server.spi.SshDao)1 UserJpaModule (org.eclipse.che.api.user.server.jpa.UserJpaModule)1 PreferenceDao (org.eclipse.che.api.user.server.spi.PreferenceDao)1 ProfileDao (org.eclipse.che.api.user.server.spi.ProfileDao)1 UserDao (org.eclipse.che.api.user.server.spi.UserDao)1 WorkspaceRuntimes (org.eclipse.che.api.workspace.server.WorkspaceRuntimes)1