X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmisc%2FMirConfig.java;h=0cf485910edbde5b098dfb543adfdd6c6987d99c;hb=cc839c9fcd0e85f65074b5b259e8d5d1ed1b13dd;hp=07676e77862c538155b5725123cb6707678807b3;hpb=07406c649982d8496617dfbf92097a27705303c2;p=mir.git diff --git a/source/mir/misc/MirConfig.java b/source/mir/misc/MirConfig.java index 07676e77..0cf48591 100755 --- a/source/mir/misc/MirConfig.java +++ b/source/mir/misc/MirConfig.java @@ -6,6 +6,7 @@ import java.io.*; import java.util.*; import java.lang.*; import com.javaexchange.dbConnectionBroker.*; +import mir.storage.StorageObjectException; /** * Title: Mir @@ -25,7 +26,7 @@ import com.javaexchange.dbConnectionBroker.*; */ public class MirConfig extends Configuration { - + private static HashMap configHash = new HashMap(); private static HashMap brokerHash = new HashMap(); private static int instances=0; @@ -43,27 +44,44 @@ public class MirConfig extends Configuration { configHash.put("Home", home); configHash.put("RootUri", uri); - configHash.put("ServletName", name); - + Enumeration resKeys = getResourceKeys(); while(resKeys.hasMoreElements()) { String keyNm = (String)resKeys.nextElement(); 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 String getProp(String PropName) { - return (String)configHash.get(PropName); + 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); + } + + /** + * Returns the property asked for by pulling it out a HashMap and + * appending it to configproperty "Home" + * @param a String containing the property name (key) + * @return a String containing the prop.value + */ + public static String getPropWithHome(String propName) { + return (String)configHash.get("Home") + + (String)configHash.get(propName); } - public static void addBroker(String driver, String URL){ + public static void addBroker(String driver, String URL) throws StorageObjectException { - System.err.println("--trying to add broker"); String username,passwd,min,max,log,reset; if(!brokerHash.containsKey("Pool.broker")){ @@ -85,12 +103,11 @@ public class MirConfig extends Configuration { if (br!=null){ instances++; brokerHash.put("Pool.broker",br); - } else { - throw new Exception(); } - } catch(Exception e){ + } catch(IOException e){ System.err.println("Der ConnectionBroker konnte nicht initializiert werden"+ e.toString());e.printStackTrace(); - } + throw new StorageObjectException(e.toString()); + } } // end if } @@ -121,7 +138,7 @@ public class MirConfig extends Configuration { } /** - * Finalize Methode + * Finalize method */ public void finalize(){ instances --;