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 = ResourceBundle.getBundle("config");
27 static ResourceBundle conf;
29 public static void initConfig(String confName) {
30 conf = ResourceBundle.getBundle(confName);
31 confs.put("confname",confName);
34 public static void addBroker(String driver, String URL){
36 System.err.println("--trying to add broker");
37 String username,passwd,min,max,log,reset;
39 if(!c.containsKey("Pool.broker")){
40 username=conf.getString("Database.Username");
41 passwd=conf.getString("Database.Password");
42 min=conf.getString("Database.poolMin");
43 max=conf.getString("Database.poolMax");
44 log=conf.getString("Home") + conf.getString("Database.PoolLog");
45 reset=conf.getString("Database.poolResetTime");
48 System.err.println("-- making Broker for -"
50 + " log " + log + " user "
51 + username + " pass: " + passwd);
53 DbConnectionBroker br = new DbConnectionBroker(driver,URL,username,passwd,(new Integer(min)).intValue(),
54 (new Integer(max)).intValue(),log,(new Float(reset)).floatValue());
57 c.put("Pool.broker",br);
59 throw new Exception();
62 System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace();
69 * Fragt ab, ob das Betriebssystem Windows ist.
70 * @return true wenn ja, sonst false.
72 public static boolean isWindows() {
73 return System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
77 * Liefert Wert einer Property zurueck
79 * @return Wert der Property
81 public static String getProperty(String propName) { // default
82 return conf.getString(propName);
86 * Liest eine Property eines Modules aus der Konfiguration
90 * @return Wert der Property
92 public String getProperty(String filename ,String theModule, String propName) {
93 return getProperty(filename, theModule + "." + propName);
97 * Liest eine Property aus der Konfiguration
100 * @return Wert der Property
102 public static String getProperty(String filename, String propName) {
103 if (filename != null) {
105 HashMap conf = ((HashMap)confs.get("confname"));
108 System.err.println("Keine Konfiguration fuer " + filename);
110 prop = (String)conf.get(propName);
114 System.err.println("Keine Konfiguration fuer " + filename + " " + propName);
120 System.err.println("--- filename null!");
127 * Liefert DBConnectionBroker einer Configuration zurueck
128 * @param confFilename
129 * @return DBConnectionBroker
131 public static DbConnectionBroker getBroker() {
132 DbConnectionBroker broker=null;
133 broker=(DbConnectionBroker)c.get("Pool.broker");
135 System.err.println("Konnte kein ConnectionPoolBroker initialisiert werden");
141 * Liefert Hashtabel mit den Konfigurationen
144 public static HashMap getConfs(){
148 public static DbConnectionBroker getBrokerInfo(){
149 return (DbConnectionBroker)c.get("Pool.broker");
156 public void finalize(){
160 } catch (Throwable t) {}
164 * Liefert Anzahl der Instantiierten DBConnectionBroker zurueck
167 public static int getBrokerInstances() {