use of javax.inject.Singleton in project webpieces by deanhiller.
the class WebServerModule method providesChanMgr.
@Provides
@Singleton
public ChannelManager providesChanMgr(WebServerConfig config, BufferPool pool) {
String id = "webpieces";
Executor executor = Executors.newFixedThreadPool(config.getNumFrontendServerThreads(), new NamedThreadFactory(id));
ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, executor);
return chanMgr;
}
use of javax.inject.Singleton in project webpieces by deanhiller.
the class HibernateModule method providesSessionFactory.
@Singleton
@Provides
public EntityManagerFactory providesSessionFactory() throws IOException {
log.info("Loading Hibernate. ENTITY classloader=" + entityClassLoader + " hibernate classloader=" + this.getClass().getClassLoader());
Map<String, Object> properties = createClassLoaderProperty();
EntityManagerFactory factory = Persistence.createEntityManagerFactory(persistenceUnit, properties);
log.info("Done loading Hibernate");
return factory;
}
use of javax.inject.Singleton in project graphhopper by graphhopper.
the class GraphHopperModule method createGraphHopper.
@Provides
@Singleton
GraphHopper createGraphHopper(CmdArgs args) {
GraphHopper graphHopper = new GraphHopperOSM(SpatialRuleLookupHelper.createLandmarkSplittingFeatureCollection(args.get(Parameters.Landmark.PREPARE + "split_area_location", ""))).forServer();
SpatialRuleLookupHelper.buildAndInjectSpatialRuleIntoGH(graphHopper, args);
graphHopper.init(args);
return graphHopper;
}
use of javax.inject.Singleton in project verify-hub by alphagov.
the class SamlEngineModule method getVerifyMetadataResolver.
@Provides
@Singleton
@Named("VerifyMetadataResolver")
private MetadataResolver getVerifyMetadataResolver(Environment environment, SamlEngineConfiguration configuration) {
final MetadataResolver metadataResolver = new DropwizardMetadataResolverFactory().createMetadataResolver(environment, configuration.getMetadataConfiguration());
registerMetadataRefreshTask(environment, metadataResolver, configuration.getMetadataConfiguration(), "metadata");
return metadataResolver;
}
use of javax.inject.Singleton in project talk-android by nextcloud.
the class RestModule method provideHttpClient.
@Provides
@Singleton
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences, MagicTrustManager magicTrustManager, SSLSocketFactoryCompat sslSocketFactoryCompat, Cache cache, CookieManager cookieManager) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.connectTimeout(45, TimeUnit.SECONDS);
httpClient.readTimeout(45, TimeUnit.SECONDS);
httpClient.writeTimeout(45, TimeUnit.SECONDS);
httpClient.cookieJar(new JavaNetCookieJar(cookieManager));
httpClient.cache(cache);
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(loggingInterceptor);
}
httpClient.sslSocketFactory(sslSocketFactoryCompat, magicTrustManager);
httpClient.retryOnConnectionFailure(true);
httpClient.hostnameVerifier(magicTrustManager.getHostnameVerifier(OkHostnameVerifier.INSTANCE));
if (!Proxy.NO_PROXY.equals(proxy)) {
httpClient.proxy(proxy);
if (appPreferences.getProxyCredentials() && !TextUtils.isEmpty(appPreferences.getProxyUsername()) && !TextUtils.isEmpty(appPreferences.getProxyPassword())) {
httpClient.proxyAuthenticator(new ProxyAuthenticator(Credentials.basic(appPreferences.getProxyUsername(), appPreferences.getProxyPassword())));
}
}
httpClient.addInterceptor(new HeadersInterceptor());
return httpClient.build();
}
Aggregations