Search in sources :

Example 16 with Singleton

use of com.google.inject.Singleton in project ratpack by ratpack.

the class ThymeleafModule method provideCacheManager.

@Provides
@Singleton
StandardCacheManager provideCacheManager(Config config) {
    int cacheSize = getCacheSizeSetting(config);
    StandardCacheManager cacheManager = new StandardCacheManager();
    cacheManager.setTemplateCacheMaxSize(cacheSize);
    return cacheManager;
}
Also used : StandardCacheManager(org.thymeleaf.cache.StandardCacheManager) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 17 with Singleton

use of com.google.inject.Singleton in project ratpack by ratpack.

the class HandlebarsModule method provideHandlebars.

@SuppressWarnings("UnusedDeclaration")
@Provides
@Singleton
Handlebars provideHandlebars(Config config, Injector injector, TemplateLoader templateLoader, TemplateCache templateCache) {
    final Handlebars handlebars = new Handlebars().with(templateLoader).with(templateCache).startDelimiter(config.getStartDelimiter()).endDelimiter(config.getEndDelimiter());
    GuiceUtil.eachOfType(injector, NAMED_HELPER_TYPE, helper -> handlebars.registerHelper(helper.getName(), helper));
    return handlebars;
}
Also used : Handlebars(com.github.jknack.handlebars.Handlebars) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 18 with Singleton

use of com.google.inject.Singleton in project airpal by airbnb.

the class AirpalModule method provideDBI.

@Singleton
@Provides
public DBI provideDBI(ObjectMapper objectMapper) throws ClassNotFoundException {
    final DBIFactory factory = new DBIFactory();
    final DBI dbi = factory.build(environment, config.getDataSourceFactory(), provideDbType().name());
    dbi.registerMapper(new TableRow.TableRowMapper(objectMapper));
    dbi.registerMapper(new QueryStoreMapper(objectMapper));
    dbi.registerArgumentFactory(new UUIDArgumentFactory());
    dbi.registerArgumentFactory(new URIArgumentFactory());
    return dbi;
}
Also used : URIArgumentFactory(com.airbnb.airpal.sql.jdbi.URIArgumentFactory) UUIDArgumentFactory(com.airbnb.airpal.sql.jdbi.UUIDArgumentFactory) TableRow(com.airbnb.airpal.sql.beans.TableRow) DBI(org.skife.jdbi.v2.DBI) QueryStoreMapper(com.airbnb.airpal.sql.jdbi.QueryStoreMapper) DBIFactory(io.dropwizard.jdbi.DBIFactory) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 19 with Singleton

use of com.google.inject.Singleton in project airpal by airbnb.

the class AirpalModule method provideSchemaCache.

@Singleton
@Provides
public SchemaCache provideSchemaCache(QueryRunnerFactory queryRunnerFactory, @Named("presto") ExecutorService executorService) {
    final SchemaCache cache = new SchemaCache(queryRunnerFactory, executorService);
    cache.populateCache(config.getPrestoCatalog());
    return cache;
}
Also used : SchemaCache(com.airbnb.airpal.presto.metadata.SchemaCache) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 20 with Singleton

use of com.google.inject.Singleton in project gerrit by GerritCodeReview.

the class SshAddressesModule method getListenAddresses.

@Provides
@Singleton
@SshListenAddresses
public List<SocketAddress> getListenAddresses(@GerritServerConfig Config cfg) {
    List<SocketAddress> listen = Lists.newArrayListWithExpectedSize(2);
    String[] want = cfg.getStringList("sshd", null, "listenaddress");
    if (want == null || want.length == 0) {
        listen.add(new InetSocketAddress(DEFAULT_PORT));
        return listen;
    }
    if (want.length == 1 && isOff(want[0])) {
        return listen;
    }
    for (final String desc : want) {
        try {
            listen.add(SocketUtil.resolve(desc, DEFAULT_PORT));
        } catch (IllegalArgumentException e) {
            log.error("Bad sshd.listenaddress: " + desc + ": " + e.getMessage());
        }
    }
    return listen;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Singleton (com.google.inject.Singleton)24 Provides (com.google.inject.Provides)23 AbstractModule (com.google.inject.AbstractModule)6 Injector (com.google.inject.Injector)5 ConfigModule (co.cask.cdap.common.guice.ConfigModule)2 ProvisionException (com.google.inject.ProvisionException)2 DataSourceFactory (io.dropwizard.db.DataSourceFactory)2 ManagedDataSource (io.dropwizard.db.ManagedDataSource)2 LazySingleton (io.druid.guice.LazySingleton)2 InetSocketAddress (java.net.InetSocketAddress)2 SocketAddress (java.net.SocketAddress)2 Readonly (keywhiz.service.config.Readonly)2 DatasetDefinitionRegistry (co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry)1 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)1 AppFabricServiceRuntimeModule (co.cask.cdap.app.guice.AppFabricServiceRuntimeModule)1 AuthorizationModule (co.cask.cdap.app.guice.AuthorizationModule)1 ProgramRunnerRuntimeModule (co.cask.cdap.app.guice.ProgramRunnerRuntimeModule)1 ServiceStoreModules (co.cask.cdap.app.guice.ServiceStoreModules)1 TwillModule (co.cask.cdap.app.guice.TwillModule)1 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1