KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > mbean > ListMBeanPropertiesAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ListMBeanPropertiesAction.java,v 1.8 2005/03/15 14:45:29 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.mbean;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 import javax.management.ObjectName JavaDoc;
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.http.HttpServletRequest JavaDoc;
35 import javax.servlet.http.HttpServletResponse JavaDoc;
36
37 import org.apache.struts.action.ActionForm;
38 import org.apache.struts.action.ActionForward;
39 import org.apache.struts.action.ActionMapping;
40 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
41
42 /**
43  * List of all Infos for a MBeans.
44  *
45  * @author Michel-Ange ANTON
46  */

47
48 public final class ListMBeanPropertiesAction extends ListMBeanDetailsAction {
49
50 // --------------------------------------------------------- Public Methods
51
public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
52         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
53         throws IOException JavaDoc, ServletException JavaDoc {
54
55         try {
56             // Save current action
57
setAction(ACTION_PROPERTIES);
58             // Parameter
59
String JavaDoc sSelect = p_Request.getParameter("select");
60
61             // Create a request attribute with our collection of MBeans
62
ArrayList JavaDoc list = new ArrayList JavaDoc();
63             // Get all infos of a MBean
64
ObjectName JavaDoc on = new ObjectName JavaDoc(sSelect);
65             MbeanItem oItem = MbeanItem.build(on);
66
67             // Force the node selected in tree when the direct is used (MBeans list)
68
StringBuffer JavaDoc sbBranch = new StringBuffer JavaDoc("domain*mbeans");
69             sbBranch.append(WhereAreYou.NODE_SEPARATOR);
70             sbBranch.append(sSelect);
71             m_WhereAreYou.selectNameNode(sbBranch.toString(), true);
72
73             // Loop for all properties
74
String JavaDoc sKey;
75             String JavaDoc sValue;
76             Iterator JavaDoc it = on.getKeyPropertyList().keySet().iterator();
77             while (it.hasNext()) {
78                 sKey = (String JavaDoc) it.next();
79                 sValue = on.getKeyProperty(sKey);
80                 list.add(new ViewMBeanProperties(sKey, sValue));
81             }
82             // Set the beans
83
p_Request.setAttribute("MBean", oItem);
84             p_Request.setAttribute("MBeanProperties", list);
85         }
86         catch (Throwable JavaDoc t) {
87             addGlobalError(t);
88             saveErrors(p_Request, m_Errors);
89             return (p_Mapping.findForward("Global Error"));
90         }
91         // Forward to the corresponding display page
92
return p_Mapping.findForward("List MBean Properties");
93     }
94
95 // --------------------------------------------------------- Inner Classes
96

97     public class ViewMBeanProperties {
98         private String JavaDoc key;
99         private String JavaDoc value;
100
101         public ViewMBeanProperties() {
102
103         }
104
105         public ViewMBeanProperties(String JavaDoc ps_Key, String JavaDoc ps_Value) {
106             setKey(ps_Key);
107             setValue(ps_Value);
108         }
109
110         public String JavaDoc getKey() {
111             return key;
112         }
113
114         public void setKey(String JavaDoc key) {
115             this.key = key;
116         }
117
118         public String JavaDoc getValue() {
119             return value;
120         }
121
122         public void setValue(String JavaDoc value) {
123             this.value = value;
124         }
125     }
126
127 }
128
Popular Tags