001/*
002 * ModeShape (http://www.modeshape.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *       http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.modeshape.schematic;
017
018import org.modeshape.schematic.document.Document;
019
020/**
021 * Service interface for {@link SchematicDb} providers. A particular provider is expected to implement this interface
022 * and make itself available for discovery using the standard {@link java.util.ServiceLoader} mechanism. 
023 * 
024 * @author Horia Chiorean (hchiorea@redhat.com)
025 * @since 5.0
026 */
027public interface SchematicDbProvider<T extends SchematicDb> {
028
029    /**
030     * Returns a schematic DB instance for a given db type and configuration document
031     * 
032     * @param type the type of DB; may not be {@code null}
033     * @param configuration a {@code Document} instance which contains the configuration of a particular DB.
034     * @return a {@link SchematicDb} instance or {@code null} if a particular provider does not recognize the type.
035     * 
036     * @throws RuntimeException if a DB provider recognizes the type, but fails in an expected way to provide a valid DB 
037     * instance.
038     */
039    T getDB(String type, Document configuration);
040}