KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collections 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 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem;
41 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator;
42
43 /**
44  * @author Frederic MAISTRE
45  */

46
47 public class EditJoramLocalQueueAction extends EditJoramBaseAction {
48
49 // --------------------------------------------------------- Public Methods
50

51     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
52         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
53         throws IOException JavaDoc, ServletException JavaDoc {
54
55         
56         String JavaDoc name = pRequest.getParameter("name");
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" + WhereAreYou.NODE_SEPARATOR
62                     + "joramlocalqueue" + name, true);
63         
64         try {
65             // Form used
66
JoramLocalQueueForm oForm = null;
67             if (name != null) {
68                 // Build a new form
69
oForm = new JoramLocalQueueForm();
70                 oForm.reset(pMapping, pRequest);
71                 // Attach the form to the session object
72
m_Session.setAttribute("joramLocalQueueForm", oForm);
73                 // Object name used
74
ObjectName JavaDoc oObjectName = JonasObjectName.joramQueue(name);
75                 oForm.setName(getStringAttribute(oObjectName, "JndiName"));
76                 oForm.setId(getStringAttribute(oObjectName, "AgentId"));
77             } else {
78                 // Used last form in session
79
oForm = (JoramLocalQueueForm) m_Session.getAttribute("joramLocalQueueForm");
80             }
81
82             // Populuate dependency list
83
if (name != null) {
84                 ArrayList JavaDoc al = new ArrayList JavaDoc();
85                 String JavaDoc[] asParam = new String JavaDoc[1];
86                 String JavaDoc[] asSignature = new String JavaDoc[1];
87                 asSignature[0] = "java.lang.String";
88                 asParam[0] = name;
89                 ObjectName JavaDoc ejbServiceObjectName = JonasObjectName.ejbService();
90                 if (JonasManagementRepr.isRegistered(ejbServiceObjectName)) {
91                     java.util.Iterator JavaDoc it = ((java.util.Set JavaDoc) JonasManagementRepr.invoke(
92                             ejbServiceObjectName, "getJmsDestinationDependence", asParam
93                             , asSignature)).iterator();
94                     while (it.hasNext()) {
95                         al.add(new EjbItem((ObjectName JavaDoc) it.next()));
96                     }
97                     // Sort by name
98
Collections.sort(al, new EjbItemByNameComparator());
99                     // Set list in form
100
oForm.setListUsedByEjb(al);
101                 }
102             }
103         } catch (Throwable JavaDoc t) {
104             return (treatError(t, pMapping, pRequest));
105         }
106
107         // Forward to the jsp.
108
return (pMapping.findForward("JoramLocalQueue"));
109     }
110
111 }
112
Popular Tags