1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.ejb; 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.JonasManagementRepr; 39 import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction; 40 41 44 45 public class ExecuteEjbAction extends JonasBaseAction { 46 47 49 protected String mAction = null; 50 protected String mForward = null; 51 52 54 65 public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm 66 , HttpServletRequest pRequest, HttpServletResponse pResponse) 67 throws IOException , ServletException { 68 69 mAction = pRequest.getParameter("action"); 71 EjbForm oForm = (EjbForm) m_Session.getAttribute("ejbForm"); 73 76 try { 77 executeEjb(oForm); 79 } catch (Throwable t) { 80 addGlobalError(t); 81 saveErrors(pRequest, m_Errors); 82 return (pMapping.findForward("Global Error")); 83 } 84 85 pRequest.setAttribute("select", oForm.getObjectName()); 87 return (pMapping.findForward(mForward)); 88 } 89 90 92 98 protected void executeEjb(EjbForm pForm) 99 throws Exception { 100 String sObjectName = pForm.getObjectName(); 102 ObjectName on = new ObjectName (sObjectName); 103 String mType = pForm.getType(); if (mType.equals("EntityBean")) { 105 mForward = "ActionEditEjbEntity"; 107 EjbEntityForm eForm = (EjbEntityForm) pForm; 108 String mPersistency = eForm.getPersistency(); 109 if (mPersistency.startsWith("Cont")) { 110 if ("synchronize".equals(mAction)) { 111 JonasManagementRepr.invoke(on, "synchronize", null, null); 112 } else if ("reduceCache".equals(mAction)) { 113 JonasManagementRepr.invoke(on, "reduceCache", null, null); 114 } 115 } 116 } else if (mType.equals("StatelessSessionBean")) { 117 mForward = "ActionEditEjbSbl"; 118 if ("reducePool".equals(mAction)) { 119 JonasManagementRepr.invoke(on, "reducePoolToMinSize", null, null); 120 } 121 } 122 } 123 124 } 125 | Popular Tags |