use of javax.inject.Singleton in project wildfly-swarm by wildfly-swarm.
the class CertInfoProducer method produceCertInfo.
@Produces
@Singleton
public CertInfo produceCertInfo() {
if (generateSelfCertificate.get()) {
if (SwarmInfo.isProduct()) {
throw SwarmMessages.MESSAGES.generateSelfSignedCertificateNotSupported();
}
checkDataDir();
return new CertInfo(selfCertificateHost.get(), JBOSS_DATA_DIR);
} else {
String keystorePath = undertow.keystorePath();
if (embeddedKeystore.get()) {
checkDataDir();
Path dataDir = Paths.get(System.getProperty(JBOSS_DATA_DIR));
Path certDestination = dataDir.resolve(keystorePath);
try {
URL jks = ClassLoader.getSystemClassLoader().getResource(keystorePath);
if (jks == null) {
Module appModule = Module.getCallerModuleLoader().loadModule("swarm.application");
jks = appModule.getClassLoader().getResource(keystorePath);
}
if (jks == null) {
throw new RuntimeException(String.format("Unable to locate embedded keystore %s in classpath", keystorePath));
}
Files.copy(jks.openStream(), certDestination);
keystorePath = certDestination.toString();
} catch (Exception ie) {
throw new RuntimeException("Error copying embedded certificate", ie);
}
}
String keystorePassword = undertow.keystorePassword();
String keyPassword = undertow.keyPassword();
String keystoreAlias = undertow.alias();
return new CertInfo(keystorePath, keystorePassword, keyPassword, keystoreAlias);
}
}
use of javax.inject.Singleton in project atlasdb by palantir.
the class TestSweeperModule method provideSweepTaskRunner.
@Provides
@Singleton
public SweepTaskRunner provideSweepTaskRunner(SerializableTransactionManager txm, @Named("kvs") KeyValueService kvs, TransactionService transactionService, SweepStrategyManager sweepStrategyManager, Follower follower, PersistentLockManager persistentLockManager, ServicesConfig config) {
LongSupplier unreadable = unreadableTs.orElse(txm::getUnreadableTimestamp);
LongSupplier immutable = immutableTs.orElse(txm::getImmutableTimestamp);
return new SweepTaskRunner(kvs, unreadable, immutable, transactionService, sweepStrategyManager, new CellsSweeper(txm, kvs, persistentLockManager, ImmutableList.of(follower)));
}
use of javax.inject.Singleton in project butter-android by butterproject.
the class DataModule method provideCache.
@Provides
@Singleton
public Cache provideCache(PreferencesHandler preferencesHandler) {
int cacheSize = 10 * 1024 * 1024;
File cacheLocation = new File(preferencesHandler.getStorageLocation());
cacheLocation.mkdirs();
return new Cache(cacheLocation, cacheSize);
}
use of javax.inject.Singleton in project sbt-android by scala-android.
the class DebugDataModule method providePicasso.
@Provides
@Singleton
Picasso providePicasso(OkHttpClient client, NetworkBehavior behavior, @IsMockMode boolean isMockMode, Application app) {
Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttpDownloader(client));
if (isMockMode) {
builder.addRequestHandler(new MockRequestHandler(behavior, app.getAssets()));
}
builder.listener((picasso, uri, exception) -> {
Timber.e(exception, "Error while loading image " + uri);
});
return builder.build();
}
use of javax.inject.Singleton in project sbt-android by scala-android.
the class DebugDataModule method provideOkHttpClient.
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Application app, Preference<InetSocketAddress> networkProxyAddress) {
OkHttpClient client = DataModule.createOkHttpClient(app);
client.setSslSocketFactory(createBadSslSocketFactory());
client.setProxy(InetSocketAddressPreferenceAdapter.createProxy(networkProxyAddress.get()));
return client;
}
Aggregations