/**
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 *
 * Copyright (C)
 * <a href="http://www.inab.org">Spanish National Institute of Bioinformatics (INB)</a>
 * <a href="http://www.bsc.es">Barcelona Supercomputing Center (BSC)</a>
 * <a href="http://inb.bsc.es">Computational Node 6</a>
 */

package org.inb.biomoby.central;

import java.util.Iterator;
//import java.util.ServiceLoader;

/**
 * @author Dmitry Repchevsky
 */

public class MobyCentralFactory
{
    private MobyCentralFactory() {}

    /**
     * Factory method to obtain an implementation of MobyCentralOperations interface
     *
     * @param central - A MobyCentral object which defines which BioMoby Registry we are connecting.
     *
     * @return - MobyCentralOperatons interface implementation to connect to the given BioMoby Registry
     */
    public static MobyCentralOperations getCentralDigest(MobyCentral central)
    {
        ServiceLoader<MobyCentralService> loader = ServiceLoader.load(MobyCentralService.class);
        Iterator<MobyCentralService> iterator = loader.iterator();

        if (iterator.hasNext())
        {
            MobyCentralService service = iterator.next();
            return service.getCentralDigest(central);
        }

        return null;
    }
}
