manveen 02/03/23 14:13:42 Modified: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context ContextForm.java SetUpContextAction.java Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context EditContextAction.java SaveContextAction.java Log: refactored "context". Revision Changes Path 1.3 +125 -77 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java Index: ContextForm.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ContextForm.java 9 Mar 2002 00:10:56 -0000 1.2 +++ ContextForm.java 23 Mar 2002 22:13:42 -0000 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java,v 1.2 2002/03/09 00:10:56 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2002/03/09 00:10:56 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/ContextForm.java,v 1.3 2002/03/23 22:13:42 manveen Exp $ + * $Revision: 1.3 $ + * $Date: 2002/03/23 22:13:42 $ * * ==================================================================== * @@ -68,24 +68,44 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import java.net.InetAddress; -import java.util.ArrayList; +import java.util.List; /** * Form bean for the context page. * * @author Manveen Kaur - * @version $Revision: 1.2 $ $Date: 2002/03/09 00:10:56 $ + * @version $Revision: 1.3 $ $Date: 2002/03/23 22:13:42 $ */ public final class ContextForm extends ActionForm { // ----------------------------------------------------- Instance Variables + /** + * The administrative action represented by this form. + */ + private String adminAction = "Edit"; + /** - * The text for the scheme. + * The object name of the Context this bean refers to. */ - //private String scheme = null; - + private String objectName = null; + + /** + * The object name of the parent of this Context. + */ + private String parentObjectName = null; + + /** + * The object name of the loader of this Context. + */ + private String loaderObjectName = null; + + /** + * The object name of the manager of this Context. + */ + private String managerObjectName = null; + /** * The text for the node label. */ @@ -172,31 +192,107 @@ private String mgrMaxSessions = "0"; /** - * The text for the contextName. + * Set of valid values for debug level. */ - private String contextName = null; + private List debugLvlVals = null; - /** - * The text for the loaderName. + /* + * Represent boolean (true, false) values for cookies etc. */ - private String loaderName = null; + private List booleanVals = null; + // ------------------------------------------------------------- Properties + + /** + * Return the administrative action represented by this form. + */ + public String getAdminAction() { + + return this.adminAction; + + } + + + /** + * Set the administrative action represented by this form. + */ + public void setAdminAction(String adminAction) { + + this.adminAction = adminAction; + + } + /** - * The text for the managerName. + * Return the object name of the Context this bean refers to. */ - private String managerName = null; + public String getObjectName() { + + return this.objectName; + + } + + /** + * Set the object name of the Context this bean refers to. + */ + public void setObjectName(String objectName) { + + this.objectName = objectName; + + } /** - * Set of valid values for debug level. + * Return the parent object name of the Context this bean refers to. */ - private ArrayList debugLvlVals = null; + public String getParentObjectName() { + + return this.parentObjectName; + + } + + /** + * Set the parent object name of the Context this bean refers to. + */ + public void setParentObjectName(String parentObjectName) { + + this.parentObjectName = parentObjectName; + + } - /* - * Represent boolean (true, false) values for cookies etc. + /** + * Return the loader object name of the Context this bean refers to. + */ + public String getLoaderObjectName() { + + return this.loaderObjectName; + + } + + /** + * Set the loader object name of the Context this bean refers to. */ - private ArrayList booleanVals = null; + public void setLoaderObjectName(String loaderObjectName) { + + this.loaderObjectName = loaderObjectName; + + } - // ------------------------------------------------------------- Properties + /** + * Return the manager object name of the Context this bean refers to. + */ + public String getManagerObjectName() { + + return this.managerObjectName; + + } + + /** + * Set the manager object name of the Context this bean refers to. + */ + public void setManagerObjectName(String managerObjectName) { + + this.managerObjectName = managerObjectName; + + } /** * Return the label of the node that was clicked. @@ -220,7 +316,7 @@ /** * Return the debugVals. */ - public ArrayList getDebugLvlVals() { + public List getDebugLvlVals() { return this.debugLvlVals; @@ -229,7 +325,7 @@ /** * Set the debugVals. */ - public void setDebugLvlVals(ArrayList debugLvlVals) { + public void setDebugLvlVals(List debugLvlVals) { this.debugLvlVals = debugLvlVals; @@ -238,7 +334,7 @@ /** * Return the booleanVals. */ - public ArrayList getBooleanVals() { + public List getBooleanVals() { return this.booleanVals; @@ -247,7 +343,7 @@ /** * Set the debugVals. */ - public void setBooleanVals(ArrayList booleanVals) { + public void setBooleanVals(List booleanVals) { this.booleanVals = booleanVals; @@ -558,59 +654,7 @@ this.mgrMaxSessions = mgrMaxSessions; } - - /** - * Return the Context Name. - */ - public String getContextName() { - - return this.contextName; - - } - - /** - * Set the Context Name. - */ - public void setContextName(String contextName) { - - this.contextName = contextName; - - } - - /** - * Return the loader Name. - */ - public String getLoaderName() { - - return this.loaderName; - } - - /** - * Set the loader Name. - */ - public void setLoaderName(String loaderName) { - - this.loaderName = loaderName; - - } - /** - * Return the manager Name. - */ - public String getManagerName() { - - return this.managerName; - - } - - /** - * Set the manager Name. - */ - public void setManagerName(String managerName) { - - this.managerName = managerName; - - } // --------------------------------------------------------- Public Methods /** @@ -620,6 +664,10 @@ * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { + + this.objectName = null; + this.loaderObjectName = null; + this.managerObjectName = null; // context properties this.cookies = "false"; 1.2 +7 -7 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SetUpContextAction.java Index: SetUpContextAction.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SetUpContextAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SetUpContextAction.java 13 Feb 2002 00:13:11 -0000 1.1 +++ SetUpContextAction.java 23 Mar 2002 22:13:42 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SetUpContextAction.java,v 1.1 2002/02/13 00:13:11 manveen Exp $ - * $Revision: 1.1 $ - * $Date: 2002/02/13 00:13:11 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SetUpContextAction.java,v 1.2 2002/03/23 22:13:42 manveen Exp $ + * $Revision: 1.2 $ + * $Date: 2002/03/23 22:13:42 $ * * ==================================================================== * @@ -94,7 +94,7 @@ * a context is chosen. * * @author Manveen Kaur - * @version $Revision: 1.1 $ $Date: 2002/02/13 00:13:11 $ + * @version $Revision: 1.2 $ $Date: 2002/03/23 22:13:42 $ */ public class SetUpContextAction extends Action { @@ -343,9 +343,9 @@ //setting values obtained from the mBean to be displayed in the form. contextFm.setNodeLabel(nodeLabel); - contextFm.setContextName(selectedName); - contextFm.setLoaderName(loaderName); - contextFm.setManagerName(managerName); + //contextFm.setContextName(selectedName); + //contextFm.setLoaderName(loaderName); + //contextFm.setManagerName(managerName); contextFm.setDebugLvlVals(debugLvlList); contextFm.setBooleanVals(booleanList); 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/EditContextAction.java Index: EditContextAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/EditContextAction.java,v 1.1 2002/03/23 22:13:42 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/03/23 22:13:42 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 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", "Tomcat", 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.context; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.LabelValueBean; import org.apache.webapp.admin.Lists; import org.apache.webapp.admin.TomcatTreeBuilder; /** * The <code>Action</code> that sets up <em>Edit Context</em> transactions. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/03/23 22:13:42 $ */ public class EditContextAction extends Action { /** * The MBeanServer we will be interacting with. */ private MBeanServer mBServer = null; /** * The MessageResources we will be retrieving messages from. */ private MessageResources resources = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Acquire the resources that we need HttpSession session = request.getSession(); Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY); if (resources == null) { resources = getServlet().getResources(); } // Acquire a reference to the MBeanServer containing our MBeans try { mBServer = ((ApplicationServlet) getServlet()).getServer(); } catch (Throwable t) { throw new ServletException ("Cannot acquire MBeanServer reference", t); } // Set up the object names of the MBeans we are manipulating // Context mBean ObjectName cname = null; // Loader mBean ObjectName lname = null; // Manager mBean ObjectName mname = null; StringBuffer sb = null; try { cname = new ObjectName(request.getParameter("select")); } catch (Exception e) { String message = resources.getMessage("error.contextName.bad", request.getParameter("select")); getServlet().log(message); response.sendError(HttpServletResponse.SC_BAD_REQUEST, message); return (null); } // Get the corresponding loader try { sb = new StringBuffer(cname.getDomain()); sb.append(":type=Loader"); sb.append(",path="); sb.append(cname.getKeyProperty("path")); sb.append(",host="); sb.append(cname.getKeyProperty("host")); sb.append(",service="); sb.append(cname.getKeyProperty("service")); lname = new ObjectName(sb.toString()); } catch (Exception e) { String message = resources.getMessage("error.managerName.bad", sb.toString()); getServlet().log(message); response.sendError(HttpServletResponse.SC_BAD_REQUEST, message); return (null); } // Session manager properties // Get the corresponding Session Manager mBean try { sb = new StringBuffer(cname.getDomain()); sb.append(":type=Manager"); sb.append(",path="); sb.append(cname.getKeyProperty("path")); sb.append(",host="); sb.append(cname.getKeyProperty("host")); sb.append(",service="); sb.append(cname.getKeyProperty("service")); mname = new ObjectName(sb.toString()); } catch (Exception e) { String message = resources.getMessage("error.managerName.bad", sb.toString()); getServlet().log(message); response.sendError(HttpServletResponse.SC_BAD_REQUEST, message); return (null); } // Fill in the form values for display and editing ContextForm contextFm = new ContextForm(); session.setAttribute("contextForm", contextFm); contextFm.setAdminAction("Edit"); contextFm.setObjectName(cname.toString()); contextFm.setLoaderObjectName(lname.toString()); contextFm.setManagerObjectName(mname.toString()); sb = new StringBuffer("Context ("); sb.append(cname.getKeyProperty("path")); sb.append(")"); contextFm.setNodeLabel(sb.toString()); contextFm.setDebugLvlVals(Lists.getDebugLevels()); contextFm.setBooleanVals(Lists.getBooleanValues()); String attribute = null; try { // Copy scalar properties attribute = "debug"; contextFm.setDebugLvl (((Integer) mBServer.getAttribute(cname, attribute)).toString()); attribute = "path"; contextFm.setPath ((String) mBServer.getAttribute(cname, attribute)); attribute = "cookies"; contextFm.setCookies (((Boolean) mBServer.getAttribute(cname, attribute)).toString()); attribute = "crossContext"; contextFm.setCrossContext (((Boolean) mBServer.getAttribute(cname, attribute)).toString()); attribute = "docBase"; contextFm.setDocBase ((String) mBServer.getAttribute(cname, attribute)); attribute = "workDir"; contextFm.setWorkDir ((String) mBServer.getAttribute(cname, attribute)); attribute = "useNaming"; contextFm.setUseNaming (((Boolean) mBServer.getAttribute(cname, attribute)).toString()); attribute = "reloadable"; contextFm.setReloadable (((Boolean) mBServer.getAttribute(cname, attribute)).toString()); attribute = "override"; contextFm.setOverride (((Boolean) mBServer.getAttribute(cname, attribute)).toString()); // loader properties attribute = "debug"; contextFm.setLdrDebugLvl (((Integer) mBServer.getAttribute(lname, attribute)).toString()); attribute = "checkInterval"; contextFm.setLdrCheckInterval (((Integer) mBServer.getAttribute(lname, attribute)).toString()); attribute = "reloadable"; contextFm.setLdrReloadable (((Boolean) mBServer.getAttribute(lname, attribute)).toString()); // manager properties attribute = "debug"; contextFm.setMgrDebugLvl (((Integer) mBServer.getAttribute(mname, attribute)).toString()); attribute = "entropy"; contextFm.setMgrSessionIDInit ((String) mBServer.getAttribute(mname, attribute)); attribute = "maxActiveSessions"; contextFm.setMgrMaxSessions (((Integer) mBServer.getAttribute(mname, attribute)).toString()); attribute = "checkInterval"; contextFm.setMgrCheckInterval (((Integer) mBServer.getAttribute(mname, attribute)).toString()); } catch (Throwable t) { getServlet().log (resources.getMessage(locale, "users.error.attribute.get", attribute), t); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.attribute.get", attribute)); return (null); } // Forward to the context display page return (mapping.findForward("Context")); } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SaveContextAction.java Index: SaveContextAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/context/SaveContextAction.java,v 1.1 2002/03/23 22:13:42 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/03/23 22:13:42 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 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.context; import java.net.URLEncoder; import java.util.Iterator; import java.util.Locale; import java.io.IOException; import javax.management.Attribute; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.QueryExp; import javax.management.Query; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.TomcatTreeBuilder; import org.apache.webapp.admin.TreeControl; import org.apache.webapp.admin.TreeControlNode; /** * The <code>Action</code> that completes <em>Add Context</em> and * <em>Edit Context</em> transactions. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/03/23 22:13:42 $ */ public final class SaveContextAction extends Action { // ----------------------------------------------------- Instance Variables /** * Signature for the <code>createStandardContext</code> operation. */ private String createStandardContextTypes[] = { "java.lang.String", // parent "java.lang.String", // path "java.lang.String", // docBase }; /** * Signature for the <code>createStandardLoader</code> operation. */ private String createStandardLoaderTypes[] = { "java.lang.String", // parent }; /** * Signature for the <code>createStandardManager</code> operation. */ private String createStandardManagerTypes[] = { "java.lang.String", // parent }; /** * The MBeanServer we will be interacting with. */ private MBeanServer mBServer = null; /** * The MessageResources we will be retrieving messages from. */ private MessageResources resources = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Acquire the resources that we need HttpSession session = request.getSession(); Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY); if (resources == null) { resources = getServlet().getResources(); } // Acquire a reference to the MBeanServer containing our MBeans try { mBServer = ((ApplicationServlet) getServlet()).getServer(); } catch (Throwable t) { throw new ServletException ("Cannot acquire MBeanServer reference", t); } // Identify the requested action ContextForm cform = (ContextForm) form; String adminAction = cform.getAdminAction(); String cObjectName = cform.getObjectName(); String lObjectName = cform.getLoaderObjectName(); String mObjectName = cform.getManagerObjectName(); // Perform a "Create Context" transaction (if requested) if ("Create".equals(adminAction)) { String operation = null; Object values[] = null; try { // get the parent host name String parentName = cform.getParentObjectName(); ObjectName honame = new ObjectName(parentName); // Ensure that the requested context name is unique ObjectName oname = new ObjectName(TomcatTreeBuilder.CONTEXT_TYPE + ",path=" + cform.getPath() + ",host=" + honame.getKeyProperty("host") + ",service=" + honame.getKeyProperty("service")); if (mBServer.isRegistered(oname)) { ActionErrors errors = new ActionErrors(); errors.add("contextName", new ActionError("error.contextName.exists")); saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } // Look up our MBeanFactory MBean ObjectName fname = new ObjectName(TomcatTreeBuilder.FACTORY_TYPE); // Create a new StandardContext object values = new Object[3]; values[0] = parentName; values[1] = cform.getPath(); values[2] = cform.getDocBase(); operation = "createStandardContext"; cObjectName = (String) mBServer.invoke(fname, operation, values, createStandardContextTypes); // Create a new StandardLoader object values = new String[1]; values[0] = parentName; operation = "createStandardLoader"; lObjectName = (String) mBServer.invoke(fname, operation, values, createStandardLoaderTypes); // Create a new StandardManager object values = new String[1]; values[0] = parentName; operation = "createStandardManager"; mObjectName = (String) mBServer.invoke(fname, operation, values, createStandardManagerTypes); // Add the new Context to our tree control node TreeControl control = (TreeControl) session.getAttribute("treeControlTest"); if (control != null) { TreeControlNode parentNode = control.findNode(parentName); if (parentNode != null) { String nodeLabel = "Context (" + cform.getPath() + ")"; String encodedName = URLEncoder.encode(cObjectName); TreeControlNode childNode = new TreeControlNode(cObjectName, "folder_16_pad.gif", nodeLabel, "EditContext.do?select=" + encodedName, "content", true); parentNode.addChild(childNode); // FIXME - force a redisplay } else { getServlet().log ("Cannot find parent node '" + parentName + "'"); } } else { getServlet().log ("Cannot find TreeControlNode!"); } } catch (Exception e) { getServlet().log (resources.getMessage(locale, "users.error.invoke", operation), e); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.invoke", operation)); return (null); } } // Perform attribute updates as requested String attribute = null; try { ObjectName coname = new ObjectName(cObjectName); ObjectName loname = new ObjectName(lObjectName); ObjectName moname = new ObjectName(mObjectName); attribute = "debug"; int debug = 0; try { debug = Integer.parseInt(cform.getDebugLvl()); } catch (Throwable t) { debug = 0; } mBServer.setAttribute(coname, new Attribute("debug", new Integer(debug))); attribute = "path"; String path = ""; try { path = cform.getPath(); } catch (Throwable t) { path = ""; } mBServer.setAttribute(coname, new Attribute("path", path)); attribute = "workDir"; String workDir = ""; try { workDir = cform.getWorkDir(); } catch (Throwable t) { workDir = ""; } mBServer.setAttribute(coname, new Attribute("workDir", workDir)); attribute = "cookies"; String cookies = "false"; try { cookies = cform.getCookies(); } catch (Throwable t) { cookies = "false"; } mBServer.setAttribute(coname, new Attribute("cookies", new Boolean(cookies))); attribute = "crossContext"; String crossContext = "false"; try { crossContext = cform.getCrossContext(); } catch (Throwable t) { crossContext = "false"; } mBServer.setAttribute(coname, new Attribute("crossContext", new Boolean(crossContext))); attribute = "override"; String override = "false"; try { override = cform.getOverride(); } catch (Throwable t) { override = "false"; } mBServer.setAttribute(coname, new Attribute("override", new Boolean(override))); attribute = "reloadable"; String reloadable = "false"; try { reloadable = cform.getReloadable(); } catch (Throwable t) { reloadable = "false"; } mBServer.setAttribute(coname, new Attribute("reloadable", new Boolean(reloadable))); attribute = "useNaming"; String useNaming = "false"; try { useNaming = cform.getUseNaming(); } catch (Throwable t) { useNaming = "false"; } mBServer.setAttribute(coname, new Attribute("useNaming", new Boolean(useNaming))); // Loader properties attribute = "reloadable"; try { reloadable = cform.getLdrReloadable(); } catch (Throwable t) { reloadable = "false"; } mBServer.setAttribute(loname, new Attribute("reloadable", new Boolean(reloadable))); attribute = "debug"; try { debug = Integer.parseInt(cform.getLdrDebugLvl()); } catch (Throwable t) { debug = 0; } mBServer.setAttribute(loname, new Attribute("debug", new Integer(debug))); attribute = "checkInterval"; int checkInterval = 0; try { checkInterval = Integer.parseInt(cform.getLdrCheckInterval()); } catch (Throwable t) { checkInterval = 0; } mBServer.setAttribute(loname, new Attribute("checkInterval", new Integer(checkInterval))); // Manager properties attribute = "entropy"; String entropy = ""; try { entropy = cform.getMgrSessionIDInit(); } catch (Throwable t) { entropy = ""; } mBServer.setAttribute(moname, new Attribute("entropy",entropy)); attribute = "debug"; try { debug = Integer.parseInt(cform.getMgrDebugLvl()); } catch (Throwable t) { debug = 0; } mBServer.setAttribute(moname, new Attribute("debug", new Integer(debug))); attribute = "checkInterval"; try { checkInterval = Integer.parseInt(cform.getMgrCheckInterval()); } catch (Throwable t) { checkInterval = 0; } mBServer.setAttribute(moname, new Attribute("checkInterval", new Integer(checkInterval))); attribute = "maxActiveSessions"; int maxActiveSessions = -1; try { maxActiveSessions = Integer.parseInt(cform.getMgrMaxSessions()); } catch (Throwable t) { maxActiveSessions = -1; } mBServer.setAttribute(moname, new Attribute("maxActiveSessions", new Integer(maxActiveSessions))); } catch (Exception e) { getServlet().log (resources.getMessage(locale, "users.error.attribute.set", attribute), e); response.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, resources.getMessage(locale, "users.error.attribute.set", attribute)); return (null); } // Forward to the success reporting page session.removeAttribute(mapping.getAttribute()); return (mapping.findForward("Save Successful")); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>