KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > jonasserver > ListRegistryAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-2004 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  * $Id: ListRegistryAction.java,v 1.11 2005/04/20 11:58:42 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.jonasserver;
27
28 import java.io.IOException JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 import javax.management.ObjectName JavaDoc;
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.http.HttpServletRequest JavaDoc;
35 import javax.servlet.http.HttpServletResponse JavaDoc;
36
37 import org.apache.struts.action.ActionForm;
38 import org.apache.struts.action.ActionForward;
39 import org.apache.struts.action.ActionMapping;
40 import org.objectweb.jonas.jmx.J2eeObjectName;
41 import org.objectweb.jonas.jmx.JonasManagementRepr;
42 import org.objectweb.jonas.jmx.JonasObjectName;
43 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
44
45 /**
46  * @author Adriana Danes <br>
47  * Contributor Michel-Ange Anton
48  */

49 public class ListRegistryAction extends JonasBaseAction {
50     /**
51      * Execute action for registry management
52      * @param pMapping mapping info
53      * @param pForm form object
54      * @param pRequest HTTP request
55      * @param pResponse HTTP response
56      *
57      * @return An <code>ActionForward</code> instance or <code>null</code>
58      *
59      * @exception IOException if an input/output error occurs
60      * @exception ServletException if a servlet exception occurs
61      */

62     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
63         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
64         throws IOException JavaDoc, ServletException JavaDoc {
65
66         // Force the node selected in tree
67
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER), true);
68         // Form used
69
JndiResourcesForm oForm = new JndiResourcesForm();
70
71         try {
72             String JavaDoc pDomainName = m_WhereAreYou.getCurrentDomainName();
73             String JavaDoc pServerName = m_WhereAreYou.getCurrentJonasServerName();
74             ObjectName JavaDoc ons = J2eeObjectName.JNDIResources(pDomainName, pServerName);
75             Iterator JavaDoc itNames = JonasManagementRepr.queryNames(ons).iterator();
76             List JavaDoc lNames = null;
77             int nbJNDIResources = 0;
78             while (itNames.hasNext()) {
79                 JndiResourceItem item = new JndiResourceItem();
80                 ObjectName JavaDoc itOn = (ObjectName JavaDoc) itNames.next();
81                 item.setProviderUrl(getStringAttribute(itOn, "ProviderURL"));
82                 item.setProtocol(getStringAttribute(itOn, "Name"));
83                 item.setResourceON(itOn.toString());
84                 lNames = getListAttribute(itOn, "Names");
85                 oForm.addProvider(item);
86                 nbJNDIResources++;
87             }
88             if (nbJNDIResources == 1) {
89                 oForm.setListNames(lNames);
90             }
91             if (JonasManagementRepr.isRegistered(JonasObjectName.webContainerService())) {
92                 oForm.setPresentServletContainer(true);
93             } else {
94                 oForm.setPresentServletContainer(false);
95             }
96             pRequest.setAttribute("jndiResourcesForm", oForm);
97         } catch (Throwable JavaDoc t) {
98             addGlobalError(t);
99             saveErrors(pRequest, m_Errors);
100             return (pMapping.findForward("Global Error"));
101         }
102         // Forward to the jsp.
103
return (pMapping.findForward("Registry"));
104     }
105 }
106
Popular Tags