Search in sources :

Example 26 with Singleton

use of javax.inject.Singleton in project sbt-android by scala-android.

the class DebugApiModule method provideBehavior.

@Provides
@Singleton
NetworkBehavior provideBehavior(@NetworkDelay Preference<Long> networkDelay, @NetworkFailurePercent Preference<Integer> networkFailurePercent, @NetworkVariancePercent Preference<Integer> networkVariancePercent) {
    NetworkBehavior behavior = NetworkBehavior.create();
    behavior.setDelay(networkDelay.get(), MILLISECONDS);
    behavior.setFailurePercent(networkFailurePercent.get());
    behavior.setVariancePercent(networkVariancePercent.get());
    return behavior;
}
Also used : NetworkBehavior(retrofit.mock.NetworkBehavior) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 27 with Singleton

use of javax.inject.Singleton in project core by weld.

the class WeldSEBeanRegistrant method registerWeldSEContexts.

public void registerWeldSEContexts(@Observes AfterBeanDiscovery event, BeanManager manager) {
    if (ignoreEvent(event)) {
        return;
    }
    final String contextId = BeanManagerProxy.unwrap(manager).getContextId();
    this.threadContext = new ThreadContext(contextId);
    event.addContext(threadContext);
    // Register WeldContainer as a singleton
    event.addBean().addType(WeldContainer.class).addQualifier(Default.Literal.INSTANCE).scope(Singleton.class).produceWith((i) -> WeldContainer.instance(contextId));
}
Also used : Singleton(javax.inject.Singleton) ThreadContext(org.jboss.weld.environment.se.contexts.ThreadContext)

Example 28 with Singleton

use of javax.inject.Singleton in project iep by Netflix.

the class LifecycleTest method provides.

@Test
public void provides() throws Exception {
    GuiceHelper helper = new GuiceHelper();
    helper.start(new AbstractModule() {

        @Override
        protected void configure() {
        }

        @Provides
        @Singleton
        private StateObject providesStateObject() {
            return new StateObject();
        }
    });
    Injector injector = helper.getInjector();
    StateObject obj = injector.getInstance(StateObject.class);
    Assert.assertEquals(State.STARTED, obj.getState());
    helper.shutdown();
    Assert.assertEquals(State.STOPPED, obj.getState());
}
Also used : Singleton(javax.inject.Singleton) Injector(com.google.inject.Injector) Provides(com.google.inject.Provides) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Example 29 with Singleton

use of javax.inject.Singleton in project androidthings-deskclock by leinardi.

the class NetworkModule method provideOkHttpClient.

@Provides
@Singleton
public OkHttpClient provideOkHttpClient(@Named(NETWORK_TIMEOUT) Long networkTimeout) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    if (BuildConfig.DEBUG) {
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);
        builder.addInterceptor(logging);
    }
    return builder.connectTimeout(networkTimeout, TimeUnit.SECONDS).readTimeout(networkTimeout, TimeUnit.SECONDS).writeTimeout(networkTimeout, TimeUnit.SECONDS).build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 30 with Singleton

use of javax.inject.Singleton in project androidthings-deskclock by leinardi.

the class AndroidThingsModule method provideEpdDriverController.

@Singleton
@Provides
EpdDriverController provideEpdDriverController(@Nullable Gdew075t8Epd epd) {
    Gdew075t8EpdDriverController controller = new Gdew075t8EpdDriverController();
    controller.setDriver(epd);
    return controller;
}
Also used : Gdew075t8EpdDriverController(com.leinardi.android.things.deskclock.epd.Gdew075t8EpdDriverController) 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