use of javax.inject.Singleton in project apollo by spotify.
the class EnvironmentModule method environmentFactory.
@Provides
@Singleton
EnvironmentFactory environmentFactory(Config configNode, ApolloConfig apolloConfig, Closer closer, Injector injector, IncomingRequestAwareClient incomingRequestAwareClient) {
final String backend = apolloConfig.backend();
final Client unawareClient = incomingRequestAwareClient.asUnawareClient();
return EnvironmentFactoryBuilder.newBuilder(backend, unawareClient, closer, injector::getInstance).withStaticConfig(configNode).build();
}
use of javax.inject.Singleton in project TeamCityApp by vase4kin.
the class AppModule method providesCryptoManager.
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
@Provides
@Singleton
protected CryptoManager providesCryptoManager() {
KeyChain keyChain = new SharedPrefsBackedKeyChain(mApplication.getApplicationContext(), CryptoConfig.KEY_256);
Crypto crypto = AndroidConceal.get().createDefaultCrypto(keyChain);
return new CryptoManagerImpl(crypto);
}
use of javax.inject.Singleton in project kiwix-android by kiwix.
the class TestNetworkModule method provideMockWebServer.
@Provides
@Singleton
MockWebServer provideMockWebServer() {
MockWebServer mockWebServer = new MockWebServer();
Thread thread = new Thread() {
@Override
public void run() {
try {
mockWebServer.start();
} catch (IOException e) {
e.printStackTrace();
}
}
};
thread.start();
return mockWebServer;
}
use of javax.inject.Singleton in project presto by prestodb.
the class RaptorModule method createDBI.
@ForMetadata
@Singleton
@Provides
public IDBI createDBI(@ForMetadata ConnectionFactory connectionFactory, TypeManager typeManager) {
DBI dbi = new DBI(connectionFactory);
dbi.registerMapper(new TableColumn.Mapper(typeManager));
dbi.registerMapper(new Distribution.Mapper(typeManager));
createTablesWithRetry(dbi);
return dbi;
}
use of javax.inject.Singleton in project presto by prestodb.
the class StorageModule method createOrcFileTailSource.
@Singleton
@Provides
public OrcFileTailSource createOrcFileTailSource(OrcCacheConfig orcCacheConfig, MBeanExporter exporter) {
int expectedFileTailSizeInBytes = toIntExact(orcCacheConfig.getExpectedFileTailSize().toBytes());
boolean dwrfStripeCacheEnabled = orcCacheConfig.isDwrfStripeCacheEnabled();
OrcFileTailSource orcFileTailSource = new StorageOrcFileTailSource(expectedFileTailSizeInBytes, dwrfStripeCacheEnabled);
if (orcCacheConfig.isFileTailCacheEnabled()) {
Cache<OrcDataSourceId, OrcFileTail> cache = CacheBuilder.newBuilder().maximumWeight(orcCacheConfig.getFileTailCacheSize().toBytes()).weigher((id, tail) -> ((OrcFileTail) tail).getTotalSize()).expireAfterAccess(orcCacheConfig.getFileTailCacheTtlSinceLastAccess().toMillis(), TimeUnit.MILLISECONDS).recordStats().build();
CacheStatsMBean cacheStatsMBean = new CacheStatsMBean(cache);
orcFileTailSource = new CachingOrcFileTailSource(orcFileTailSource, cache);
exporter.export(generatedNameOf(CacheStatsMBean.class, connectorId + "_OrcFileTail"), cacheStatsMBean);
}
return orcFileTailSource;
}
Aggregations