KickJava   Java API By Example, From Geeks To Geeks.

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


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

12
13 package org.ejtools.jmx.browser.web.action;
14
15
16
17 import java.io.IOException JavaDoc;
18
19 import java.util.Locale JavaDoc;
20
21
22
23 import javax.servlet.ServletContext JavaDoc;
24
25 import javax.servlet.ServletException JavaDoc;
26
27 import javax.servlet.http.HttpServletRequest JavaDoc;
28
29 import javax.servlet.http.HttpServletResponse JavaDoc;
30
31
32
33 import org.apache.log4j.Logger;
34
35 import org.apache.struts.action.Action;
36
37 import org.apache.struts.action.ActionErrors;
38
39 import org.apache.struts.action.ActionForm;
40
41 import org.apache.struts.action.ActionForward;
42
43 import org.apache.struts.action.ActionMapping;
44
45 import org.apache.struts.util.MessageResources;
46
47 import org.ejtools.jmx.browser.web.Constants;
48
49 import org.ejtools.jmx.browser.web.JMXContainer;
50
51
52
53 /**
54
55  * Description of the Class
56
57  *
58
59  * @author letiemble
60
61  * @created 12 novembre 2001
62
63  * @version $Revision: 1.6 $
64
65  * @todo Javadoc to complete
66
67  */

68
69 public class RefreshAction extends Action
70
71 {
72
73    /** Description of the Field */
74
75    private static Logger logger = Logger.getLogger(RefreshAction.class);
76
77
78
79
80
81    /** Constructor for the FilterAction object */
82
83    public RefreshAction() { }
84
85
86
87
88
89    /**
90
91     * Description of the Method
92
93     *
94
95     * @param mapping Description of the Parameter
96
97     * @param form Description of the Parameter
98
99     * @param request Description of the Parameter
100
101     * @param response Description of the Parameter
102
103     * @return Description of the Return Value
104
105     * @exception IOException Description of the Exception
106
107     * @exception ServletException Description of the Exception
108
109     */

110
111    public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
112
113       throws IOException JavaDoc, ServletException JavaDoc
114
115    {
116
117       JMXContainer tree = null;
118
119
120
121       // Extract attributes we will need
122

123       Locale JavaDoc locale = getLocale(request);
124
125       MessageResources messages = getResources();
126
127
128
129       // Validate the request parameters specified by the user
130

131       ActionErrors errors = new ActionErrors();
132
133
134
135       logger.debug("Connecting to JMX Server");
136
137
138
139       ServletContext JavaDoc context = this.getServlet().getServletContext();
140
141       tree = (JMXContainer) context.getAttribute(Constants.TREE);
142
143
144
145       if (tree == null)
146
147       {
148
149          tree = new JMXContainer();
150
151          context.setAttribute(Constants.TREE, tree);
152
153       }
154
155
156
157       tree.refresh();
158
159
160
161       // Report any errors we have discovered back to the original form
162

163       if (!errors.empty())
164
165       {
166
167          saveErrors(request, errors);
168
169          return (mapping.findForward("home"));
170
171       }
172
173
174
175       return (mapping.findForward("view"));
176
177    }
178
179 }
180
181
182
183
Popular Tags