001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
021:
022: import java.io.IOException;
023: import java.util.ArrayList;
024: import java.util.Vector;
025:
026: import javax.management.ObjectName;
027: import javax.servlet.ServletException;
028: import javax.servlet.http.HttpServletRequest;
029: import javax.servlet.http.HttpServletResponse;
030:
031: import org.apache.struts.action.ActionForm;
032: import org.apache.struts.action.ActionForward;
033: import org.apache.struts.action.ActionMapping;
034:
035: import org.objectweb.jonas.jmx.JonasManagementRepr;
036: import org.objectweb.jonas.jmx.JonasObjectName;
037: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
038:
039: /**
040: * @author Adriana Danes
041: */
042:
043: public class ListRemoteDestinationsAction extends EditJoramBaseAction {
044:
045: // --------------------------------------------------------- Public Methods
046:
047: public ActionForward executeAction(ActionMapping pMapping,
048: ActionForm pForm, HttpServletRequest pRequest,
049: HttpServletResponse pResponse) throws IOException,
050: ServletException {
051:
052: // Current JOnAS server
053: String jonasServerName = m_WhereAreYou
054: .getCurrentJonasServerName();
055:
056: String id = pRequest.getParameter("id");
057: if (id == null) {
058: // Try to get from the session
059: id = (String) m_Session.getAttribute("remoteServerId");
060: }
061:
062: // Force the node selected in tree
063: m_WhereAreYou.selectNameNode(
064: getTreeBranchName(DEPTH_DOMAIN)
065: + WhereAreYou.NODE_SEPARATOR + "joramplatform"
066: + WhereAreYou.NODE_SEPARATOR
067: + "joramremoteserver" + id, true);
068:
069: try {
070: // Object name used for JmslocalServer MBean
071: ObjectName oObjectName = JonasObjectName
072: .joramRemoteServer(id);
073: String asDestName = null;
074: ArrayList alQueues = new ArrayList();
075: // get queues
076: Vector v = (Vector) JonasManagementRepr.invoke(oObjectName,
077: "retrieveRemoteQueuesNames", null, null,
078: jonasServerName);
079: if (v != null) {
080: for (int i = 0; i < v.size(); i++) {
081: asDestName = (String) v.get(i);
082: boolean deps = false;
083: // Chech dependences
084: // TO DO
085: alQueues.add(new DestinationItem(asDestName,
086: "queue", deps));
087: }
088: }
089: // get topicss
090: v = (Vector) JonasManagementRepr.invoke(oObjectName,
091: "retrieveRemoteTopicsNames", null, null,
092: jonasServerName);
093: ArrayList alTopics = new ArrayList();
094: if (v != null) {
095: for (int i = 0; i < v.size(); i++) {
096: asDestName = (String) v.get(i);
097: boolean deps = false;
098: // Chech dependences
099: // TO DO
100: alTopics.add(new DestinationItem(asDestName,
101: "topic", deps));
102: }
103: }
104:
105: // merge alQueues and alTopics in alDestinations
106: ArrayList alDestinations = new ArrayList(alQueues);
107: alDestinations.addAll(alTopics);
108:
109: pRequest.setAttribute("destinationsList", alDestinations);
110: } catch (Throwable t) {
111: return (treatError(t, pMapping, pRequest));
112: }
113:
114: // Forward to the jsp.
115: return (pMapping.findForward("Joram Remote Destinations"));
116: }
117:
118: }
|