ListMBeanPropertiesAction.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: ListMBeanPropertiesAction.java,v 1.7 2004/03/19 14:31:47 sauthieg Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.mbean;
00027 
00028 import java.io.IOException;
00029 import java.util.ArrayList;
00030 import java.util.Iterator;
00031 
00032 import javax.management.ObjectName;
00033 import javax.servlet.ServletException;
00034 import javax.servlet.http.HttpServletRequest;
00035 import javax.servlet.http.HttpServletResponse;
00036 
00037 import org.apache.struts.action.ActionForm;
00038 import org.apache.struts.action.ActionForward;
00039 import org.apache.struts.action.ActionMapping;
00040 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00041 
00048 public final class ListMBeanPropertiesAction extends ListMBeanDetailsAction {
00049 
00050 // --------------------------------------------------------- Public Methods
00051     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00052         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00053         throws IOException, ServletException {
00054 
00055         try {
00056             // Save current action
00057             setAction(ACTION_PROPERTIES);
00058             // Parameter
00059             String sSelect = p_Request.getParameter("select");
00060 
00061             // Create a request attribute with our collection of MBeans
00062             ArrayList list = new ArrayList();
00063             // Get all infos of a MBean
00064             ObjectName on = new ObjectName(sSelect);
00065             MbeanItem oItem = MbeanItem.build(on);
00066 
00067             // Force the node selected in tree when the direct is used (MBeans list)
00068             StringBuffer sbBranch = new StringBuffer("mbeans");
00069             sbBranch.append(WhereAreYou.NODE_SEPARATOR);
00070             sbBranch.append(sSelect);
00071             m_WhereAreYou.selectNameNode(sbBranch.toString(), true);
00072 
00073             // Loop for all properties
00074             String sKey;
00075             String sValue;
00076             Iterator it = on.getKeyPropertyList().keySet().iterator();
00077             while (it.hasNext()) {
00078                 sKey = (String) it.next();
00079                 sValue = on.getKeyProperty(sKey);
00080                 list.add(new ViewMBeanProperties(sKey, sValue));
00081             }
00082             // Set the beans
00083             p_Request.setAttribute("MBean", oItem);
00084             p_Request.setAttribute("MBeanProperties", list);
00085         }
00086         catch (Throwable t) {
00087             addGlobalError(t);
00088             saveErrors(p_Request, m_Errors);
00089             return (p_Mapping.findForward("Global Error"));
00090         }
00091         // Forward to the corresponding display page
00092         return p_Mapping.findForward("List MBean Properties");
00093     }
00094 
00095 // --------------------------------------------------------- Inner Classes
00096 
00097     public class ViewMBeanProperties {
00098         private String key;
00099         private String value;
00100 
00101         public ViewMBeanProperties() {
00102 
00103         }
00104 
00105         public ViewMBeanProperties(String ps_Key, String ps_Value) {
00106             setKey(ps_Key);
00107             setValue(ps_Value);
00108         }
00109 
00110         public String getKey() {
00111             return key;
00112         }
00113 
00114         public void setKey(String key) {
00115             this.key = key;
00116         }
00117 
00118         public String getValue() {
00119             return value;
00120         }
00121 
00122         public void setValue(String value) {
00123             this.value = value;
00124         }
00125     }
00126 
00127 }

Generated on Tue Feb 15 15:05:28 2005 for JOnAS by  doxygen 1.3.9.1