All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.instaclustr.guice.ServiceBindings Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.instaclustr.guice;

import com.google.common.util.concurrent.Service;
import com.google.inject.Binder;
import com.google.inject.multibindings.Multibinder;

public final class ServiceBindings {
    private ServiceBindings() {}

    public static void bindService(final Binder binder, final Class serviceClass) {
        binder.bind(serviceClass).asEagerSingleton(); // ensure only one copy of the Service exists

        final Multibinder serviceMultibinder = Multibinder.newSetBinder(binder, Service.class);

        serviceMultibinder.addBinding().to(serviceClass);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy