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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations