1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.container; 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.ActionMessage; 36 import org.apache.struts.action.ActionForm; 37 import org.apache.struts.action.ActionForward; 38 import org.apache.struts.action.ActionMapping; 39 import org.objectweb.jonas.jmx.JonasManagementRepr; 40 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminException; 41 42 45 public class ApplyWebAppJettyAction extends BaseWebAppAction { 46 47 private static String sDefaultForward = "ActionEditWebAppJetty"; 48 49 51 53 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 54 , HttpServletRequest p_Request, HttpServletResponse p_Response) 55 throws IOException , ServletException { 56 57 ActionForward oForward = null; 59 60 WebAppJettyForm oForm = (WebAppJettyForm) p_Form; 62 63 try { 65 if ("stop".equals(oForm.getAction())) { 67 oForward = stopWebApplication(oForm, p_Mapping); 68 } 69 else if ("start".equals(oForm.getAction())) { 71 oForward = startWebApplication(oForm, p_Mapping); 72 } 73 } catch (JonasAdminException e) { 74 m_Errors.add("webapp", new ActionMessage(e.getId())); 76 saveErrors(p_Request, m_Errors); 77 oForward = new ActionForward(p_Mapping.getInput()); 79 } catch (Throwable t) { 80 addGlobalError(t); 81 saveErrors(p_Request, m_Errors); 82 oForward = p_Mapping.findForward("Global Error"); 83 } 84 85 return oForward; 87 } 88 89 90 92 99 protected ActionForward startWebApplication(WebAppJettyForm p_Form, ActionMapping p_Mapping) 100 throws Exception { 101 try { 102 ObjectName onContext = new ObjectName (p_Form.getObjectName()); 103 JonasManagementRepr.invoke(onContext, "start", null, null); 104 } catch (Throwable t) { 105 throw new JonasAdminException("error.webapp.start"); 106 } 107 return p_Mapping.findForward(sDefaultForward); 108 } 109 110 117 protected ActionForward stopWebApplication(WebAppJettyForm p_Form, ActionMapping p_Mapping) 118 throws Exception { 119 try { 120 ObjectName onContext = new ObjectName (p_Form.getObjectName()); 121 JonasManagementRepr.invoke(onContext, "stop", null, null); 122 } catch (Throwable t) { 123 throw new JonasAdminException("error.webapp.stop"); 124 } 125 return p_Mapping.findForward(sDefaultForward); 126 } 127 } 128 | Popular Tags |