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;
}
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));
}
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());
}
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();
}
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;
}
Aggregations