com.instaclustr.guice.ServiceBindings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common classes and utilities integrated with various projects
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 extends Service> 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);
}
}