package be.iminds.ilabt.jfed.highlevel.controller;

import be.iminds.ilabt.jfed.log.cache.ApiCallDetailsCache;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Collection;

/**
 * User: twalcari
 * Date: 12/2/2014
 * Time: 15:54
 */
@Singleton
public class TaskExecutionFactory {

    private final ApiCallDetailsCache cache;

    @Inject
    public TaskExecutionFactory(ApiCallDetailsCache cache) {
        this.cache = cache;
    }

    public <T extends Task> TaskExecution<T> createTaskExecution(T task, Collection<TaskExecutionFinishedCallback<T>> callbacks) {
        return new TaskExecution<>(task, callbacks, cache);
    }

    public <T extends Task> TaskExecution<T> createTaskExecution(T task) {
        return new TaskExecution<>(task, cache);
    }

}
