View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.misc;
17  
18  import james.core.data.DBConnectionData;
19  import james.gui.application.preferences.config.ConfFile;
20  import p3j.misc.Misc;
21  
22  /**
23   * Main P3J configuration file.
24   * 
25   * @author Christina Bohk
26   * @author Roland Ewald
27   * 
28   */
29  public class P3JConfigFile extends ConfFile {
30  
31    @Override
32    public void setDefaults() {
33  
34      // DAtabase settings
35      put(Misc.PREF_DB_TYPE, Misc.DEFAULT_DB_TYPE);
36      Misc.DEFAULT_DB_TYPE.writePreferences(this,
37          Misc.DEFAULT_DB_TYPE.getDefaults());
38  
39      // Execution settings
40      put(Misc.PREF_NUM_TRIALS, Misc.DEFAULT_NUM_TRIALS);
41      put(Misc.PREF_NUM_PARALLEL_THREADS, Misc.DEFAULT_NUM_PARALLEL_THREADS);
42      put(Misc.PREF_EXECUTION_MODE, Misc.DEFAULT_EXEC_MODE);
43    }
44  
45    /**
46     * Gets the dB connection data as defined in the configuration.
47     * 
48     * @return the database connection data
49     */
50    public DBConnectionData getDBConnectionData() {
51      return new DBConnectionData((String) get(Misc.PREF_DB_URL),
52          (String) get(Misc.PREF_DB_USER), (String) get(Misc.PREF_DB_PWD),
53          (String) get(Misc.PREF_HIBERNATE_DRIVER_PROPERTY));
54    }
55  
56  }