1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.container; 27 28 import java.io.IOException ; 29 import java.util.ArrayList ; 30 import java.util.Collections ; 31 import java.util.Iterator ; 32 33 import javax.management.MalformedObjectNameException ; 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.J2eeObjectName; 43 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 44 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 45 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 46 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem; 47 import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator; 48 49 52 53 public class EditContainerAction extends JonasBaseAction { 54 55 57 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 58 , HttpServletRequest p_Request, HttpServletResponse p_Response) 59 throws IOException , ServletException { 60 String sObjectName = p_Request.getParameter("select"); 62 if (sObjectName == null) { 63 sObjectName = (String ) p_Request.getAttribute("select"); 65 } 66 String sNextForward = (String ) p_Request.getAttribute("NextForward"); 68 69 ObjectName oObjectName = null; 71 try { 72 if (sNextForward != null) { 73 oObjectName = getModuleObjectName(sObjectName); 74 } else { 75 oObjectName = new ObjectName (sObjectName); 76 } 77 } catch (Throwable t) { 78 addGlobalError(t); 79 saveErrors(p_Request, m_Errors); 80 return (p_Mapping.findForward("Global Error")); 81 } 82 83 ContainerForm oForm = null; 85 String sPath = null; 86 if (oObjectName != null) { 88 oForm = new ContainerForm(); 89 oForm.reset(p_Mapping, p_Request); 90 m_Session.setAttribute("containerForm", oForm); 91 sPath = getStringAttribute(oObjectName, "fileName"); 92 93 oForm.setPath(sPath); 94 oForm.setFilename(JonasAdminJmx.extractFilename(sPath)); 95 } 96 else { 97 oForm = (ContainerForm) m_Session.getAttribute("containerForm"); 99 } 100 101 if (sNextForward == null) { 103 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER) 104 + WhereAreYou.NODE_SEPARATOR + "services" + WhereAreYou.NODE_SEPARATOR 105 + "ejbContainers" + WhereAreYou.NODE_SEPARATOR + oForm.getFilename(), true); 106 } 107 108 if (oObjectName != null) { 110 try { 111 oForm.setContainerName(getStringAttribute(oObjectName, "containerName")); 112 oForm.setCurrentNumberOfMDBType(getIntegerAttribute(oObjectName 113 , "currentNumberOfMDB")); 114 oForm.setCurrentNumberOfSBFType(getIntegerAttribute(oObjectName 115 , "currentNumberOfSBF")); 116 oForm.setCurrentNumberOfBMPType(getIntegerAttribute(oObjectName 117 , "currentNumberOfBMP")); 118 oForm.setCurrentNumberOfSBLType(getIntegerAttribute(oObjectName 119 , "currentNumberOfSBL")); 120 oForm.setCurrentNumberOfCMPType(getIntegerAttribute(oObjectName 121 , "currentNumberOfCMP")); 122 oForm.setCurrentNumberOfBeanType(getIntegerAttribute(oObjectName 123 , "currentNumberOfEJB")); 124 searchEjbs(oForm, sPath, oObjectName); 126 } 127 catch (Throwable t) { 128 addGlobalError(t); 129 saveErrors(p_Request, m_Errors); 130 return (p_Mapping.findForward("Global Error")); 131 } 132 } 133 134 if (sNextForward == null) { 136 sNextForward = "Container"; 137 } 138 return (p_Mapping.findForward(sNextForward)); 140 } 141 142 protected void searchEjbs(ContainerForm p_Form, String p_Path, ObjectName p_ObjectName) 143 throws Exception { 144 String sName; 145 String sTypeResource; 146 Iterator itNames; 147 ArrayList al = new ArrayList (); 148 String p_DomainName = p_ObjectName.getDomain(); 149 String p_ServerName = p_ObjectName.getKeyProperty("J2EEServer"); 150 String p_moduleName = p_ObjectName.getKeyProperty("name"); 151 152 ObjectName on = J2eeObjectName.getEntityBeans(p_DomainName, p_moduleName, p_ServerName); 153 itNames = JonasAdminJmx.getListMbean(on).iterator(); 154 while (itNames.hasNext()) { 155 al.add(new EjbItem((ObjectName ) itNames.next())); 156 } 157 on = J2eeObjectName.getStatefulSessionBeans(p_DomainName, p_moduleName, p_ServerName); 158 itNames = JonasAdminJmx.getListMbean(on).iterator(); 159 while (itNames.hasNext()) { 160 al.add(new EjbItem((ObjectName ) itNames.next())); 161 } 162 on = J2eeObjectName.getStatelessSessionBeans(p_DomainName, p_moduleName, p_ServerName); 163 itNames = JonasAdminJmx.getListMbean(on).iterator(); 164 while (itNames.hasNext()) { 165 al.add(new EjbItem((ObjectName ) itNames.next())); 166 } 167 on = J2eeObjectName.getMessageDrivenBeans(p_DomainName, p_moduleName, p_ServerName); 168 itNames = JonasAdminJmx.getListMbean(on).iterator(); 169 while (itNames.hasNext()) { 170 al.add(new EjbItem((ObjectName ) itNames.next())); 171 } 172 173 Collections.sort(al, new EjbItemByNameComparator()); 175 p_Form.setEjbs(al); 177 } 178 179 ObjectName getModuleObjectName(String ejbObjectName) throws MalformedObjectNameException { 180 ObjectName o_ejbObjectName = new ObjectName (ejbObjectName); 181 String domainName = o_ejbObjectName.getDomain(); 182 String moduleName = o_ejbObjectName.getKeyProperty("EJBModule"); 183 String serverName = o_ejbObjectName.getKeyProperty("J2EEServer"); 184 String appName = o_ejbObjectName.getKeyProperty("J2EEApplication"); 185 return J2eeObjectName.getEJBModule(domainName, serverName, appName, moduleName); 186 } 187 } 188 | Popular Tags |