1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.container; 27 28 import java.io.IOException ; 29 import java.net.URL ; 30 import java.util.ArrayList ; 31 import java.util.Collections ; 32 import java.util.HashMap ; 33 import java.util.Iterator ; 34 35 import javax.management.ObjectName ; 36 import javax.servlet.ServletException ; 37 import javax.servlet.http.HttpServletRequest ; 38 import javax.servlet.http.HttpServletResponse ; 39 40 import org.apache.struts.action.ActionForm; 41 import org.apache.struts.action.ActionForward; 42 import org.apache.struts.action.ActionMapping; 43 import org.objectweb.jonas.jmx.J2eeObjectName; 44 import org.objectweb.jonas.jmx.JonasManagementRepr; 45 import org.objectweb.jonas.jmx.JonasObjectName; 46 import org.objectweb.jonas.webapp.jonasadmin.JettyObjectName; 47 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 48 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 49 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 50 51 54 55 public class ListWebContainersAction extends JonasBaseAction { 56 57 59 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 60 , HttpServletRequest p_Request, HttpServletResponse p_Response) 61 throws IOException , ServletException { 62 63 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR 65 + "services" + WhereAreYou.NODE_SEPARATOR + "web", true); 66 m_WhereAreYou.setCurrentJonasDeploymentType(WhereAreYou.DEPLOYMENT_WAR); 68 m_Session.removeAttribute("itemsWebContainersForm"); 70 71 try { 73 ArrayList al = new ArrayList (); 74 ObjectName on; 75 String sPathContext; 76 HashMap hWebAppItems = new HashMap (); 77 78 if (m_WhereAreYou.isCatalinaServer() == true) { 80 WebAppItem oItem; 81 String p_domainName = m_WhereAreYou.getCurrentDomainName(); 82 String p_serverName = m_WhereAreYou.getAdminJonasServerName(); 83 ObjectName onContainers = J2eeObjectName.getWebModules(p_domainName, p_serverName); 84 Iterator itOns = JonasAdminJmx.getListMbean(onContainers).iterator(); 85 while (itOns.hasNext()) { 86 ObjectName onWebModule = (ObjectName ) itOns.next(); 87 oItem = new WebAppItem(onWebModule); 88 String webModulePath = ((URL ) JonasManagementRepr.getAttribute(onWebModule, "warURL")).toString(); 89 String sFile = JonasAdminJmx.extractFilename(webModulePath); 90 oItem.setFile(sFile); 91 oItem.setPath(webModulePath); 92 hWebAppItems.put(oItem.getPathContext(), oItem); 93 } 94 } else if (m_WhereAreYou.isJettyServer()) { 95 Iterator itOnContexts = JonasAdminJmx.getListMbean(JettyObjectName.jettyContexts()). 97 iterator(); 98 while (itOnContexts.hasNext()) { 99 on = (ObjectName ) itOnContexts.next(); 100 sPathContext = on.getKeyProperty("context"); 101 if (sPathContext != null) { 102 if (!hWebAppItems.containsKey(sPathContext) && on.getKeyProperty("WebApplicationContext") != null && 103 on.getKeyProperty("WebApplicationHandler") == null && on.getKeyProperty("config") == null) { 104 hWebAppItems.put(sPathContext, new WebAppItem(sPathContext, on.toString())); 105 } 106 } 107 } 108 109 114 String sPath; 115 String sFile; 116 WebAppItem oWeb; 117 Iterator itOnWars = JonasAdminJmx.getListMbean(JonasObjectName.allWars()).iterator(); 118 while (itOnWars.hasNext()) { 119 on = (ObjectName ) itOnWars.next(); 120 sPath = on.getKeyProperty("fname"); 121 sFile = JonasAdminJmx.extractFilename(sPath); 122 sPathContext = getStringAttribute(on, "ContextRoot"); 123 if (sPathContext.charAt(0) != '/') { 124 sPathContext = "/" + sPathContext; 125 } 126 oWeb = (WebAppItem) hWebAppItems.get(sPathContext); 127 if (oWeb != null) { 128 oWeb.setFile(sFile); 129 oWeb.setPath(sPath); 130 } 131 } 132 } 133 134 al.addAll(hWebAppItems.values()); 136 Collections.sort(al, new WebAppItemByPathContext()); 137 138 p_Request.setAttribute("listWebContainers", al); 140 } catch (Throwable t) { 141 addGlobalError(t); 142 saveErrors(p_Request, m_Errors); 143 return (p_Mapping.findForward("Global Error")); 144 } 145 return (p_Mapping.findForward("Web Containers")); 147 } 148 } 149 | Popular Tags |