2 * put your module comment here
12 import com.javaexchange.dbConnectionBroker.*;
16 * Diese Klasse realisert den Zugriff auf die Konfiguration.
19 public class Configuration {
21 private static HashMap confs = new HashMap(); // key: conffilename, confHash
22 private static HashMap c = new HashMap();
23 private String confFilename;
24 private static String defaultconfFilename;
25 private static int instances=0;
26 static ResourceBundle conf;
28 public static void initConfig(String confName) {
29 conf = ResourceBundle.getBundle(confName);
30 confs.put("confname",confName);
33 public static void addBroker(String driver, String URL){
35 System.err.println("--trying to add broker");
36 String username,passwd,min,max,log,reset;
38 if(!c.containsKey("Pool.broker")){
39 username=conf.getString("Database.Username");
40 passwd=conf.getString("Database.Password");
41 min=conf.getString("Database.poolMin");
42 max=conf.getString("Database.poolMax");
43 log=conf.getString("Home") + conf.getString("Database.PoolLog");
44 reset=conf.getString("Database.poolResetTime");
47 System.err.println("-- making Broker for -"
49 + " log " + log + " user "
50 + username + " pass: " + passwd);
52 DbConnectionBroker br = new DbConnectionBroker(driver,URL,username,passwd,(new Integer(min)).intValue(),
53 (new Integer(max)).intValue(),log,(new Float(reset)).floatValue());
56 c.put("Pool.broker",br);
58 throw new Exception();
61 System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace();
68 * Fragt ab, ob das Betriebssystem Windows ist.
69 * @return true wenn ja, sonst false.
71 public static boolean isWindows() {
72 return System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
76 * Liefert Wert einer Property zurueck
78 * @return Wert der Property
80 public static String getProperty(String propName) { // default
81 return conf.getString(propName);
85 * Liest eine Property eines Modules aus der Konfiguration
89 * @return Wert der Property
91 public String getProperty(String filename ,String theModule, String propName) {
92 return getProperty(filename, theModule + "." + propName);
96 * Liest eine Property aus der Konfiguration
99 * @return Wert der Property
101 public static String getProperty(String filename, String propName) {
102 if (filename != null) {
104 HashMap conf = ((HashMap)confs.get("confname"));
107 System.err.println("Keine Konfiguration fuer " + filename);
109 prop = (String)conf.get(propName);
113 System.err.println("Keine Konfiguration fuer " + filename + " " + propName);
119 System.err.println("--- filename null!");
126 * Liefert DBConnectionBroker einer Configuration zurueck
127 * @param confFilename
128 * @return DBConnectionBroker
130 public static DbConnectionBroker getBroker() {
131 DbConnectionBroker broker=null;
132 broker=(DbConnectionBroker)c.get("Pool.broker");
134 System.err.println("Konnte kein ConnectionPoolBroker initialisiert werden");
140 * Liefert Hashtabel mit den Konfigurationen
143 public static HashMap getConfs(){
147 public static DbConnectionBroker getBrokerInfo(){
148 return (DbConnectionBroker)c.get("Pool.broker");
155 public void finalize(){
159 } catch (Throwable t) {}
163 * Liefert Anzahl der Instantiierten DBConnectionBroker zurueck
166 public static int getBrokerInstances() {