KickJava   Java API By Example, From Geeks To Geeks.

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


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: EditJonasServerAction.java,v 1.13 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.ObjectName JavaDoc;
31 import javax.servlet.ServletException JavaDoc;
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpServletResponse JavaDoc;
34
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionForward;
37 import org.apache.struts.action.ActionMapping;
38 import org.objectweb.jonas.jmx.J2eeObjectName;
39 import org.objectweb.jonas.jmx.JonasObjectName;
40 import org.objectweb.jonas.jmx.ManagementReprLoader;
41 import org.objectweb.jonas.jmx.JonasManagementRepr;
42 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
43 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
44
45 /**
46  * @author Michel-Ange ANTON
47  */

48
49 public class EditJonasServerAction extends JonasBaseAction {
50
51 // --------------------------------------------------------- Public Methods
52
/**
53      * Execute action for a JOnAS server instance 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
68         String JavaDoc requestedObjectName = (String JavaDoc) pRequest.getParameter("select");
69         boolean changeManagement = false;
70         try {
71             ObjectName JavaDoc on = ObjectName.getInstance(requestedObjectName);
72             String JavaDoc requestedJonasServerName = on.getKeyProperty("name");
73             String JavaDoc currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName();
74             if (!currentJonasServerName.equals(requestedJonasServerName)) {
75                 // change management conext
76
ManagementReprLoader.loadServerRepr(requestedJonasServerName);
77                 // set WhereAreYou for the requested server if context change succeded
78
m_WhereAreYou.refreshServers(pRequest);
79                 if (m_WhereAreYou.getCurrentJonasServerName().equals(requestedJonasServerName)) {
80                     changeManagement = true;
81                 } else {
82                     addGlobalError(new Error JavaDoc("Can't switch management context to server " + requestedJonasServerName));
83                     saveErrors(pRequest, m_Errors);
84                     return (pMapping.findForward("Global Error"));
85                 }
86             }
87
88             if (changeManagement) {
89                 refreshServerTree(pRequest);
90             }
91
92             // Force the node selected in tree
93
m_WhereAreYou.selectNameNode("domain"
94                     + WhereAreYou.NODE_SEPARATOR
95                     + requestedJonasServerName, true);
96
97             // Form used
98
JonasServerForm oForm = (JonasServerForm) pForm;
99             //try {
100
// Object name used
101
ObjectName JavaDoc oObjectName = J2eeObjectName.J2EEServer(m_WhereAreYou.getCurrentDomainName()
102                 , m_WhereAreYou.getCurrentJonasServerName());
103             oForm.setJonasName(m_WhereAreYou.getCurrentJonasServerName());
104             oForm.setJonasVersion(getStringAttribute(oObjectName, "serverVersion"));
105             oForm.setProtocols(getStringAttribute(oObjectName, "protocols"));
106             if (JonasManagementRepr.isRegistered(JonasObjectName.webContainerService())) {
107                 oForm.setPresentServletContainer(true);
108                 if (m_WhereAreYou.isCatalinaServer()) {
109                     oForm.setServerServletContainerInfo("Apache Tomcat");
110                     //oForm.setServerServletContainerInfo(ServerInfo.getServerInfo());
111
}
112             } else {
113                 oForm.setPresentServletContainer(false);
114             }
115         } catch (Throwable JavaDoc t) {
116             addGlobalError(t);
117             saveErrors(pRequest, m_Errors);
118             return (pMapping.findForward("Global Error"));
119         }
120         // Forward to the jsp.
121
return (pMapping.findForward("JonasServer"));
122     }
123
124 }
125
Popular Tags