ListJmsResourcesAction.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * Initial developer(s): Michel-Ange ANTON
00022  * --------------------------------------------------------------------------
00023  * $Id: ListJmsResourcesAction.java,v 1.2 2004/03/19 14:31:47 sauthieg Exp $
00024  * --------------------------------------------------------------------------
00025  */
00026 
00027 package org.objectweb.jonas.webapp.jonasadmin.resource;
00028 
00029 import java.io.IOException;
00030 import java.util.ArrayList;
00031 import java.util.Collections;
00032 import java.util.Set;
00033 
00034 import javax.management.ObjectName;
00035 import javax.servlet.ServletException;
00036 import javax.servlet.http.HttpServletRequest;
00037 import javax.servlet.http.HttpServletResponse;
00038 
00039 import org.apache.struts.action.ActionForm;
00040 import org.apache.struts.action.ActionForward;
00041 import org.apache.struts.action.ActionMapping;
00042 import org.objectweb.jonas.jmx.JonasManagementRepr;
00043 import org.objectweb.jonas.jmx.JonasObjectName;
00044 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
00045 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
00046 
00051 public class ListJmsResourcesAction extends JonasBaseAction {
00052 
00053 // --------------------------------------------------------- Public Methods
00054 
00057     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00058         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00059         throws IOException, ServletException {
00060 
00061         try {
00062             String asDestName = null;
00063 
00064             // Prepare access to ejbContainer service in order to chech dependences
00065             ObjectName ejbServiceMB = JonasObjectName.ejbService();
00066             boolean registeredEjbService = JonasManagementRepr.isRegistered(ejbServiceMB);
00067 
00068             // Get queues
00069             ArrayList alQueues = new ArrayList();
00070             ArrayList al = JonasAdminJmx.getQueuesList();
00071             if (al != null) {
00072                 for (int i = 0; i < al.size(); i++) {
00073                     asDestName = al.get(i).toString();
00074                     boolean deps = false;
00075                     // Chech dependences
00076                     if (registeredEjbService) {
00077                         deps = hasDeps(asDestName, ejbServiceMB);
00078                     }
00079                     alQueues.add(new DestinationItem(asDestName, "queue", deps));
00080                 }
00081                 Collections.sort(alQueues, new DestinationItemByNameComparator());
00082             }
00083             // Get topics
00084             ArrayList alTopics = new ArrayList();
00085             al = JonasAdminJmx.getTopicsList();
00086             if (al != null) {
00087                 for (int i = 0; i < al.size(); i++) {
00088                     asDestName = al.get(i).toString();
00089                     boolean deps = false;
00090                     // Chech dependences
00091                     if (registeredEjbService) {
00092                         deps = hasDeps(asDestName, ejbServiceMB);
00093                     }
00094                     alTopics.add(new DestinationItem(al.get(i).toString(), "topic", deps));
00095                 }
00096                 Collections.sort(alTopics, new DestinationItemByNameComparator());
00097             }
00098 
00099             // merge alQueues and alTopics in alDestinations
00100             ArrayList alDestinations = new ArrayList(alQueues);
00101             alDestinations.addAll(alTopics);
00102 
00103             p_Request.setAttribute("destinationsList", alDestinations);
00104         } catch (Throwable t) {
00105             addGlobalError(t);
00106             saveErrors(p_Request, m_Errors);
00107             return (p_Mapping.findForward("Global Error"));
00108         }   
00109 
00110         // Forward to the jsp.
00111         return (p_Mapping.findForward("Jms Resources"));
00112     }
00113 
00114     private boolean hasDeps(String destName, ObjectName ejbServiceMB) {
00115         String[] asParam = { destName };
00116         String[] asSignature = { "java.lang.String" };
00117         Set deps = (java.util.Set) JonasManagementRepr.invoke(ejbServiceMB, "getJmsDestinationDependence", asParam, asSignature);
00118         boolean res =  deps.size() > 0 ? true : false; 
00119         return res;
00120     }
00121 }

Generated on Tue Feb 15 15:05:30 2005 for JOnAS by  doxygen 1.3.9.1