Search in sources :

Example 96 with Singleton

use of javax.inject.Singleton in project dobby-android by InceptAi.

the class ProdModule method providesDobbyAi.

@Singleton
@Provides
public DobbyAi providesDobbyAi(DobbyApplication application, DobbyThreadpool threadpool, InferenceDatabaseWriter inferenceDatabaseWriter, FailureDatabaseWriter failureDatabaseWriter) {
    DobbyAi dobbyAi = new DobbyAi(threadpool, inferenceDatabaseWriter, failureDatabaseWriter, application);
    application.getProdComponent().inject(dobbyAi);
    return dobbyAi;
}
Also used : DobbyAi(com.inceptai.dobby.ai.DobbyAi) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 97 with Singleton

use of javax.inject.Singleton in project coins-android by bubelov.

the class MainModule method httpClient.

@Provides
@Singleton
OkHttpClient httpClient() {
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS);
    if (BuildConfig.DEBUG) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
        httpClientBuilder.addInterceptor(loggingInterceptor);
        httpClientBuilder.addNetworkInterceptor(new StethoInterceptor());
    }
    return httpClientBuilder.build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) StethoInterceptor(com.facebook.stetho.okhttp3.StethoInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 98 with Singleton

use of javax.inject.Singleton in project webpieces by deanhiller.

the class AbstractLoader method loadRouteImpl.

protected void loadRouteImpl(RouteMeta meta, ResolvedMethod method) {
    String controllerStr = method.getControllerStr();
    String methodStr = method.getMethodStr();
    Injector injector = meta.getInjector();
    Object controllerInst = createController(injector, controllerStr);
    Singleton singleton = controllerInst.getClass().getAnnotation(Singleton.class);
    if (singleton == null)
        throw new IllegalArgumentException("EVERY controller must be marked with @javax.inject.Singleton not @com.google.inject.Singleton. bad controller=" + controllerInst.getClass().getName());
    loader.loadInstIntoMeta(meta, controllerInst, methodStr);
}
Also used : Injector(com.google.inject.Injector) Singleton(javax.inject.Singleton)

Example 99 with Singleton

use of javax.inject.Singleton in project webpieces by deanhiller.

the class WebServerModule method providesAsyncServerMgr.

@Provides
@Singleton
public HttpFrontendManager providesAsyncServerMgr(ChannelManager chanMgr, ScheduledExecutorService timer, @Named(HttpFrontendFactory.HTTP2_ENGINE_THREAD_POOL) Executor executor1, BufferPool pool, Time time, WebServerConfig config) {
    HttpParser httpParser = HttpParserFactory.createParser(pool);
    HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
    InjectionConfig injConfig = new InjectionConfig(http2Parser, time, config.getHttp2Config());
    return HttpFrontendFactory.createFrontEnd(chanMgr, timer, injConfig, httpParser);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) HttpParser(org.webpieces.httpparser.api.HttpParser) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 100 with Singleton

use of javax.inject.Singleton in project bugzy by cpunq.

the class NetModule method provideFogBugzService.

@Provides
@Singleton
FogbugzApiService provideFogBugzService(Application application, PrefsHelper prefsHelper, Gson gson) {
    OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    Retrofit.Builder builder = new Retrofit.Builder().baseUrl(mBaseUrl).addCallAdapterFactory(new LiveDataCallAdapterFactory(gson)).addConverterFactory(GsonConverterFactory.create(gson));
    Retrofit retrofit = builder.client(httpClient.addInterceptor(new ConnectivityInterceptor(application.getApplicationContext())).addInterceptor(new RequestInterceptor(prefsHelper)).build()).build();
    return retrofit.create(FogbugzApiService.class);
}
Also used : LiveDataCallAdapterFactory(com.bluestacks.bugzy.utils.LiveDataCallAdapterFactory) Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) RequestInterceptor(com.bluestacks.bugzy.data.remote.RequestInterceptor) ConnectivityInterceptor(com.bluestacks.bugzy.data.remote.ConnectivityInterceptor) 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