KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > resource > DatasourcePropertiesForm


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  * --------------------------------------------------------------------------
22  * $Id: DatasourcePropertiesForm.java,v 1.10 2005/04/21 08:59:54 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.resource;
27
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29
30 import org.apache.struts.action.ActionMessage;
31 import org.apache.struts.action.ActionErrors;
32 import org.apache.struts.action.ActionForm;
33 import org.apache.struts.action.ActionMapping;
34 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
35
36 /**
37  * @author Michel-Ange Anton
38  */

39 public class DatasourcePropertiesForm extends ActionForm {
40
41 // --------------------------------------------------------- Constants
42

43 // --------------------------------------------------------- Properties variables
44

45     private String JavaDoc name = null;
46     private String JavaDoc datasourceName = null;
47     private String JavaDoc datasourceDescription = null;
48     private String JavaDoc datasourceUrl = null;
49     private String JavaDoc datasourceClassname = null;
50     private String JavaDoc datasourceUsername = null;
51     private String JavaDoc datasourcePassword = null;
52     private String JavaDoc datasourceMapper = null;
53     private String JavaDoc jdbcConnteststmt = null;
54     private String JavaDoc jdbcConnchecklevel = null;
55     private String JavaDoc jdbcConnmaxage = null;
56     private String JavaDoc jdbcMaxopentime = null;
57     private String JavaDoc jdbcMaxconpool = null;
58     private String JavaDoc jdbcMinconpool = null;
59     private String JavaDoc jdbcMaxwaittime = null;
60     private String JavaDoc jdbcMaxwaiters = null;
61     private String JavaDoc jdbcSamplingperiod = null;
62
63     private java.util.List JavaDoc booleanValues = Jlists.getBooleanValues();
64     private java.util.List JavaDoc checkingLevels = Jlists.getJdbcConnectionCheckingLevels();
65     private String JavaDoc action = "edit";
66
67 // --------------------------------------------------------- Public Methods
68

69     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
70         // Reset datas
71
name = null;
72         datasourceName = null;
73         datasourceDescription = null;
74         datasourceUrl = null;
75         datasourceClassname = null;
76         datasourceUsername = null;
77         datasourcePassword = null;
78         datasourceMapper = null;
79
80         jdbcConnmaxage = "1440";
81         jdbcMaxopentime = "1440";
82         jdbcConnchecklevel = "1";
83         jdbcConnteststmt = "SELECT 1";
84         jdbcMinconpool = "0";
85         jdbcMaxconpool = "-1";
86         jdbcMaxwaittime = "10";
87         jdbcMaxwaiters = "1000";
88     }
89
90     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
91         ActionErrors oErrors = new ActionErrors();
92         if ((name == null) || (name.length() == 0)) {
93             oErrors.add("name"
94                 , new ActionMessage("error.resource.datasource.properties.name.required"));
95         }
96         if ((datasourceName == null) || (datasourceName.length() == 0)) {
97             oErrors.add("datasourceName"
98                 , new ActionMessage("error.resource.datasource.properties.datasourceName.required"));
99         }
100         validateInteger(oErrors, jdbcConnmaxage, "jdbcConnmaxage"
101             , "error.resource.datasource.properties.jdbcConnmaxage.numberformat");
102         validateInteger(oErrors, jdbcMaxopentime, "jdbcMaxopentime"
103             , "error.resource.datasource.properties.jdbcMaxopentime.numberformat");
104         validateInteger(oErrors, jdbcMinconpool, "jdbcMinconpool"
105             , "error.resource.datasource.properties.jdbcMinconpool.numberformat");
106         validateInteger(oErrors, jdbcMaxconpool, "jdbcMaxconpool"
107             , "error.resource.datasource.properties.jdbcMaxconpool.numberformat");
108         validateInteger(oErrors, jdbcMaxwaittime, "jdbcMaxwaittime"
109             , "error.resource.datasource.properties.jdbcMaxwaitime.numberformat");
110         validateInteger(oErrors, jdbcMaxwaiters, "jdbcMaxwaiters"
111             , "error.resource.datasource.properties.jdbcMaxwaiters.numberformat");
112         return oErrors;
113     }
114
115     protected void validateInteger(ActionErrors p_Errors, String JavaDoc p_Value, String JavaDoc p_Tag
116         , String JavaDoc p_ResError) {
117         try {
118             Integer.parseInt(p_Value);
119         }
120         catch (NumberFormatException JavaDoc e) {
121             p_Errors.add(p_Tag, new ActionMessage(p_ResError));
122         }
123     }
124
125 // --------------------------------------------------------- Properties Methods
126

127     public String JavaDoc getName() {
128         return name;
129     }
130
131     public void setName(String JavaDoc name) {
132         this.name = name;
133     }
134
135     public String JavaDoc getDatasourceName() {
136         return datasourceName;
137     }
138
139     public void setDatasourceName(String JavaDoc datasourceName) {
140         this.datasourceName = datasourceName;
141     }
142
143     public String JavaDoc getDatasourceDescription() {
144         return datasourceDescription;
145     }
146
147     public void setDatasourceDescription(String JavaDoc datasourceDescription) {
148         this.datasourceDescription = datasourceDescription;
149     }
150
151     public String JavaDoc getDatasourceUrl() {
152         return datasourceUrl;
153     }
154
155     public void setDatasourceUrl(String JavaDoc datasourceUrl) {
156         this.datasourceUrl = datasourceUrl;
157     }
158
159     public String JavaDoc getDatasourceClassname() {
160         return datasourceClassname;
161     }
162
163     public void setDatasourceClassname(String JavaDoc datasourceClassname) {
164         this.datasourceClassname = datasourceClassname;
165     }
166
167     public String JavaDoc getDatasourceUsername() {
168         return datasourceUsername;
169     }
170
171     public void setDatasourceUsername(String JavaDoc datasourceUsername) {
172         this.datasourceUsername = datasourceUsername;
173     }
174
175     public String JavaDoc getDatasourcePassword() {
176         return datasourcePassword;
177     }
178
179     public void setDatasourcePassword(String JavaDoc datasourcePassword) {
180         this.datasourcePassword = datasourcePassword;
181     }
182
183     public String JavaDoc getDatasourceMapper() {
184         return datasourceMapper;
185     }
186
187     public void setDatasourceMapper(String JavaDoc datasourceMapper) {
188         this.datasourceMapper = datasourceMapper;
189     }
190
191     public String JavaDoc getJdbcConnmaxage() {
192         return jdbcConnmaxage;
193     }
194
195     public void setJdbcConnmaxage(String JavaDoc s) {
196         jdbcConnmaxage = s;
197     }
198
199     public String JavaDoc getJdbcMaxopentime() {
200         return jdbcMaxopentime;
201     }
202
203     public void setJdbcMaxopentime(String JavaDoc s) {
204         jdbcMaxopentime = s;
205     }
206
207     public String JavaDoc getJdbcConnchecklevel() {
208         return jdbcConnchecklevel;
209     }
210
211     public void setJdbcConnchecklevel(String JavaDoc jdbcConnchecklevel) {
212         this.jdbcConnchecklevel = jdbcConnchecklevel;
213     }
214
215     public String JavaDoc getJdbcConnteststmt() {
216         return jdbcConnteststmt;
217     }
218
219     public void setJdbcConnteststmt(String JavaDoc jdbcConnteststmt) {
220         this.jdbcConnteststmt = jdbcConnteststmt;
221     }
222
223     public String JavaDoc getJdbcMinconpool() {
224         return jdbcMinconpool;
225     }
226
227     public void setJdbcMinconpool(String JavaDoc jdbcMinconpool) {
228         this.jdbcMinconpool = jdbcMinconpool;
229     }
230
231     public String JavaDoc getJdbcMaxconpool() {
232         return jdbcMaxconpool;
233     }
234
235     public void setJdbcMaxconpool(String JavaDoc jdbcMaxconpool) {
236         this.jdbcMaxconpool = jdbcMaxconpool;
237     }
238
239     public String JavaDoc getJdbcMaxwaittime() {
240         return jdbcMaxwaittime;
241     }
242
243     public void setJdbcMaxwaittime(String JavaDoc jdbcMaxwaittime) {
244         this.jdbcMaxwaittime = jdbcMaxwaittime;
245     }
246
247     public String JavaDoc getJdbcMaxwaiters() {
248         return jdbcMaxwaiters;
249     }
250
251     public void setJdbcMaxwaiters(String JavaDoc jdbcMaxwaiters) {
252         this.jdbcMaxwaiters = jdbcMaxwaiters;
253     }
254
255     public String JavaDoc getJdbcSamplingperiod() {
256         return jdbcSamplingperiod;
257     }
258
259     public void setJdbcSamplingperiod(String JavaDoc s) {
260         this.jdbcSamplingperiod = s;
261     }
262
263     public java.util.List JavaDoc getBooleanValues() {
264         return booleanValues;
265     }
266
267     public java.util.List JavaDoc getCheckingLevels() {
268         return checkingLevels;
269     }
270
271     public String JavaDoc getAction() {
272         return action;
273     }
274
275     public void setAction(String JavaDoc action) {
276         this.action = action;
277     }
278
279 }
280
Popular Tags