01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
21:
22: import java.io.IOException;
23: import java.util.ArrayList;
24: import java.util.Iterator;
25: import java.util.List;
26:
27: import javax.management.ObjectName;
28: import javax.servlet.ServletException;
29: import javax.servlet.http.HttpServletRequest;
30: import javax.servlet.http.HttpServletResponse;
31:
32: import org.apache.struts.action.ActionForm;
33: import org.apache.struts.action.ActionForward;
34: import org.apache.struts.action.ActionMapping;
35:
36: import org.objectweb.jonas.jmx.JonasManagementRepr;
37: import org.objectweb.jonas.jmx.JonasObjectName;
38: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
39:
40: /**
41: * @author Frederic MAISTRE
42: */
43:
44: public class ListJoramServersAction extends EditJoramBaseAction {
45:
46: // --------------------------------------------------------- Public Methods
47:
48: public ActionForward executeAction(ActionMapping pMapping,
49: ActionForm pForm, HttpServletRequest pRequest,
50: HttpServletResponse pResponse) throws IOException,
51: ServletException {
52:
53: // Current JOnAS server
54: String jonasServerName = m_WhereAreYou
55: .getCurrentJonasServerName();
56:
57: // Force the node selected in tree
58: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN)
59: + WhereAreYou.NODE_SEPARATOR + "joramplatform", true);
60:
61: try {
62: // ObjectName for local server
63: ObjectName oName = JonasObjectName.joramLocalServer();
64: String localId = (String) JonasManagementRepr.getAttribute(
65: oName, "LocalServerId", jonasServerName);
66: ArrayList remoteIds = new ArrayList();
67: List list = (List) JonasManagementRepr.getAttribute(oName,
68: "PlatformServersIds", jonasServerName);
69: if (list != null) {
70: Iterator it = list.iterator();
71: String id;
72: while (it.hasNext()) {
73: id = it.next().toString();
74: if (!id.equals(localId)) {
75: remoteIds.add(id);
76: }
77: }
78: }
79: pRequest.setAttribute("localId", localId);
80: pRequest.setAttribute("remoteIds", remoteIds);
81: } catch (Throwable t) {
82: return (treatError(t, pMapping, pRequest));
83: }
84:
85: // Forward to the jsp.
86: return (pMapping.findForward("JoramServers"));
87: }
88:
89: }
|