Store db parameters in Config object, not in CFB object.
[cfb.git] / prod / net / jaekl / cfb / Config.java
index 8aa423419ef74ab08fee0c9764124d9215ba5b72..76151a7c64c3b0159ede64dddd5dc2cb26624422 100644 (file)
@@ -17,6 +17,11 @@ import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 
 public class Config {
+       private static final String DB_HOST = "db.host";
+       private static final String DB_NAME = "db.name";
+       private static final String DB_PASS = "db.pass";
+       private static final String DB_PORT = "db.port";
+       private static final String DB_USER = "db.user";
        private static final String FINDBUGS_HOME = "FindBugsHome";
        private static final String MAIL_FROM = "mail.from";
        private static final String MAIL_SMTP_HOST = "mail.smtp.host";
@@ -64,6 +69,18 @@ public class Config {
        public String getMailSmtpHost() { return m_mailSmtpHost; }
        public ArrayList<String> getNotify() { return new ArrayList<String>(m_notify); }
        
+       public String getDbHost() { return m_host; }
+       public int    getDbPort() { return m_port; }
+       public String getDbName() { return m_dbName; }
+       public String getDbUser() { return m_user; }
+       public String getDbPass() { return m_pass; }
+       
+       public void setDbHost(String value) { m_host = value; }
+       public void setDbPort(int value)    { m_port = value; }
+       public void setDbName(String value) { m_dbName = value; }
+       public void setDbUser(String value) { m_user = value; }
+       public void setDbPass(String value) { m_pass = value; }
+       
        public void readFile(File configProperties) throws IOException
        {
                Properties props = new Properties();
@@ -79,6 +96,21 @@ public class Config {
                        }
                }
                
+               if (props.containsKey(DB_HOST)) {
+                       m_host = props.getProperty(DB_HOST);
+               }
+               if (props.containsKey(DB_NAME)) {
+                       m_dbName = props.getProperty(DB_NAME);
+               }
+               if (props.containsKey(DB_PASS)) {
+                       m_pass = props.getProperty(DB_PASS);
+               }
+               if (props.containsKey(DB_PORT)) {
+                       m_port = Integer.parseInt(props.getProperty(DB_PORT));
+               }
+               if (props.containsKey(DB_USER)) {
+                       m_user = props.getProperty(DB_USER);
+               }
                if (props.containsKey(FINDBUGS_HOME)) {
                        m_fbDir = new File(props.getProperty(FINDBUGS_HOME));
                }