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

com.netflix.governator.guice.serviceloader.ServiceLoaderBootstrapModule Maven / Gradle / Ivy

package com.netflix.governator.guice.serviceloader;

import java.util.ServiceLoader;

import com.google.common.collect.Lists;
import com.google.inject.Module;
import com.netflix.governator.guice.BootstrapBinder;
import com.netflix.governator.guice.BootstrapModule;

/**
 * BootstrapModule that loads guice modules via the ServiceLoader.
 * 
 * @author elandau
 */
public class ServiceLoaderBootstrapModule implements BootstrapModule {
    private final Class type;
    
    public ServiceLoaderBootstrapModule() {
        this(Module.class);
    }
    
    public ServiceLoaderBootstrapModule(Class type) {
        this.type = type;
    }
    
    @Override
    public void configure(BootstrapBinder binder) {
        ServiceLoader modules = ServiceLoader.load(type);
        binder.includeModules(Lists.newArrayList(modules.iterator()));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy