KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > web > action > DetailAction


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.jmx.browser.web.action;
8
9 import java.io.IOException JavaDoc;
10 import java.util.Locale JavaDoc;
11
12 import javax.servlet.ServletContext JavaDoc;
13 import javax.servlet.ServletException JavaDoc;
14 import javax.servlet.http.HttpServletRequest JavaDoc;
15 import javax.servlet.http.HttpServletResponse JavaDoc;
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 /**
30  * Description of the Class
31  *
32  * @author letiemble
33  * @created 12 novembre 2001
34  * @version $Revision: 1.6 $
35  * @todo Javadoc to complete
36  */

37 public class DetailAction extends Action
38 {
39    /** Description of the Field */
40    private static Logger logger = Logger.getLogger(DetailAction.class);
41
42
43    /** Constructor for the SearchLoginAction object */
44    public DetailAction() { }
45
46
47    /**
48     * Description of the Method
49     *
50     * @param mapping Description of the Parameter
51     * @param form Description of the Parameter
52     * @param request Description of the Parameter
53     * @param response Description of the Parameter
54     * @return Description of the Return Value
55     * @exception IOException Description of the Exception
56     * @exception ServletException Description of the Exception
57     */

58    public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
59       throws IOException JavaDoc, ServletException JavaDoc
60    {
61       String JavaDoc reference = null;
62
63       // Extract attributes we will need
64
Locale JavaDoc locale = getLocale(request);
65       MessageResources messages = getResources();
66
67       // Validate the request parameters specified by the user
68
ActionErrors errors = new ActionErrors();
69
70       reference = request.getParameter("reference");
71       logger.debug("ObjectName requested " + reference);
72
73       ServletContext JavaDoc 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          //Slobodan Vujsinovic 2005.06.27.
80
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       // Report any errors we have discovered back to the original form
100
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