ListLocalDestinationsAction.java

00001 
00022 package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
00023 
00024 import java.io.IOException;
00025 import java.util.ArrayList;
00026 import java.util.Set;
00027 import java.util.Vector;
00028 
00029 import javax.management.ObjectName;
00030 import javax.servlet.ServletException;
00031 import javax.servlet.http.HttpServletRequest;
00032 import javax.servlet.http.HttpServletResponse;
00033 
00034 import org.apache.struts.action.ActionForm;
00035 import org.apache.struts.action.ActionForward;
00036 import org.apache.struts.action.ActionMapping;
00037 
00038 import org.objectweb.jonas.jmx.JonasManagementRepr;
00039 import org.objectweb.jonas.jmx.JonasObjectName;
00040 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00041 
00046 public class ListLocalDestinationsAction extends EditJoramBaseAction {
00047 
00048     ObjectName ejbServiceObjectName = null;
00049     String[] asParam = null;
00050     String[] asSignature = null;
00051     
00052     // --------------------------------------------------------- Public Methods
00053     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
00054         , HttpServletRequest pRequest, HttpServletResponse pResponse)
00055         throws IOException, ServletException {
00056 
00057         // Force the node selected in tree
00058         m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR
00059                 + "joramplatform" + WhereAreYou.NODE_SEPARATOR
00060                 + "joramlocalserver", true);
00061         
00062         // Get reference on EJB container service in order to determine dependencies 
00063         // between the deployed EJBs and JMS destinations
00064         initRefs();
00065         
00066         // Get all destinations
00067         String asDestName = null;
00068         try {
00069             // Object name used for JmslocalServer MBean
00070             ObjectName oObjectName = JonasObjectName.joramLocalServer();
00071             ArrayList alQueues = new ArrayList();
00072             // get queues
00073             Vector v = (Vector) getListAttribute(oObjectName, "LocalQueuesNames");
00074             if (v != null) {
00075                 for (int i = 0; i < v.size(); i++) {
00076                     asDestName = (String) v.get(i);
00077                     boolean deps = hasDeps(asDestName);
00078                     alQueues.add(new DestinationItem(asDestName, "queue", deps));
00079                 }
00080             }
00081             // get topicss
00082             v = (Vector) getListAttribute(oObjectName, "LocalTopicsNames");
00083             ArrayList alTopics = new ArrayList();
00084             if (v != null) {
00085                 for (int i = 0; i < v.size(); i++) {
00086                     asDestName = (String) v.get(i);
00087                     boolean deps = hasDeps(asDestName);
00088                     alTopics.add(new DestinationItem(asDestName, "topic", deps));
00089                 }
00090             }
00091 
00092             // merge alQueues and alTopics in alDestinations
00093             ArrayList alDestinations = new ArrayList(alQueues);
00094             alDestinations.addAll(alTopics);
00095 
00096             pRequest.setAttribute("destinationsList", alDestinations);
00097         } catch (Throwable t) {
00098             return (treatError(t, pMapping, pRequest));
00099         }
00100 
00101         // Forward to the jsp.
00102         return (pMapping.findForward("Joram Destinations"));
00103     }
00104 
00105     private void initRefs() {
00106         asParam = new String[1];
00107         asSignature = new String[1];
00108         asSignature[0] = "java.lang.String";
00109         ejbServiceObjectName = JonasObjectName.ejbService();
00110         if (!JonasManagementRepr.isRegistered(ejbServiceObjectName)) {
00111             ejbServiceObjectName = null;
00112         }
00113     }
00114     
00115     private boolean hasDeps(String pDestName) {
00116         boolean ret = false;
00117         if (ejbServiceObjectName != null) {
00118             asParam[0] = pDestName;
00119             Set deps = (Set) JonasManagementRepr.invoke(
00120                     ejbServiceObjectName, "getJmsDestinationDependence",
00121                     asParam, asSignature);
00122             if (!deps.isEmpty()) {
00123                 ret = true;
00124             }
00125         }
00126         return ret;
00127     }
00128 }

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