KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > monitoring > MemoryForm


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer(s): Michel-Ange ANTON
22  * --------------------------------------------------------------------------
23  * $Id: MemoryForm.java,v 1.4 2005/04/21 08:59:54 kemlerp Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.webapp.jonasadmin.monitoring;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30
31 import org.apache.struts.action.ActionMessage;
32 import org.apache.struts.action.ActionErrors;
33 import org.apache.struts.action.ActionForm;
34 import org.apache.struts.action.ActionMapping;
35
36 public class MemoryForm extends ActionForm {
37
38 // --------------------------------------------------------- Properties Variables
39

40     private int numberOfMeasures = 120;
41     private int range = 10;
42     private int widthGraphic;
43     private int heightGraphic;
44     private int timerGraphic;
45
46 // --------------------------------------------------------- Public Methods
47

48     /**
49      * Reset all properties to their default values.
50      *
51      * @param mapping The mapping used to select this instance
52      * @param request The servlet request we are processing
53      */

54
55     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
56         numberOfMeasures = 120;
57         range = 10;
58         refreshGraphic();
59     }
60
61     public void refreshGraphic() {
62         widthGraphic = MemoryGraphServlet.getWidth(numberOfMeasures);
63         heightGraphic = MemoryGraphServlet.getHeight();
64         timerGraphic = 1000 * (range + 2);
65     }
66
67     /**
68      * Validate the properties that have been set from this HTTP request,
69      * and return an <code>ActionErrors</code> object that encapsulates any
70      * validation errors that have been found. If no errors are found, return
71      * <code>null</code> or an <code>ActionErrors</code> object with no
72      * recorded error messages.
73      *
74      * @param mapping The mapping used to select this instance
75      * @param request The servlet request we are processing
76      */

77     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
78         ActionErrors oErrors = new ActionErrors();
79         if (numberOfMeasures <= 1) {
80             oErrors.add("numberOfMeasures"
81                 , new ActionMessage("error.monitoring.memory.numberOfMeasures"));
82         }
83         if (range < 10) {
84             oErrors.add("range", new ActionMessage("error.monitoring.memory.range"));
85         }
86         //System.out.println("oErrors.size() = "+oErrors.size());
87
if (oErrors.size() == 0) {
88             //System.out.println("sizingGraphic");
89
refreshGraphic();
90         }
91         return oErrors;
92     }
93
94 // --------------------------------------------------------- Properties Methods
95

96     public int getNumberOfMeasures() {
97         return numberOfMeasures;
98     }
99
100     public void setNumberOfMeasures(int numberOfMeasures) {
101         this.numberOfMeasures = numberOfMeasures;
102     }
103
104     public int getRange() {
105         return range;
106     }
107
108     public void setRange(int range) {
109         this.range = range;
110     }
111
112     public int getWidthGraphic() {
113         return widthGraphic;
114     }
115
116     public void setWidthGraphic(int widthGraphic) {
117         this.widthGraphic = widthGraphic;
118     }
119
120     public int getHeightGraphic() {
121         return heightGraphic;
122     }
123
124     public void setHeightGraphic(int heightGraphic) {
125         this.heightGraphic = heightGraphic;
126     }
127
128     public int getTimerGraphic() {
129         return timerGraphic;
130     }
131
132     public void setTimerGraphic(int timerGraphic) {
133         this.timerGraphic = timerGraphic;
134     }
135
136 }
Popular Tags