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

io.pity.bootstrap.injection.injectors.TaskInjector Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package io.pity.bootstrap.injection.injectors;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import io.pity.api.PropertyValueProvider;
import io.pity.api.reporting.ReportPublisher;
import io.pity.bootstrap.publish.html.HtmlReportPublisher;

import java.io.IOException;
import java.util.List;

/**
 * Used using the 'task' phase of execution.
 */
public class TaskInjector {

    public static final Class DEFAULT_PUBLISHER = HtmlReportPublisher.class;

    private final Injector injector;

    public TaskInjector(List abstractModules) throws IOException {
        injector = Guice.createInjector(abstractModules);
    }

    public PropertyValueProvider getPropertyValueProvider() {
        return injector.getInstance(PropertyValueProvider.class);
    }

    public Injector getInjector() {
        return injector;
    }

    public  T getInstance(Class clazz) {
        return getInjector().getInstance(clazz);
    }

    public ReportPublisher getReportPublisher() {
        return getInstance(ReportPublisher.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy