really splitting log
[mir.git] / source / mir / misc / MirConfig.java
index 7a58c94..4adcd34 100755 (executable)
@@ -5,7 +5,8 @@ import  java.net.*;
 import  java.io.*;
 import  java.util.*;
 import  java.lang.*;
-import  com.javaexchange.dbConnectionBroker.*;
+import  mir.storage.StorageObjectException;
+import com.codestudio.util.*;
 
 /**
  * Title:        Mir
@@ -43,7 +44,6 @@ public class MirConfig extends Configuration {
 
     configHash.put("Home", home);
     configHash.put("RootUri", uri);
-    configHash.put("ServletName", name);
 
     Enumeration resKeys = getResourceKeys();
     while(resKeys.hasMoreElements()) {
@@ -51,14 +51,22 @@ public class MirConfig extends Configuration {
       configHash.put(keyNm, getProperty(keyNm));
     }
   }
+  /**
+   * Returns the property asked for by pulling it out a HashMap
+   * @param a String containing the property name (key)
+   * @return a String containing the prop. value
+   */
+  public static void setServletName(String servletName) {
+    configHash.put("ServletName",servletName);
+  }
 
   /**
    * Returns the property asked for by pulling it out a HashMap
    * @param a String containing the property name (key)
    * @return a String containing the prop. value
    */
-  public static String getProp(String PropName) {
-    return (String)configHash.get(PropName);
+  public static String getProp(String propName) {
+    return (String)configHash.get(propName);
   }
 
   /**
@@ -67,71 +75,55 @@ public class MirConfig extends Configuration {
    * @param a String containing the property name (key)
    * @return a String containing the prop.value
    */
-  public static String getPropWithHome(String PropName) {
+  public static String getPropWithHome(String propName) {
     return (String)configHash.get("Home") +
-           (String)configHash.get(PropName);
+           (String)configHash.get(propName);
   }
 
-  public static void addBroker(String driver, String URL){
+  public static void addBroker(String driver, String URL) throws StorageObjectException {
 
-    String username,passwd,min,max,log,reset;
+    String username,passwd,min,max,log,reset,dbname,dblogfile;
 
     if(!brokerHash.containsKey("Pool.broker")){
       username=getProp("Database.Username");
       passwd=getProp("Database.Password");
       min=getProp("Database.poolMin");
       max=getProp("Database.poolMax");
-      log=getProp("Home") + configHash.get("Database.PoolLog");
+      dbname=getProp("Database.Name");
+      log=getProp("Home")+ configHash.get("Database.PoolLog");
       reset=getProp("Database.poolResetTime");
-
-      try{
-        System.err.println("-- making Broker for -"
-                            +driver+" - " +URL
-                            + " log " + log + " user "
-                            + username + " pass: " + passwd);
-
-        DbConnectionBroker br = new DbConnectionBroker(driver,URL,username,passwd,(new Integer(min)).intValue(),
-                                                      (new Integer(max)).intValue(),log,(new Float(reset)).floatValue());
-        if (br!=null){
-          instances++;
-          brokerHash.put("Pool.broker",br);
-        } else {
-            throw new Exception();
-        }
-      } catch(Exception e){
-        System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace();
+      dblogfile=getPropWithHome("Database.Logfile");
+
+      System.err.println("-- making Broker for -"
+                          +driver+" - " +URL
+                          + " log " + log + " user "
+                          + username + " pass: " + passwd);
+
+      JDBCPoolMetaData meta = new JDBCPoolMetaData();
+      meta.setDbname(dbname);
+      meta.setDriver(driver);
+      meta.setURL(URL);
+      meta.setUserName(username);
+      meta.setPassword(passwd);
+      meta.setJNDIName("mir");
+      meta.setMaximumSize(Integer.parseInt(max));
+      meta.setMinimumSize(Integer.parseInt(min));
+      meta.setCacheEnabled(true);
+      //meta.setDebugging(true);
+      meta.setLogFile(dblogfile+".pool");
+
+      JDBCPool pool = SQLManager.getInstance().createPool(meta);
+
+      if (pool!=null){
+        instances++;
+        brokerHash.put("Pool.broker",pool);
       }
-    } // end if
-  }
 
-  /**
-   * Liefert DBConnectionBroker einer Configuration zurueck
-   * @param confFilename
-   * @return DBConnectionBroker
-   */
-  public static DbConnectionBroker getBroker() {
-    DbConnectionBroker broker=null;
-    broker=(DbConnectionBroker)brokerHash.get("Pool.broker");
-    if (broker==null) {
-      System.err.println("Konnte kein ConnectionPoolBroker initialisiert werden");
-    }
-    return broker;
-  }
-
-  /**
-   * Liefert Anzahl der Instantiierten DBConnectionBroker zurueck
-   * @return
-   */
-  public static int getBrokerInstances() {
-    return instances;
-  }
-
-  public static DbConnectionBroker getBrokerInfo(){
-    return (DbConnectionBroker)brokerHash.get("Pool.broker");
+    } // end if
   }
 
   /**
-   * Finalize Methode
+   * Finalize method
    */
   public void finalize(){
     instances --;