KickJava   Java API By Example, From Geeks To Geeks.

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


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.Set JavaDoc;
27 import java.util.Vector JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
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.ActionForm;
35 import org.apache.struts.action.ActionForward;
36 import org.apache.struts.action.ActionMapping;
37
38 import org.objectweb.jonas.jmx.JonasManagementRepr;
39 import org.objectweb.jonas.jmx.JonasObjectName;
40 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
41 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
42
43 /**
44  * @author Adriana Danes
45  */

46
47 public class ListLocalDestinationsAction extends EditJoramBaseAction {
48
49     ObjectName JavaDoc ejbServiceObjectName = null;
50     String JavaDoc[] asParam = null;
51     String JavaDoc[] asSignature = null;
52
53     // --------------------------------------------------------- Public Methods
54
public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
55         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
56         throws IOException JavaDoc, ServletException JavaDoc {
57
58         // Force the node selected in tree
59
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR
60                 + "joramplatform" + WhereAreYou.NODE_SEPARATOR
61                 + "joramlocalserver", true);
62
63         // Get reference on EJB container service in order to determine dependencies
64
// between the deployed EJBs and JMS destinations
65
initRefs();
66
67         // Get all destinations
68
String JavaDoc asDestName = null;
69         try {
70             // Object name used for JmslocalServer MBean
71
ObjectName JavaDoc oObjectName = JonasObjectName.joramLocalServer();
72             ArrayList JavaDoc alQueues = new ArrayList JavaDoc();
73             // get queues
74
Vector JavaDoc v = (Vector JavaDoc) getListAttribute(oObjectName, "LocalQueuesNames");
75             if (v != null) {
76                 for (int i = 0; i < v.size(); i++) {
77                     asDestName = (String JavaDoc) v.get(i);
78                     ObjectName JavaDoc queueOn = new ObjectName JavaDoc("joram:type=JMSqueue,name=" + asDestName);
79                     if (JonasAdminJmx.hasMBeanName(queueOn)) {
80                         boolean deps = hasDeps(asDestName);
81                         alQueues.add(new DestinationItem(asDestName, "queue", deps));
82                     }
83                 }
84             }
85             // get topicss
86
v = (Vector JavaDoc) getListAttribute(oObjectName, "LocalTopicsNames");
87             ArrayList JavaDoc alTopics = new ArrayList JavaDoc();
88             if (v != null) {
89                 for (int i = 0; i < v.size(); i++) {
90                     asDestName = (String JavaDoc) v.get(i);
91                     ObjectName JavaDoc topicOn = new ObjectName JavaDoc("joram:type=JMStopic,name=" + asDestName);
92                     if (JonasAdminJmx.hasMBeanName(topicOn)) {
93                         boolean deps = hasDeps(asDestName);
94                         alQueues.add(new DestinationItem(asDestName, "topic", deps));
95                     }
96                 }
97             }
98
99             // merge alQueues and alTopics in alDestinations
100
ArrayList JavaDoc alDestinations = new ArrayList JavaDoc(alQueues);
101             alDestinations.addAll(alTopics);
102
103             pRequest.setAttribute("destinationsList", alDestinations);
104         } catch (Throwable JavaDoc t) {
105             return (treatError(t, pMapping, pRequest));
106         }
107
108         // Forward to the jsp.
109
return (pMapping.findForward("Joram Destinations"));
110     }
111
112 }
113
Popular Tags