Search in sources :

Example 81 with Singleton

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;
}
Also used : WebDavServer(org.cryptomator.frontend.webdav.WebDavServer) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 82 with Singleton

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;
}
Also used : DeferredCloser(org.cryptomator.ui.util.DeferredCloser) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 83 with Singleton

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();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 84 with Singleton

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));
}
Also used : Path(java.nio.file.Path) CachingTemplateResolver(ratpack.groovy.template.internal.CachingTemplateResolver) TemplateConfiguration(groovy.text.markup.TemplateConfiguration) MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 85 with Singleton

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));
}
Also used : GsonConverter(retrofit.converter.GsonConverter) RMPClient(com.tevinjeffrey.rmp.client.RMPClient) OkHttpClient(com.squareup.okhttp.OkHttpClient) ClientService(com.tevinjeffrey.rmp.client.ClientService) OkClient(retrofit.client.OkClient) RestAdapter(retrofit.RestAdapter) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Singleton (javax.inject.Singleton)168 Provides (dagger.Provides)98 Provides (com.google.inject.Provides)57 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)21 Named (javax.inject.Named)17 OkHttpClient (okhttp3.OkHttpClient)17 Cache (okhttp3.Cache)10 List (java.util.List)9 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)8 Binder (com.google.inject.Binder)8 Module (com.google.inject.Module)8 CachingStripeMetadataSource (com.facebook.presto.orc.CachingStripeMetadataSource)7 DwrfAwareStripeMetadataSourceFactory (com.facebook.presto.orc.DwrfAwareStripeMetadataSourceFactory)7 OrcDataSourceId (com.facebook.presto.orc.OrcDataSourceId)7 StorageStripeMetadataSource (com.facebook.presto.orc.StorageStripeMetadataSource)7 StripeMetadataSource (com.facebook.presto.orc.StripeMetadataSource)7 StripeMetadataSourceFactory (com.facebook.presto.orc.StripeMetadataSourceFactory)7 CachingOrcFileTailSource (com.facebook.presto.orc.cache.CachingOrcFileTailSource)7 OrcCacheConfig (com.facebook.presto.orc.cache.OrcCacheConfig)7 OrcFileTailSource (com.facebook.presto.orc.cache.OrcFileTailSource)7