KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > ApplyTopAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 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: ApplyTopAction.java,v 1.10 2005/04/01 09:49:48 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin;
27
28 import java.io.IOException JavaDoc;
29
30 import javax.servlet.ServletException JavaDoc;
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32 import javax.servlet.http.HttpServletResponse JavaDoc;
33
34 import org.apache.struts.action.ActionMessage;
35 import org.apache.struts.action.ActionMessages;
36 import org.apache.struts.action.ActionForm;
37 import org.apache.struts.action.ActionForward;
38 import org.apache.struts.action.ActionMapping;
39
40 import org.objectweb.jonas.jmx.JonasManagementRepr;
41
42 /**
43  * @author Michel-Ange Anton (initial developer)<br>
44  * @author Adriana Danes
45  * @author Florent Benoit (changes for struts 1.2.2)
46  */

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

51     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form, HttpServletRequest JavaDoc p_Request
52         , HttpServletResponse JavaDoc p_Response)
53         throws IOException JavaDoc, ServletException JavaDoc {
54         // What locale does the user want to switch to?
55
String JavaDoc sRequested = ((TopForm) p_Form).getServerSelect();
56
57         // Switch to the specified locale, if it exists
58
if (sRequested != null) {
59             String JavaDoc sCurrentRMIConnectorName = null;
60             try {
61                 // Save current RmiConnector
62
sCurrentRMIConnectorName = JonasManagementRepr.getCurrentRMIConnectorName();
63                 // Set the new RmiConnector
64
JonasManagementRepr.setCurrentRMIConnectorName(sRequested);
65                 // Refresh the current servers
66
m_WhereAreYou.refreshServers(p_Request);
67             } catch (Exception JavaDoc e) {
68                 ActionMessages errors = new ActionMessages();
69                 // Delete RMIconnector_ of string
70
String JavaDoc sServerName = sRequested.substring(13);
71                 errors.add("serverSelect", new ActionMessage("error.server.jonas.serverName.bad"
72                     , sServerName));
73                 try {
74                     // Restore current RmiConnector
75
JonasManagementRepr.setCurrentRMIConnectorName(sCurrentRMIConnectorName);
76                 } catch (Exception JavaDoc eBis) {
77                     // none
78
}
79                 saveErrors(p_Request, errors);
80             }
81         }
82         // Forward control back to the ActionEditTop
83
return (p_Mapping.findForward("ActionEditTop"));
84     }
85 }
86
Popular Tags