Search in sources :

Example 56 with Provides

use of com.google.inject.Provides 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 57 with Provides

use of com.google.inject.Provides 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 58 with Provides

use of com.google.inject.Provides 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 59 with Provides

use of com.google.inject.Provides in project verify-hub by alphagov.

the class SamlProxyModule method getVerifyMetadataResolver.

@Provides
@Singleton
@Named("VerifyMetadataResolver")
public MetadataResolver getVerifyMetadataResolver(Environment environment, SamlProxyConfiguration 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 60 with Provides

use of com.google.inject.Provides in project verify-hub by alphagov.

the class SamlSoapProxyModule method jsonClient.

@Provides
@Singleton
public JsonClient jsonClient(JsonResponseProcessor jsonResponseProcessor, Environment environment, SamlSoapProxyConfiguration configuration) {
    Client client = new ClientProvider(environment, configuration.getJerseyClientConfiguration(), configuration.getEnableRetryTimeOutConnections(), "samlSoapProxyClient").get();
    ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
    return new JsonClient(errorHandlingClient, jsonResponseProcessor);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) HealthCheckSoapRequestClient(uk.gov.ida.hub.samlsoapproxy.client.HealthCheckSoapRequestClient) MatchingServiceHealthCheckClient(uk.gov.ida.hub.samlsoapproxy.client.MatchingServiceHealthCheckClient) Client(javax.ws.rs.client.Client) AttributeQueryRequestClient(uk.gov.ida.hub.samlsoapproxy.client.AttributeQueryRequestClient) JsonClient(uk.gov.ida.jerseyclient.JsonClient) SoapRequestClient(uk.gov.ida.hub.samlsoapproxy.client.SoapRequestClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)126 Singleton (javax.inject.Singleton)36 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)24 Injector (com.google.inject.Injector)22 Named (javax.inject.Named)17 LazySingleton (io.druid.guice.LazySingleton)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 IOException (java.io.IOException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 Binder (com.google.inject.Binder)3