Search in sources :

Example 16 with Singleton

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;
}
Also used : Executor(java.util.concurrent.Executor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 17 with Singleton

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;
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 18 with Singleton

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;
}
Also used : GraphHopperOSM(com.graphhopper.reader.osm.GraphHopperOSM) GraphHopper(com.graphhopper.GraphHopper) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 19 with Singleton

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;
}
Also used : DropwizardMetadataResolverFactory(uk.gov.ida.saml.metadata.factories.DropwizardMetadataResolverFactory) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) AbstractReloadingMetadataResolver(org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 20 with Singleton

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();
}
Also used : JavaNetCookieJar(okhttp3.JavaNetCookieJar) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) 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