Search in sources :

Example 66 with Injector

use of com.google.inject.Injector in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method setUpInjector.

@Before
public void setUpInjector() throws Exception {
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    lifecycle = new LifecycleManager();
    lifecycle.add(injector);
    lifecycle.start();
    db = schemaFactory.open();
    schemaCreator.create(db);
    userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
    user = userFactory.create(userId);
    requestContext.setContext(new RequestContext() {

        @Override
        public CurrentUser getUser() {
            return user;
        }

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });
    configureProject();
    setUpChange();
}
Also used : CurrentUser(com.google.gerrit.server.CurrentUser) Injector(com.google.inject.Injector) LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) InMemoryModule(com.google.gerrit.testutil.InMemoryModule) Provider(com.google.inject.Provider) Before(org.junit.Before)

Example 67 with Injector

use of com.google.inject.Injector in project torodb by torodb.

the class ToroDbBootstrap method createStandaloneService.

public static Service createStandaloneService(Config config, Clock clock) {
    Injector bootstrapInjector = Guice.createInjector(new BootstrapModule(config, clock));
    ThreadFactory threadFactory = bootstrapInjector.getInstance(ThreadFactory.class);
    return new ToroDbService(threadFactory, bootstrapInjector);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) Injector(com.google.inject.Injector)

Example 68 with Injector

use of com.google.inject.Injector in project torodb by torodb.

the class StampedeBootstrap method createStampedeService.

public static Service createStampedeService(BootstrapModule bootstrapModule) {
    Injector bootstrapInjector = Guice.createInjector(bootstrapModule);
    ThreadFactory threadFactory = bootstrapInjector.getInstance(ThreadFactory.class);
    return new StampedeService(threadFactory, bootstrapInjector);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) Injector(com.google.inject.Injector)

Example 69 with Injector

use of com.google.inject.Injector in project torodb by torodb.

the class StampedeService method startUp.

@Override
protected void startUp() throws Exception {
    LOGGER.info("Starting up ToroDB Stampede");
    shutdowner = bootstrapInjector.getInstance(Shutdowner.class);
    shutdowner.awaitRunning();
    BackendBundle backendBundle = createBackendBundle();
    startBundle(backendBundle);
    BackendService backendService = backendBundle.getBackendService();
    ConsistencyHandler consistencyHandler = createConsistencyHandler(backendService);
    if (!consistencyHandler.isConsistent()) {
        LOGGER.info("Database is not consistent. Cleaning it up");
        dropDatabase(backendService);
    }
    Injector finalInjector = createFinalInjector(backendBundle, consistencyHandler);
    AbstractReplication replication = getReplication();
    reportReplication(replication);
    TorodBundle torodBundle = createTorodBundle(finalInjector);
    startBundle(torodBundle);
    MongodbReplConfig replConfig = getReplConfig(replication);
    startBundle(createMongodbReplBundle(finalInjector, torodBundle, replConfig));
    LOGGER.info("ToroDB Stampede is now running");
}
Also used : BackendService(com.torodb.core.backend.BackendService) Shutdowner(com.torodb.core.Shutdowner) Injector(com.google.inject.Injector) BackendBundle(com.torodb.core.backend.BackendBundle) MongodbReplConfig(com.torodb.mongodb.repl.guice.MongodbReplConfig) ConsistencyHandler(com.torodb.mongodb.repl.ConsistencyHandler) AbstractReplication(com.torodb.packaging.config.model.protocol.mongo.AbstractReplication) TorodBundle(com.torodb.torod.TorodBundle)

Example 70 with Injector

use of com.google.inject.Injector in project graphhopper by graphhopper.

the class GHServer method start.

public void start() throws Exception {
    Injector injector = Guice.createInjector(createModule());
    start(injector);
}
Also used : Injector(com.google.inject.Injector)

Aggregations

Injector (com.google.inject.Injector)2159 AbstractModule (com.google.inject.AbstractModule)623 Test (org.junit.Test)513 Module (com.google.inject.Module)364 Test (org.testng.annotations.Test)131 Before (org.junit.Before)116 Binder (com.google.inject.Binder)114 Properties (java.util.Properties)110 Key (com.google.inject.Key)84 Map (java.util.Map)78 HttpServletRequest (javax.servlet.http.HttpServletRequest)78 Provider (com.google.inject.Provider)74 IOException (java.io.IOException)71 TypeLiteral (com.google.inject.TypeLiteral)70 Set (java.util.Set)64 BeforeClass (org.junit.BeforeClass)61 File (java.io.File)60 CConfiguration (co.cask.cdap.common.conf.CConfiguration)55 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)55 PrivateModule (com.google.inject.PrivateModule)55