001package io.ebean.datasource; 002 003/** 004 * Factory that creates DataSourcePool's. 005 * 006 * <pre>{@code 007 * 008 * DataSourceFactory factory = DataSourceFactory.get(); 009 * 010 * DataSourceConfig config = new DataSourceConfig(); 011 * config.setDriver("org.h2.Driver"); 012 * config.setUrl("jdbc:h2:mem:tests2"); 013 * config.setUsername("sa"); 014 * config.setPassword(""); 015 * 016 * DataSourcePool pool = factory.createPool("test", config); 017 * 018 * Connection connection = pool.getConnection(); 019 * 020 * }</pre> 021 */ 022public interface DataSourceFactory { 023 024 /** 025 * Return the DataSourceFactory. 026 * <p> 027 * The implementation is obtained via standard service loader mechanism requiring an 028 * implementation to be in the classpath. 029 * </p> 030 */ 031 static DataSourceFactory get() { 032 return DSManager.get(); 033 } 034 035 /** 036 * Create the DataSourcePool with the given configuration. 037 * 038 * @param name The name of the pool. 039 * @param config The configuration options. 040 * @return The created DataSourcePool 041 */ 042 DataSourcePool createPool(String name, DataSourceConfig config); 043}