001/* 
002 * JKNIV, SQLegance keeping queries maintainable.
003 * 
004 * Copyright (C) 2017, the original author or authors.
005 *
006 * This library is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 2.1 of the License.
010 * 
011 * This library is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 * 
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with this library; if not, write to the Free Software Foundation, Inc., 
018 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
019 */
020package net.sf.jkniv.whinstone.spi;
021
022import java.util.Properties;
023
024import net.sf.jkniv.sqlegance.RepositoryType;
025import net.sf.jkniv.sqlegance.SqlContext;
026import net.sf.jkniv.whinstone.Repository;
027
028/**
029 * Build a new instance of {@code Repository} Factory to construct it 
030 * according the data access technology like JPA, JDBC, CASSANDRA, COUCHDB, etc
031 * 
032 * @author Alisson Gomes
033 * @since 0.6.0
034 */
035public interface RepositoryFactory
036{
037    /**
038     * New instance of Repository using default name from {@code SqlContext} "repository-sql.xml".
039     * 
040     * @return new instance of {@code Repository}.
041     */
042    Repository newInstance();
043    
044    /**
045     * New instance of {@code Repository} using default name from {@code SqlContext} "repository-sql.xml"
046     * with additional properties.
047     * 
048     * @param props additional properties of {@code Repository}
049     * @return new instance of {@code Repository}.
050     */
051    Repository newInstance(Properties props);
052    
053    /**
054     * New instance of {@code Repository} using additional properties and {@code SqlContext} instance.
055     * 
056     * @param props additional properties of {@code Repository}
057     * @param sqlContext the {@code SqlContext} with the queries from {@code Repository}.
058     * @return new instance of {@code Repository}.
059     */
060    Repository newInstance(Properties props, SqlContext sqlContext);
061    
062    /**
063     * 
064     * @param sqlContext the name of XML file with the queries from {@code Repository}.
065     * @return new instance of {@code Repository}.
066     */
067    Repository newInstance(String sqlContext);
068    
069    /**
070     * 
071     * @param sqlContext the {@code SqlContext} with the queries from {@code Repository}.
072     * @return new instance of {@code Repository}.
073     */
074    Repository newInstance(SqlContext sqlContext);
075    
076    /**
077     * The type of {@code Repository}
078     * @return the type of {@code Repository} like: JDBC, JPA, COUCHDB, CASSANDRA
079     */
080    RepositoryType getType();
081}