

package org.apache.commons.pipeline.driver.control;

import org.apache.commons.pipeline.Stage;
import org.apache.commons.pipeline.StageContext;
import org.apache.commons.pipeline.StageDriverFactory;

/**
 * <p>This interface represents a factory that is used by a {@link Pipeline} to create
 * a driver for a {@link Stage} when that stage is added to the pipeline. The factory
 * pattern is used here to ensure that each stage is run by a unique driver
 * instance.</p>
 *
 * <p>In order to guarantee that PrioritizableStageDriverFactory instances can be used
 * effectively in configuration frameworks, each PrioritizableStageDriverFactory implementation
 * <em>must</em> provide a no-argument constructor.
 */
public interface PrioritizableStageDriverFactory<T extends PrioritizableStageDriver> extends StageDriverFactory<T> {
    /**
     * This method is used to create a driver that will run the specified stage
     * in the specified context.
     * @param stage The stage to be run by the newly created driver.
     * @param context The context in which the stage will be run
     * @return The newly created driver
     */
    public T createStageDriver(Stage stage, StageContext context);
        
    /**
     * Sets the initial priority of the driver to be created.
     */
    public void setInitialPriority(double priority);
}
