001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ListMBeanPropertiesAction.java 6414 2005-03-15 14:45:30Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.mbean;
025:
026: import java.io.IOException;
027: import java.util.ArrayList;
028: import java.util.Iterator;
029:
030: import javax.management.ObjectName;
031: import javax.servlet.ServletException;
032: import javax.servlet.http.HttpServletRequest;
033: import javax.servlet.http.HttpServletResponse;
034:
035: import org.apache.struts.action.ActionForm;
036: import org.apache.struts.action.ActionForward;
037: import org.apache.struts.action.ActionMapping;
038: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
039:
040: /**
041: * List of all Infos for a MBeans.
042: *
043: * @author Michel-Ange ANTON
044: */
045:
046: public final class ListMBeanPropertiesAction extends
047: ListMBeanDetailsAction {
048:
049: // --------------------------------------------------------- Public Methods
050: public ActionForward executeAction(ActionMapping p_Mapping,
051: ActionForm p_Form, HttpServletRequest p_Request,
052: HttpServletResponse p_Response) throws IOException,
053: ServletException {
054:
055: try {
056: // Save current action
057: setAction(ACTION_PROPERTIES);
058: // Parameter
059: String sSelect = p_Request.getParameter("select");
060:
061: // Create a request attribute with our collection of MBeans
062: ArrayList list = new ArrayList();
063: // Get all infos of a MBean
064: ObjectName on = new ObjectName(sSelect);
065: MbeanItem oItem = MbeanItem.build(on);
066:
067: // Force the node selected in tree when the direct is used (MBeans list)
068: StringBuffer sbBranch = new StringBuffer("domain*mbeans");
069: sbBranch.append(WhereAreYou.NODE_SEPARATOR);
070: sbBranch.append(sSelect);
071: m_WhereAreYou.selectNameNode(sbBranch.toString(), true);
072:
073: // Loop for all properties
074: String sKey;
075: String sValue;
076: Iterator it = on.getKeyPropertyList().keySet().iterator();
077: while (it.hasNext()) {
078: sKey = (String) it.next();
079: sValue = on.getKeyProperty(sKey);
080: list.add(new ViewMBeanProperties(sKey, sValue));
081: }
082: // Set the beans
083: p_Request.setAttribute("MBean", oItem);
084: p_Request.setAttribute("MBeanProperties", list);
085: } catch (Throwable t) {
086: addGlobalError(t);
087: saveErrors(p_Request, m_Errors);
088: return (p_Mapping.findForward("Global Error"));
089: }
090: // Forward to the corresponding display page
091: return p_Mapping.findForward("List MBean Properties");
092: }
093:
094: // --------------------------------------------------------- Inner Classes
095:
096: public class ViewMBeanProperties {
097: private String key;
098: private String value;
099:
100: public ViewMBeanProperties() {
101:
102: }
103:
104: public ViewMBeanProperties(String ps_Key, String ps_Value) {
105: setKey(ps_Key);
106: setValue(ps_Value);
107: }
108:
109: public String getKey() {
110: return key;
111: }
112:
113: public void setKey(String key) {
114: this .key = key;
115: }
116:
117: public String getValue() {
118: return value;
119: }
120:
121: public void setValue(String value) {
122: this.value = value;
123: }
124: }
125:
126: }
|