KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > jonasserver > EditJvmAction


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: EditJvmAction.java,v 1.4 2005/04/20 11:58:42 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.jonasserver;
27
28 import java.io.IOException JavaDoc;
29
30 import javax.management.MalformedObjectNameException JavaDoc;
31 import javax.management.ObjectName JavaDoc;
32 import javax.servlet.ServletException JavaDoc;
33 import javax.servlet.http.HttpServletRequest JavaDoc;
34 import javax.servlet.http.HttpServletResponse JavaDoc;
35
36 import org.apache.struts.action.ActionMessage;
37 import org.apache.struts.action.ActionMessages;
38 import org.apache.struts.action.ActionForm;
39 import org.apache.struts.action.ActionForward;
40 import org.apache.struts.action.ActionMapping;
41 import org.objectweb.jonas.jmx.JonasManagementRepr;
42 import org.objectweb.jonas.jmx.JonasObjectName;
43 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
44 /**
45  * @author Adriana DANES
46  */

47
48 public class EditJvmAction extends JonasBaseAction {
49
50 // --------------------------------------------------------- Public Methods
51

52     /**
53      * Execute action for JVM management
54      * @param pMapping mapping info
55      * @param pForm form object
56      * @param pRequest HTTP request
57      * @param pResponse HTTP response
58      *
59      * @return An <code>ActionForward</code> instance or <code>null</code>
60      *
61      * @exception IOException if an input/output error occurs
62      * @exception ServletException if a servlet exception occurs
63      */

64     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
65         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
66         throws IOException JavaDoc, ServletException JavaDoc {
67         // Force the node selected in tree
68
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER), true);
69
70         ActionMessages oErrors = new ActionMessages();
71
72         // The MBean of current Jonas server
73
ObjectName JavaDoc on_server = m_WhereAreYou.getCurrentJonasServer();
74         // JVM MBean
75
ObjectName JavaDoc oObjectName = null;
76         // List of JVMs - in reality we have only one
77
String JavaDoc[] jvms = (String JavaDoc []) JonasManagementRepr.getAttribute(on_server, "javaVMs");
78         try {
79             if (jvms.length > 0) {
80                 oObjectName = new ObjectName JavaDoc(jvms[0]);
81             } else {
82                 oErrors.add("JVMs", new ActionMessage("error.server.jonas.jvms"));
83                 saveErrors(pRequest, oErrors);
84                 return (pMapping.findForward("Global Error"));
85             }
86         } catch (MalformedObjectNameException JavaDoc e) {
87             addGlobalError(e);
88             saveErrors(pRequest, m_Errors);
89             return (pMapping.findForward("Global Error"));
90         }
91
92         // Form used
93
JvmForm oForm = (JvmForm) pForm;
94         try {
95             // Copy scalar properties
96
oForm.setJavaVendor(getStringAttribute(oObjectName, "javaVendor"));
97             oForm.setJavaVersion(getStringAttribute(oObjectName, "javaVersion"));
98             oForm.setNode(getStringAttribute(oObjectName, "node"));
99             if (JonasManagementRepr.isRegistered(JonasObjectName.webContainerService())) {
100                 oForm.setPresentServletContainer(true);
101             } else {
102                 oForm.setPresentServletContainer(false);
103             }
104         } catch (Throwable JavaDoc t) {
105             addGlobalError(t);
106             saveErrors(pRequest, m_Errors);
107             return (pMapping.findForward("Global Error"));
108         }
109
110         // Forward to the jsp.
111
return (pMapping.findForward("Jvm"));
112     }
113
114 }
115
Popular Tags