patrickl 01/11/18 13:09:13 Modified: webapps/admin/WEB-INF web.xml webapps/admin/WEB-INF/classes/org/apache/webapp/admin ApplicationServlet.java TreeControlTestListener.java Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin TreeBuilders.java Log: Added option to get a list of TreeBuilder classes from the ApplicationServlet init parameter "treebuilders". Revision Changes Path 1.4 +4 -0 jakarta-tomcat-4.0/webapps/admin/WEB-INF/web.xml Index: web.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/web.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- web.xml 2001/11/08 21:38:30 1.3 +++ web.xml 2001/11/18 21:09:12 1.4 @@ -49,6 +49,10 @@ <param-name>validate</param-name> <param-value>true</param-value> </init-param> + <init-param> + <param-name>treebuilders</param-name> + <param-value>org.apache.webapp.admin.TomcatTreeBuilder</param-value> + </init-param> <load-on-startup>2</load-on-startup> </servlet> 1.3 +45 -4 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java Index: ApplicationServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ApplicationServlet.java 2001/10/27 22:18:50 1.2 +++ ApplicationServlet.java 2001/11/18 21:09:12 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java,v 1.2 2001/10/27 22:18:50 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/10/27 22:18:50 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java,v 1.3 2001/11/18 21:09:12 patrickl Exp $ + * $Revision: 1.3 $ + * $Date: 2001/11/18 21:09:12 $ * * ==================================================================== * @@ -79,7 +79,7 @@ * ApplicationLocales class. * * @author Patrick Luby - * @version $Revision: 1.2 $ $Date: 2001/10/27 22:18:50 $ + * @version $Revision: 1.3 $ $Date: 2001/11/18 21:09:12 $ */ public class ApplicationServlet extends ActionServlet { @@ -95,6 +95,13 @@ public static final String LOCALES_KEY = "applicationLocales"; + /** + * The application scope key under which we store our + * <code>TreeBuilders</code> instance. + */ + public static final String TREEBUILDERS_KEY = "treeBuilders"; + + // ----------------------------------------------------- Instance Variables @@ -154,6 +161,9 @@ // Perform initialization specific to this application initApplicationLocales(); + // Perform initialization of list of TreeBuilder classes + initTreeBuilders(); + } @@ -168,6 +178,37 @@ ApplicationLocales locales = new ApplicationLocales(this); getServletContext().setAttribute(LOCALES_KEY, locales); + + } + + + /** + * Create and initialize the TreeBuilders object, and make it + * available as a servlet context attribute. + */ + protected void initTreeBuilders() { + + // Get the list of tree nodes that we must build from web.xml + String value = getServletConfig().getInitParameter("treebuilders"); + if (value == null || value.length() < 1 ) + return; + + // Parse each comma-delimited entry + int start = 0; + int end = 0; + while (true) { + + // Extract the next comma-delimited entry + end = value.lastIndexOf(",", start); + if (end == -1) + end = value.length(); + String entry = value.substring(start, end).trim(); + TreeBuilders.treeBuilders.add(value); + if (end == value.length()) + break; + start = end; // For the following entry + + } } 1.2 +27 -4 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeControlTestListener.java Index: TreeControlTestListener.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeControlTestListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TreeControlTestListener.java 2001/11/06 20:40:13 1.1 +++ TreeControlTestListener.java 2001/11/18 21:09:12 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeControlTestListener.java,v 1.1 2001/11/06 20:40:13 craigmcc Exp $ - * $Revision: 1.1 $ - * $Date: 2001/11/06 20:40:13 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeControlTestListener.java,v 1.2 2001/11/18 21:09:12 patrickl Exp $ + * $Revision: 1.2 $ + * $Date: 2001/11/18 21:09:12 $ * * ==================================================================== * @@ -63,9 +63,12 @@ package org.apache.webapp.admin; +import java.util.List; +import java.util.Iterator; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; +import org.apache.struts.action.ActionServlet; /** @@ -73,7 +76,8 @@ * for the tree control test. * * @author Craig R. McClanahan - * @version $Revision: 1.1 $ $Date: 2001/11/06 20:40:13 $ + * @author Patrick Luby + * @version $Revision: 1.2 $ $Date: 2001/11/18 21:09:12 $ */ public class TreeControlTestListener implements HttpSessionListener { @@ -91,15 +95,33 @@ HttpSession session = event.getSession(); + // Create the ROOT-NODE TreeControlNode root = new TreeControlNode("ROOT-NODE", null, "Root Node", "treeControlTest.do?select=ROOT-NODE", null, true); TreeControl control = new TreeControl(root); + control.selectNode("ROOT-NODE"); TreeControlNode parent = null; TreeControlNode child = null; + // Create child nodes based on the servlet's init parameter + List treeBuilders = TreeBuilders.getTreeBuilders(); + + Iterator iterator = treeBuilders.iterator(); + while (iterator.hasNext()) { + + String currentBuilder = (String)(iterator.next()); + if (currentBuilder == null || currentBuilder.length() < 1) + continue; + + // FIXME: We need to dynamically load the class name that + // currentBuilder is set to and invoke its buildTree method. + // However, right now, we only invoke the hard-code tree below + if (!currentBuilder.equals("org.apache.webapp.admin.TomcatTreeBuilder")) + continue; + parent = new TreeControlNode("CATALINA", "folder_16_pad.gif", "Tomcat Server", @@ -137,7 +159,6 @@ "treeControlTest.do?select=SERVICE-TOMCAT-APACHE", null, true); parent.addChild(child); - control.selectNode("SERVICE-TOMCAT-APACHE"); parent = child; child = @@ -162,6 +183,8 @@ "treeControlTest.do?select=RESOURCES", null, true); parent.addChild(child); + // FIXME: end of hard-coding that needs to be replaced + } event.getSession().getServletContext().log ("TreeControlTestListener: Session " + 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeBuilders.java Index: TreeBuilders.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TreeBuilders.java,v 1.1 2001/11/18 21:09:12 patrickl Exp $ * $Revision: 1.1 $ * $Date: 2001/11/18 21:09:12 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; import org.apache.struts.action.ActionServlet; import org.apache.struts.util.MessageResources; /** * Class to hold the list of TreeBuilder classes supported by this package. * * @author Patrick Luby * @version $Revision: 1.1 $ $Date: 2001/11/18 21:09:12 $ */ public final class TreeBuilders { // ------------------------------------------------------- Static Variables /** * The list of TreeBuilder class names supported by this application. */ protected static ArrayList treeBuilders = new ArrayList(); // --------------------------------------------------------- Static Methods /** * Return the list of TreeBuilder classes names supported by this application. */ public static List getTreeBuilders() { return (treeBuilders); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>