amyroh 02/05/03 16:47:28
Modified: catalina/src/share/org/apache/catalina/mbeans
MBeanFactory.java
Log:
Removes redundant code. Minor JLS formatting.
Patch submitted by Jon Stevens. Thanks Jon.
Revision Changes Path
1.31 +34 -53
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java
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
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- MBeanFactory.java 3 May 2002 00:27:17 -0000 1.30
+++ MBeanFactory.java 3 May 2002 23:47:28 -0000 1.31
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
1.30 2002/05/03 00:27:17 amyroh Exp $
- * $Revision: 1.30 $
- * $Date: 2002/05/03 00:27:17 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v
1.31 2002/05/03 23:47:28 amyroh Exp $
+ * $Revision: 1.31 $
+ * $Date: 2002/05/03 23:47:28 $
*
* ====================================================================
*
@@ -117,7 +117,7 @@
* <code>org.apache.catalina.core.StandardServer</code> component.</p>
*
* @author Amy Roh
- * @version $Revision: 1.30 $ $Date: 2002/05/03 00:27:17 $
+ * @version $Revision: 1.31 $ $Date: 2002/05/03 23:47:28 $
*/
public class MBeanFactory extends BaseModelMBean {
@@ -175,11 +175,28 @@
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 +218,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 +356,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 +542,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 +582,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 +622,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 +662,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 +702,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 +742,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 +782,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 +987,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 +1027,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 +1065,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")) {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>