1 7 package org.ejtools.jmx.browser.web.action; 8 9 import java.io.IOException ; 10 import java.util.Locale ; 11 12 import javax.servlet.ServletContext ; 13 import javax.servlet.ServletException ; 14 import javax.servlet.http.HttpServletRequest ; 15 import javax.servlet.http.HttpServletResponse ; 16 17 import org.apache.log4j.Logger; 18 import org.apache.struts.action.Action; 19 import org.apache.struts.action.ActionError; 20 import org.apache.struts.action.ActionErrors; 21 import org.apache.struts.action.ActionForm; 22 import org.apache.struts.action.ActionForward; 23 import org.apache.struts.action.ActionMapping; 24 import org.apache.struts.util.MessageResources; 25 import org.ejtools.jmx.browser.model.Resource; 26 import org.ejtools.jmx.browser.web.Constants; 27 import org.ejtools.jmx.browser.web.JMXContainer; 28 29 37 public class DetailAction extends Action 38 { 39 40 private static Logger logger = Logger.getLogger(DetailAction.class); 41 42 43 44 public DetailAction() { } 45 46 47 58 public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 59 throws IOException , ServletException 60 { 61 String reference = null; 62 63 Locale locale = getLocale(request); 65 MessageResources messages = getResources(); 66 67 ActionErrors errors = new ActionErrors(); 69 70 reference = request.getParameter("reference"); 71 logger.debug("ObjectName requested " + reference); 72 73 ServletContext context = this.getServlet().getServletContext(); 74 JMXContainer tree = (JMXContainer) context.getAttribute(Constants.TREE); 75 76 if (tree != null) 77 { 78 logger.debug("Tree root found => " + tree); 79 Resource res = (Resource) tree.searchObjectName(reference,true); 81 82 if (res != null) 83 { 84 context.setAttribute(Constants.DETAIL, res); 85 logger.debug("MBean found => " + res); 86 context.setAttribute(Constants.DETAIL_INFO, res.getMBeanInfo()); 87 logger.debug("MBeanInfo found => " + res.getMBeanInfo()); 88 } 89 else 90 { 91 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("web.error.no.mbean")); 92 } 93 } 94 else 95 { 96 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("web.error.cannot.connect")); 97 } 98 99 if (!errors.empty()) 101 { 102 saveErrors(request, errors); 103 return (mapping.findForward("error")); 104 } 105 106 return (mapping.findForward("detail")); 107 } 108 } 109 110 | Popular Tags |