Search in sources :

Example 66 with Singleton

use of javax.inject.Singleton in project dagger by square.

the class InjectAdapterProcessor method writeInjectAdapterConstructor.

private MethodSpec writeInjectAdapterConstructor(ExecutableElement constructor, TypeElement type, ClassName strippedTypeName) {
    String key = (constructor != null) ? GeneratorKeys.get(type.asType()) : null;
    String membersKey = GeneratorKeys.rawMembersKey(type.asType());
    boolean singleton = type.getAnnotation(Singleton.class) != null;
    return MethodSpec.constructorBuilder().addModifiers(PUBLIC).addStatement("super($S, $S, $N, $T.class)", key, membersKey, (singleton ? "IS_SINGLETON" : "NOT_SINGLETON"), strippedTypeName).build();
}
Also used : Singleton(javax.inject.Singleton) Util.rawTypeToString(dagger.internal.codegen.Util.rawTypeToString) Util.elementToString(dagger.internal.codegen.Util.elementToString)

Example 67 with Singleton

use of javax.inject.Singleton in project SongkickInterview by pakoito.

the class NetworkModule method provideOkHttp.

@Provides
@Singleton
OkHttpClient provideOkHttp(final Cache cache, LoggerInterceptor loggerInterceptor, StethoInterceptor stethoInterceptor) {
    final OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.setCache(cache);
    okHttpClient.networkInterceptors().add(loggerInterceptor);
    okHttpClient.networkInterceptors().add(stethoInterceptor);
    okHttpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    okHttpClient.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    okHttpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    return okHttpClient;
}
Also used : OkHttpClient(com.squareup.okhttp.OkHttpClient) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 68 with Singleton

use of javax.inject.Singleton in project ngAndroid by davityle.

the class UtilsModule method messageUtils.

@Provides
@Singleton
public MessageUtils messageUtils(ProcessingEnvironment processingEnvironment) {
    if (this.messageUtils == null || this.processingEnvironment != processingEnvironment) {
        this.messageUtils = new MessageUtils(processingEnvironment);
        this.processingEnvironment = processingEnvironment;
    }
    return messageUtils;
}
Also used : MessageUtils(com.github.davityle.ngprocessor.util.MessageUtils) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 69 with Singleton

use of javax.inject.Singleton in project Varis-Android by dkhmelenko.

the class TestNetworkModule method provideGitHubRestClient.

@Singleton
@Provides
public GitHubRestClient provideGitHubRestClient() {
    GitHubRestClient gitHubRestClient = mock(GitHubRestClient.class);
    GithubApiService githubApiService = mock(GithubApiService.class);
    Mockito.when(gitHubRestClient.getApiService()).thenReturn(githubApiService);
    return gitHubRestClient;
}
Also used : GitHubRestClient(com.khmelenko.lab.varis.network.retrofit.github.GitHubRestClient) GithubApiService(com.khmelenko.lab.varis.network.retrofit.github.GithubApiService) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 70 with Singleton

use of javax.inject.Singleton in project Varis-Android by dkhmelenko.

the class TestNetworkModule method provideTravisRestClient.

@Singleton
@Provides
public TravisRestClient provideTravisRestClient() {
    TravisRestClient travisRestClient = mock(TravisRestClient.class);
    TravisApiService apiService = mock(TravisApiService.class);
    Mockito.when(travisRestClient.getApiService()).thenReturn(apiService);
    return travisRestClient;
}
Also used : TravisRestClient(com.khmelenko.lab.varis.network.retrofit.travis.TravisRestClient) TravisApiService(com.khmelenko.lab.varis.network.retrofit.travis.TravisApiService) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Singleton (javax.inject.Singleton)168 Provides (dagger.Provides)98 Provides (com.google.inject.Provides)57 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)21 Named (javax.inject.Named)17 OkHttpClient (okhttp3.OkHttpClient)17 Cache (okhttp3.Cache)10 List (java.util.List)9 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)8 Binder (com.google.inject.Binder)8 Module (com.google.inject.Module)8 CachingStripeMetadataSource (com.facebook.presto.orc.CachingStripeMetadataSource)7 DwrfAwareStripeMetadataSourceFactory (com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory)7 OrcDataSourceId (com.facebook.presto.orc.OrcDataSourceId)7 StorageStripeMetadataSource (com.facebook.presto.orc.StorageStripeMetadataSource)7 StripeMetadataSource (com.facebook.presto.orc.StripeMetadataSource)7 StripeMetadataSourceFactory (com.facebook.presto.orc.StripeMetadataSourceFactory)7 CachingOrcFileTailSource (com.facebook.presto.orc.cache.CachingOrcFileTailSource)7 OrcCacheConfig (com.facebook.presto.orc.cache.OrcCacheConfig)7 OrcFileTailSource (com.facebook.presto.orc.cache.OrcFileTailSource)7