KickJava   Java API By Example, From Geeks To Geeks.

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


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: SetupWhereAreYouAction.java,v 1.12 2005/05/13 12:34:44 danesa 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.ActionForm;
36 import org.apache.struts.action.ActionForward;
37 import org.apache.struts.action.ActionMapping;
38 import org.objectweb.jonas.common.JProp;
39 import org.objectweb.jonas.common.Log;
40 import org.objectweb.jonas.jmx.JonasManagementRepr;
41 import org.objectweb.jonas.jmx.ManagementReprLoader;
42 import org.objectweb.util.monolog.api.BasicLevel;
43 import org.objectweb.util.monolog.api.Logger;
44
45 /**
46  * @author Michel-Ange ANTON (initial developer)
47  * @author Florent Benoit (changes for struts 1.2.2)
48  */

49 public class SetupWhereAreYouAction extends JonasBaseAction {
50
51 // --------------------------------------------------------- Public Methods
52

53     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
54         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
55         throws IOException JavaDoc, ServletException JavaDoc {
56         // nothing to do
57
return null;
58     }
59
60     public ActionForward execute(ActionMapping p_Mapping, ActionForm p_Form
61         , HttpServletRequest JavaDoc p_Request, HttpServletResponse JavaDoc p_Response)
62         throws IOException JavaDoc, ServletException JavaDoc {
63
64         // Initialize the instance variables
65
initialize(p_Request);
66
67         try {
68             if (JonasManagementRepr.reprNull()) {
69                 //throw new JonasAdminException(WhereAreYou.EXCEPTION_MBEANSERVER_NOTFOUND);
70
String JavaDoc serverName = null;
71                 try {
72                     // Get the name of the Jonas Server who is running the application
73
JProp oJProp = JProp.getInstance();
74                     serverName = oJProp.getValue(JProp.JONAS_NAME);
75                 } catch (Exception JavaDoc e) {
76                     // Current Jonas not found, can't run jonasAdmin
77
throw new JonasAdminException(WhereAreYou.EXCEPTION_JONASSERVER_NOTFOUND, e.getMessage(), e);
78                 }
79                 ManagementReprLoader.loadServerRepr(serverName);
80             }
81             if (m_WhereAreYou == null) {
82                 m_WhereAreYou = new WhereAreYou();
83                 m_WhereAreYou.initialize(getServlet(), p_Request);
84                 m_Session.setAttribute(WhereAreYou.SESSION_NAME, m_WhereAreYou);
85             } else {
86                 m_WhereAreYou.refreshServers(p_Request);
87             }
88         } catch (JonasAdminException e) {
89
90             String JavaDoc message = m_Resources.getMessage(e.getId());
91             //getServlet().log(message);
92
Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX);
93             if (logger.isLoggable(BasicLevel.DEBUG)) {
94                 logger.log(BasicLevel.DEBUG, message);
95             }
96             m_Errors.add(e.getId(), new ActionMessage(e.getId()));
97             saveErrors(p_Request, m_Errors);
98             return (p_Mapping.findForward("Global Error"));
99         }
100         return (p_Mapping.findForward("Frame Main"));
101     }
102
103 }
104
Popular Tags