1 25 26 package org.objectweb.jonas.webapp.jonasadmin.jonasserver; 27 28 import java.io.IOException ; 29 30 import javax.management.ObjectName ; 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 import org.objectweb.jonas.jmx.J2eeObjectName; 39 import org.objectweb.jonas.jmx.JonasObjectName; 40 import org.objectweb.jonas.jmx.ManagementReprLoader; 41 import org.objectweb.jonas.jmx.JonasManagementRepr; 42 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 43 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 44 45 48 49 public class EditJonasServerAction extends JonasBaseAction { 50 51 64 public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm 65 , HttpServletRequest pRequest, HttpServletResponse pResponse) 66 throws IOException , ServletException { 67 68 String requestedObjectName = (String ) pRequest.getParameter("select"); 69 boolean changeManagement = false; 70 try { 71 ObjectName on = ObjectName.getInstance(requestedObjectName); 72 String requestedJonasServerName = on.getKeyProperty("name"); 73 String currentJonasServerName = m_WhereAreYou.getCurrentJonasServerName(); 74 if (!currentJonasServerName.equals(requestedJonasServerName)) { 75 ManagementReprLoader.loadServerRepr(requestedJonasServerName); 77 m_WhereAreYou.refreshServers(pRequest); 79 if (m_WhereAreYou.getCurrentJonasServerName().equals(requestedJonasServerName)) { 80 changeManagement = true; 81 } else { 82 addGlobalError(new Error ("Can't switch management context to server " + requestedJonasServerName)); 83 saveErrors(pRequest, m_Errors); 84 return (pMapping.findForward("Global Error")); 85 } 86 } 87 88 if (changeManagement) { 89 refreshServerTree(pRequest); 90 } 91 92 m_WhereAreYou.selectNameNode("domain" 94 + WhereAreYou.NODE_SEPARATOR 95 + requestedJonasServerName, true); 96 97 JonasServerForm oForm = (JonasServerForm) pForm; 99 ObjectName oObjectName = J2eeObjectName.J2EEServer(m_WhereAreYou.getCurrentDomainName() 102 , m_WhereAreYou.getCurrentJonasServerName()); 103 oForm.setJonasName(m_WhereAreYou.getCurrentJonasServerName()); 104 oForm.setJonasVersion(getStringAttribute(oObjectName, "serverVersion")); 105 oForm.setProtocols(getStringAttribute(oObjectName, "protocols")); 106 if (JonasManagementRepr.isRegistered(JonasObjectName.webContainerService())) { 107 oForm.setPresentServletContainer(true); 108 if (m_WhereAreYou.isCatalinaServer()) { 109 oForm.setServerServletContainerInfo("Apache Tomcat"); 110 } 112 } else { 113 oForm.setPresentServletContainer(false); 114 } 115 } catch (Throwable t) { 116 addGlobalError(t); 117 saveErrors(pRequest, m_Errors); 118 return (pMapping.findForward("Global Error")); 119 } 120 return (pMapping.findForward("JonasServer")); 122 } 123 124 } 125 | Popular Tags |