/**
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.pnc.executor.servicefactories;

import org.jboss.pnc.model.SystemImageType;
import org.jboss.pnc.spi.environment.EnvironmentDriver;
import org.jboss.pnc.spi.executor.exceptions.ExecutorException;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;

/**
 * Creates instances of environment drivers
 * 
 * @author Jakub Bartecek &lt;jbartece@redhat.com&gt;
 *
 */
@ApplicationScoped
public class EnvironmentDriverFactory {

    @Inject
    Instance<EnvironmentDriver> availableDrivers;
    
    /**
     * Gets environment driver, which can manage requested environment
     * @param buildType Requested build system specification
     * @return Available driver for given environment
     * @throws ExecutorException Throw if no suitable driver for selected environment was found
     */
    public EnvironmentDriver getDriver(SystemImageType systemImageType) throws ExecutorException {
        for (EnvironmentDriver driver : availableDrivers) {
            if (driver.canRunImageType(systemImageType))
                return driver;
        }

        throw new ExecutorException("No environment driver available for " + systemImageType + " system image type.");
    }
}

/**
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.pnc.executor.servicefactories;

import org.jboss.pnc.model.SystemImageType;
import org.jboss.pnc.spi.environment.EnvironmentDriver;
import org.jboss.pnc.spi.executor.exceptions.ExecutorException;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;

/**
 * Creates instances of environment drivers
 * 
 * @author Jakub Bartecek &lt;jbartece@redhat.com&gt;
 *
 */
@ApplicationScoped
public class EnvironmentDriverFactory {

    @Inject
    Instance<EnvironmentDriver> availableDrivers;
    
    /**
     * Gets environment driver, which can manage requested environment
     * @return Available driver for given systemImageType
     * @throws ExecutorException Throw if no suitable driver for selected environment was found
     */
    public EnvironmentDriver getDriver(SystemImageType systemImageType) throws ExecutorException {
        for (EnvironmentDriver driver : availableDrivers) {
            if (driver.canRunImageType(systemImageType))
                return driver;
        }

        throw new ExecutorException("No environment driver available for " + systemImageType + " system image type.");
    }
}

Fix api doc.