001package net.sf.jkniv.sqlegance.builder;
002
003import java.util.Properties;
004
005import net.sf.jkniv.sqlegance.SqlContext;
006
007/**
008 * Load the SQL sentences from XML file build a new context to the queries
009 * 
010 * @author Alisson Gomes
011 * @since 0.6.0
012 */
013public class SqlContextFactory
014{
015    /**
016     * Build a new context from SQL sentences
017     * @param resourceName Initial XML file with SQL sentences
018     * @return SQL sentences that belong to repository (like database)
019     */
020    public static SqlContext newInstance(String resourceName)
021    {
022        return new ClassPathSqlContext(resourceName);
023    }
024
025    /**
026     * Build a new context from SQL sentences
027     * @param resourceName Initial XML file with SQL sentences
028     * @param props customized properties to SQL context, see {@code RepositoryProperty} enumeration 
029     * @return SQL sentences that belong to repository (like database)
030     */
031    public static SqlContext newInstance(String resourceName, Properties props)
032    {
033        return new ClassPathSqlContext(resourceName, props);
034    }
035
036    /**
037     * Build a new context from SQL sentences
038     * @param resourceName Initial XML file with SQL sentences
039     * @param repositoryConfigName name of repository
040     * @return SQL sentences that belong to repository (like database)
041     */
042    public static SqlContext newInstance(String resourceName, String repositoryConfigName)
043    {
044        return new ClassPathSqlContext(resourceName, repositoryConfigName, null);
045    }
046
047}