Search in sources :

Example 71 with Provides

use of com.google.inject.Provides in project druid by druid-io.

the class JettyServerModule method getServer.

@Provides
@LazySingleton
public Server getServer(final Injector injector, final Lifecycle lifecycle, @Self final DruidNode node, final ServerConfig config) {
    final Server server = makeJettyServer(node, config);
    initializeServer(injector, lifecycle, server);
    return server;
}
Also used : Server(org.eclipse.jetty.server.Server) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 72 with Provides

use of com.google.inject.Provides in project druid by druid-io.

the class GoogleStorageDruidModule method getGoogleStorage.

@Provides
@LazySingleton
public GoogleStorage getGoogleStorage(final GoogleAccountConfig config) throws IOException, GeneralSecurityException {
    LOG.info("Building Cloud Storage Client...");
    HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
    GoogleCredential credential = GoogleCredential.getApplicationDefault(httpTransport, jsonFactory);
    if (credential.createScopedRequired()) {
        credential = credential.createScoped(StorageScopes.all());
    }
    Storage storage = new Storage.Builder(httpTransport, jsonFactory, credential).setApplicationName(APPLICATION_NAME).build();
    return new GoogleStorage(storage);
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) GoogleNetHttpTransport(com.google.api.client.googleapis.javanet.GoogleNetHttpTransport) Storage(com.google.api.services.storage.Storage) JsonFactory(com.google.api.client.json.JsonFactory) GoogleCredential(com.google.api.client.googleapis.auth.oauth2.GoogleCredential) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 73 with Provides

use of com.google.inject.Provides in project druid by druid-io.

the class JacksonModule method smileMapper.

@Provides
@LazySingleton
@Smile
public ObjectMapper smileMapper() {
    final SmileFactory smileFactory = new SmileFactory();
    smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false);
    smileFactory.delegateToTextual(true);
    final ObjectMapper retVal = new DefaultObjectMapper(smileFactory);
    retVal.getFactory().setCodec(retVal);
    return retVal;
}
Also used : SmileFactory(com.fasterxml.jackson.dataformat.smile.SmileFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides) Smile(io.druid.guice.annotations.Smile)

Example 74 with Provides

use of com.google.inject.Provides in project druid by druid-io.

the class CuratorModule method makeEnsembleProvider.

@Provides
@LazySingleton
public EnsembleProvider makeEnsembleProvider(CuratorConfig config, ExhibitorConfig exConfig) {
    if (exConfig.getHosts().isEmpty()) {
        return new FixedEnsembleProvider(config.getZkHosts());
    }
    return new ExhibitorEnsembleProvider(new Exhibitors(exConfig.getHosts(), exConfig.getRestPort(), newBackupProvider(config.getZkHosts())), new DefaultExhibitorRestClient(exConfig.getUseSsl()), exConfig.getRestUriPath(), exConfig.getPollingMs(), new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES)) {

        @Override
        public void start() throws Exception {
            log.info("Poll the list of zookeeper servers for initial ensemble");
            this.pollForInitialEnsemble();
            super.start();
        }
    };
}
Also used : Exhibitors(org.apache.curator.ensemble.exhibitor.Exhibitors) DefaultExhibitorRestClient(org.apache.curator.ensemble.exhibitor.DefaultExhibitorRestClient) ExhibitorEnsembleProvider(org.apache.curator.ensemble.exhibitor.ExhibitorEnsembleProvider) FixedEnsembleProvider(org.apache.curator.ensemble.fixed.FixedEnsembleProvider) BoundedExponentialBackoffRetry(org.apache.curator.retry.BoundedExponentialBackoffRetry) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 75 with Provides

use of com.google.inject.Provides in project hudson-2.x by hudson.

the class HudsonModule method getHudson.

@Provides
private Hudson getHudson() {
    Hudson hudson = Hudson.getInstance();
    checkState(hudson != null);
    return hudson;
}
Also used : Hudson(hudson.model.Hudson) 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