Index: MBeanFactory.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
retrieving revision 1.30
diff -u -r1.30 MBeanFactory.java
--- MBeanFactory.java	3 May 2002 00:27:17 -0000	1.30
+++ MBeanFactory.java	3 May 2002 18:43:56 -0000
@@ -175,10 +175,24 @@
             return "Engine";
         } else if (type.equals("org.apache.catalina.core.StandardHost")) {
             return "Host";
-        } else return null;
-
+        } else {
+            return null;
+        }
     }
 
+    /**
+     * Little convenience method to remove redundant code
+     * when retrieving the path string
+     *
+     * @param t path string
+     * @return empty string if t==null || t.equals('/')
+     */
+    private final String getPathStr(String t) {
+        if (t == null || t.equals('/')) {
+            return "";
+        }
+        return t;
+    }
 
     /**
      * Create a new AccessLoggerValve.
@@ -201,10 +215,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             ((StandardContext)context).addValve(accessLogger);
         } else if (type.equals("Engine")) {
@@ -342,10 +353,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setLogger(fileLogger);
         } else if (type.equals("Engine")) {
@@ -531,10 +539,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setRealm(realm);
         } else if (type.equals("Engine")) {
@@ -574,10 +579,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setRealm(realm);
         } else if (type.equals("Engine")) {
@@ -617,10 +619,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setRealm(realm);
         } else if (type.equals("Engine")) {
@@ -660,10 +659,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             ((StandardContext)context).addValve(valve);
         } else if (type.equals("Engine")) {
@@ -703,10 +699,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             ((StandardContext)context).addValve(valve);
         } else if (type.equals("Engine")) {
@@ -746,10 +739,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             ((StandardContext)context).addValve(valve);
         } else if (type.equals("Engine")) {
@@ -789,10 +779,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             ((StandardContext)context).addValve(valve);
         } else if (type.equals("Engine")) {
@@ -997,10 +984,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {        
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setLogger(logger);
         } else if (type.equals("Engine")) {
@@ -1040,10 +1024,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setLogger(logger);
         } else if (type.equals("Engine")) {
@@ -1081,10 +1062,7 @@
         Engine engine = (Engine) service.getContainer();
         if (type.equals("Context")) {
             Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
-            String pathStr = pname.getKeyProperty("path");
-            if (pathStr.equals("/")) {
-                pathStr = "";
-            }
+            String pathStr = getPathStr(pname.getKeyProperty("path"));
             Context context = (Context) host.findChild(pathStr);
             context.setRealm(realm);
         } else if (type.equals("Engine")) {
