1 26 27 package org.objectweb.jonas.webapp.jonasadmin.resource; 28 29 import java.io.IOException ; 30 import java.util.ArrayList ; 31 import java.util.Collections ; 32 import java.util.Set ; 33 34 import javax.management.ObjectName ; 35 import javax.servlet.ServletException ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 39 import org.apache.struts.action.ActionForm; 40 import org.apache.struts.action.ActionForward; 41 import org.apache.struts.action.ActionMapping; 42 import org.objectweb.jonas.jmx.JonasManagementRepr; 43 import org.objectweb.jonas.jmx.JonasObjectName; 44 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 45 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 46 47 50 51 public class ListJmsResourcesAction extends JonasBaseAction { 52 53 55 57 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 58 , HttpServletRequest p_Request, HttpServletResponse p_Response) 59 throws IOException , ServletException { 60 61 try { 62 String asDestName = null; 63 64 ObjectName ejbServiceMB = JonasObjectName.ejbService(); 66 boolean registeredEjbService = JonasManagementRepr.isRegistered(ejbServiceMB); 67 68 ArrayList alQueues = new ArrayList (); 70 ArrayList al = JonasAdminJmx.getQueuesList(); 71 if (al != null) { 72 for (int i = 0; i < al.size(); i++) { 73 asDestName = al.get(i).toString(); 74 boolean deps = false; 75 if (registeredEjbService) { 77 deps = hasDeps(asDestName, ejbServiceMB); 78 } 79 alQueues.add(new DestinationItem(asDestName, "queue", deps)); 80 } 81 Collections.sort(alQueues, new DestinationItemByNameComparator()); 82 } 83 ArrayList alTopics = new ArrayList (); 85 al = JonasAdminJmx.getTopicsList(); 86 if (al != null) { 87 for (int i = 0; i < al.size(); i++) { 88 asDestName = al.get(i).toString(); 89 boolean deps = false; 90 if (registeredEjbService) { 92 deps = hasDeps(asDestName, ejbServiceMB); 93 } 94 alTopics.add(new DestinationItem(al.get(i).toString(), "topic", deps)); 95 } 96 Collections.sort(alTopics, new DestinationItemByNameComparator()); 97 } 98 99 ArrayList alDestinations = new ArrayList (alQueues); 101 alDestinations.addAll(alTopics); 102 103 p_Request.setAttribute("destinationsList", alDestinations); 104 } catch (Throwable t) { 105 addGlobalError(t); 106 saveErrors(p_Request, m_Errors); 107 return (p_Mapping.findForward("Global Error")); 108 } 109 110 return (p_Mapping.findForward("Jms Resources")); 112 } 113 114 private boolean hasDeps(String destName, ObjectName ejbServiceMB) { 115 String [] asParam = { destName }; 116 String [] asSignature = { "java.lang.String" }; 117 Set deps = (java.util.Set ) JonasManagementRepr.invoke(ejbServiceMB, "getJmsDestinationDependence", asParam, asSignature); 118 boolean res = deps.size() > 0 ? true : false; 119 return res; 120 } 121 } 122 | Popular Tags |