1 56 package org.objectstyle.cayenne.project; 57 58 import java.io.File ; 59 60 import javax.sql.DataSource ; 61 62 import org.apache.log4j.Level; 63 import org.apache.log4j.Logger; 64 import org.objectstyle.cayenne.ConfigurationException; 65 import org.objectstyle.cayenne.conf.DriverDataSourceFactory; 66 import org.objectstyle.cayenne.conn.DataSourceInfo; 67 68 74 public class ProjectDataSourceFactory extends DriverDataSourceFactory { 75 private static Logger logObj = Logger.getLogger(ProjectDataSourceFactory.class); 76 77 protected File projectDir; 78 79 public ProjectDataSourceFactory(File projectDir) throws Exception { 80 super(); 81 this.projectDir = projectDir; 82 } 83 84 public DataSource getDataSource(String location, Level logLevel) throws Exception { 85 try { 86 this.load(location); 87 } catch (ConfigurationException e) { 88 logObj.info("No data source at '" + location + "', ignoring."); 89 } 90 91 return new ProjectDataSource(this.getDriverInfo()); 92 } 93 94 protected DataSourceInfo getDriverInfo() { 95 DataSourceInfo temp = super.getDriverInfo(); 96 if (null == temp) { 97 temp = new DataSourceInfo(); 98 } 99 100 return temp; 101 } 102 103 } | Popular Tags |