KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > actions > config > ShowAttributesAction


1 /**
2  * Copyright 2004-2005 jManage.org
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.jmanage.webui.actions.config;
17
18 import org.jmanage.webui.actions.BaseAction;
19 import org.jmanage.webui.util.*;
20 import org.jmanage.webui.forms.AttributeSelectionForm;
21 import org.jmanage.core.management.ServerConnection;
22 import org.jmanage.core.management.ObjectName;
23 import org.jmanage.core.management.ObjectInfo;
24 import org.jmanage.core.management.ObjectAttributeInfo;
25 import org.jmanage.core.services.MBeanService;
26 import org.jmanage.core.services.ServiceFactory;
27 import org.apache.struts.action.ActionMapping;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32 import javax.servlet.http.HttpServletResponse JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.util.TreeMap JavaDoc;
35 import java.util.List JavaDoc;
36
37 /**
38  * Date: Jun 29, 2005 4:48:09 PM
39  * @author Bhavana
40  */

41 public class ShowAttributesAction extends BaseAction{
42     public ActionForward execute(WebContext context,
43                                  ActionMapping mapping,
44                                  ActionForm actionForm,
45                                  HttpServletRequest JavaDoc request,
46                                  HttpServletResponse JavaDoc response)
47             throws Exception JavaDoc {
48
49         AttributeSelectionForm form = (AttributeSelectionForm)actionForm;
50         String JavaDoc[] mbeans = form.getMbeans();
51         ServerConnection serverConn = context.getServerConnection();
52         ObjectName objectName = null;
53         Map JavaDoc mbeanAttributesListMap = new TreeMap JavaDoc();
54         MBeanService mbeanService = ServiceFactory.getMBeanService();
55         for(int i=0; i<mbeans.length;i++){
56             objectName = new ObjectName(mbeans[i]);
57             ObjectInfo objInfo = serverConn.getObjectInfo(objectName);
58             ObjectAttributeInfo[] objAttrInfo = objInfo.getAttributes();
59             List JavaDoc objAttrInfoList = mbeanService.filterAttributes(
60                     Utils.getServiceContext(context),
61                     objectName,
62                     objAttrInfo,
63                     form.getDataTypes());
64             mbeanAttributesListMap.put(mbeans[i],objAttrInfoList);
65         }
66         request.setAttribute("mbeanAttributesMap",mbeanAttributesListMap);
67         /*set current page for navigation*/
68         request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE,
69                 request.getParameter(RequestParams.NAVIGATION));
70         return mapping.findForward(Forwards.SUCCESS);
71     }
72 }
73
Popular Tags