use of javax.inject.Singleton in project cryptomator by cryptomator.
the class CryptomatorModule method provideWebDavServer.
@Provides
@Singleton
WebDavServer provideWebDavServer(Binding<InetSocketAddress> serverSocketAddressBinding) {
WebDavServer server = WebDavServer.create();
// no need to unsubscribe eventually, because server is a singleton
EasyBind.subscribe(serverSocketAddressBinding, server::bind);
return server;
}
use of javax.inject.Singleton in project cryptomator by cryptomator.
the class CryptomatorModule method provideDeferredCloser.
@Provides
@Singleton
DeferredCloser provideDeferredCloser() {
DeferredCloser closer = new DeferredCloser();
Cryptomator.addShutdownTask(() -> {
try {
closer.close();
} catch (Exception e) {
LOG.error("Error during shutdown.", e);
}
});
return closer;
}
use of javax.inject.Singleton in project reark by reark.
the class NetworkModule method provideOkHttpClient.
@Provides
@Singleton
public OkHttpClient provideOkHttpClient(@Named("networkInterceptors") List<Interceptor> networkInterceptors) {
OkHttpClient.Builder okBuilder = new OkHttpClient().newBuilder();
okBuilder.networkInterceptors().addAll(networkInterceptors);
return okBuilder.build();
}
use of javax.inject.Singleton in project ratpack by ratpack.
the class MarkupTemplateModule method provideTemplateEngine.
@SuppressWarnings("UnusedDeclaration")
@Provides
@Singleton
MarkupTemplateEngine provideTemplateEngine(ServerConfig serverConfig, Config config) {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
TemplateConfiguration effectiveConfiguration = new TemplateConfiguration(config);
// not copied by constructor
effectiveConfiguration.setCacheTemplates(config.isCacheTemplates());
Path templatesDir = serverConfig.getBaseDir().file(config.getTemplatesDirectory());
return new MarkupTemplateEngine(parent, effectiveConfiguration, new CachingTemplateResolver(templatesDir));
}
use of javax.inject.Singleton in project Rutgers-Course-Tracker by tevjef.
the class ClientModule method providesRMPClient.
@Provides
@Singleton
public RMPClient providesRMPClient(OkHttpClient client, Gson gson) {
OkHttpClient okClient = client.clone();
okClient.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
okClient.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint("http://rutgersapp.tevindev.me:8080/").setLogLevel(RestAdapter.LogLevel.FULL).setConverter(new GsonConverter(gson)).setClient(new OkClient(okClient)).build();
return new RMPClient(restAdapter.create(ClientService.class));
}
Aggregations