Search in sources :

Example 76 with Provides

use of com.google.inject.Provides in project camel by apache.

the class CamelModuleWithRouteTypes method routes.

@Provides
Set<RoutesBuilder> routes(Injector injector) {
    Set<RoutesBuilder> answer = Sets.newHashSet();
    for (Class<? extends RoutesBuilder> type : routes) {
        RoutesBuilder route = injector.getInstance(type);
        answer.add(route);
    }
    return answer;
}
Also used : RoutesBuilder(org.apache.camel.RoutesBuilder) Provides(com.google.inject.Provides)

Example 77 with Provides

use of com.google.inject.Provides in project presto by prestodb.

the class MongoClientModule method createMongoSession.

@Singleton
@Provides
public static MongoSession createMongoSession(TypeManager typeManager, MongoClientConfig config) {
    requireNonNull(config, "config is null");
    MongoClientOptions.Builder options = MongoClientOptions.builder();
    options.connectionsPerHost(config.getConnectionsPerHost()).connectTimeout(config.getConnectionTimeout()).socketTimeout(config.getSocketTimeout()).socketKeepAlive(config.getSocketKeepAlive()).sslEnabled(config.getSslEnabled()).maxWaitTime(config.getMaxWaitTime()).minConnectionsPerHost(config.getMinConnectionsPerHost()).readPreference(config.getReadPreference().getReadPreference()).writeConcern(config.getWriteConcern().getWriteConcern());
    if (config.getRequiredReplicaSetName() != null) {
        options.requiredReplicaSetName(config.getRequiredReplicaSetName());
    }
    MongoClient client = new MongoClient(config.getSeeds(), config.getCredentials(), options.build());
    return new MongoSession(typeManager, client, config);
}
Also used : MongoClient(com.mongodb.MongoClient) MongoClientOptions(com.mongodb.MongoClientOptions) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 78 with Provides

use of com.google.inject.Provides in project PocketHub by pockethub.

the class PocketHubModule method issueStore.

@Provides
IssueStore issueStore(Context context) {
    IssueStore store = issues != null ? issues.get() : null;
    if (store == null) {
        store = new IssueStore(context);
        issues = new WeakReference<>(store);
    }
    return store;
}
Also used : IssueStore(com.github.pockethub.android.core.issue.IssueStore) Provides(com.google.inject.Provides)

Example 79 with Provides

use of com.google.inject.Provides in project PocketHub by pockethub.

the class PocketHubModule method commitStore.

@Provides
CommitStore commitStore(Context context) {
    CommitStore store = commits != null ? commits.get() : null;
    if (store == null) {
        store = new CommitStore(context);
        commits = new WeakReference<>(store);
    }
    return store;
}
Also used : CommitStore(com.github.pockethub.android.core.commit.CommitStore) Provides(com.google.inject.Provides)

Example 80 with Provides

use of com.google.inject.Provides in project PocketHub by pockethub.

the class PocketHubModule method gistStore.

@Provides
GistStore gistStore(Context context) {
    GistStore store = gists != null ? gists.get() : null;
    if (store == null) {
        store = new GistStore(context);
        gists = new WeakReference<>(store);
    }
    return store;
}
Also used : GistStore(com.github.pockethub.android.core.gist.GistStore) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)111 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)23 Singleton (javax.inject.Singleton)23 Injector (com.google.inject.Injector)22 LazySingleton (io.druid.guice.LazySingleton)12 Named (javax.inject.Named)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 File (java.io.File)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 DB (com.codecademy.eventhub.base.DB)3 Binder (com.google.inject.Binder)3