Package com.buschmais.cdo.api.bootstrap

Source Code of com.buschmais.cdo.api.bootstrap.Cdo

package com.buschmais.cdo.api.bootstrap;

import com.buschmais.cdo.api.CdoException;
import com.buschmais.cdo.api.CdoManagerFactory;

import java.util.ServiceLoader;

/**
* Provides methods for bootstrapping CDO.
*/
public class Cdo {

    /**
     * Create a {@link CdoManagerFactory} for the CDO unit identified by name.
     * <p>CDO units are defined in XML descriptors located as classpath resources with the name "/META-INF/cdo.xml".</p>
     *
     * @param name The name of the CDO unit.
     * @return The {@link CdoManagerFactory}.
     */
    public static CdoManagerFactory createCdoManagerFactory(String name) {
        ServiceLoader<CdoBootstrapService> serviceLoader = ServiceLoader.load(CdoBootstrapService.class);
        for (CdoBootstrapService cdoBootstrapService : serviceLoader) {
            CdoManagerFactory cdoManagerFactory = cdoBootstrapService.createCdoManagerFactory(name);
            if (cdoManagerFactory != null) {
                return cdoManagerFactory;
            }
        }
        throw new CdoException("Cannot bootstrap CDO implementation.");
    }

    /**
     * Create a {@link CdoManagerFactory} for the given CDO unit.
     *
     * @param cdoUnit The CDO unit.
     * @return The {@link CdoManagerFactory}.
     */
    public static CdoManagerFactory createCdoManagerFactory(CdoUnit cdoUnit) {
        ServiceLoader<CdoBootstrapService> serviceLoader = ServiceLoader.load(CdoBootstrapService.class);
        for (CdoBootstrapService cdoBootstrapService : serviceLoader) {
            CdoManagerFactory cdoManagerFactory = cdoBootstrapService.createCdoManagerFactory(cdoUnit);
            if (cdoManagerFactory != null) {
                return cdoManagerFactory;
            }
        }
        throw new CdoException("Cannot bootstrap CDO implementation.");
    }

}
TOP

Related Classes of com.buschmais.cdo.api.bootstrap.Cdo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.