KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > joramplatform > ListRemoteDestinationsAction


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 package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
23
24 import java.io.IOException JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.Vector JavaDoc;
27
28 import javax.management.ObjectName JavaDoc;
29 import javax.servlet.ServletException JavaDoc;
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32
33 import org.apache.struts.action.ActionForm;
34 import org.apache.struts.action.ActionForward;
35 import org.apache.struts.action.ActionMapping;
36
37 import org.objectweb.jonas.jmx.JonasManagementRepr;
38 import org.objectweb.jonas.jmx.JonasObjectName;
39 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
40
41 /**
42  * @author Adriana Danes
43  */

44
45 public class ListRemoteDestinationsAction extends EditJoramBaseAction {
46
47 // --------------------------------------------------------- Public Methods
48

49     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
50         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
51         throws IOException JavaDoc, ServletException JavaDoc {
52
53         String JavaDoc id = pRequest.getParameter("id");
54         if (id == null) {
55             // Try to get from the session
56
id = (String JavaDoc) m_Session.getAttribute("remoteServerId");
57         }
58         
59         // Force the node selected in tree
60
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR
61                 + "joramplatform" + WhereAreYou.NODE_SEPARATOR
62                 + "joramremoteserver" + id, true);
63
64         try {
65             // Object name used for JmslocalServer MBean
66
ObjectName JavaDoc oObjectName = JonasObjectName.joramRemoteServer(id);
67             String JavaDoc asDestName = null;
68             ArrayList JavaDoc alQueues = new ArrayList JavaDoc();
69             // get queues
70
Vector JavaDoc v = (Vector JavaDoc) JonasManagementRepr.invoke(oObjectName, "retrieveRemoteQueuesNames", null, null);
71             if (v != null) {
72                 for (int i = 0; i < v.size(); i++) {
73                     asDestName = (String JavaDoc) v.get(i);
74                     boolean deps = false;
75                     // Chech dependences
76
// TO DO
77
alQueues.add(new DestinationItem(asDestName, "queue", deps));
78                 }
79             }
80             // get topicss
81
v = (Vector JavaDoc) JonasManagementRepr.invoke(oObjectName, "retrieveRemoteTopicsNames", null, null);
82             ArrayList JavaDoc alTopics = new ArrayList JavaDoc();
83             if (v != null) {
84                 for (int i = 0; i < v.size(); i++) {
85                     asDestName = (String JavaDoc) v.get(i);
86                     boolean deps = false;
87                     // Chech dependences
88
// TO DO
89
alTopics.add(new DestinationItem(asDestName, "topic", deps));
90                 }
91             }
92
93             // merge alQueues and alTopics in alDestinations
94
ArrayList JavaDoc alDestinations = new ArrayList JavaDoc(alQueues);
95             alDestinations.addAll(alTopics);
96
97             pRequest.setAttribute("destinationsList", alDestinations);
98         } catch (Throwable JavaDoc t) {
99             return (treatError(t, pMapping, pRequest));
100         }
101
102         // Forward to the jsp.
103
return (pMapping.findForward("Joram Remote Destinations"));
104     }
105
106 }
107
Popular Tags