KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > ejb > EjbForm


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

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.ejb;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.HashMap JavaDoc;
30
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32
33 import org.apache.struts.action.ActionMessage;
34 import org.apache.struts.action.ActionErrors;
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionMapping;
37
38 /**
39  * @author Michel-Ange ANTON
40  */

41 public class EjbForm extends ActionForm {
42
43 // --------------------------------------------------------- Properties variables
44

45     /**
46      * Parameters properties
47      */

48     private String JavaDoc type = null;
49     private String JavaDoc fullType = null;
50     private String JavaDoc file = null;
51     private String JavaDoc name = null;
52     private String JavaDoc objectName = null;
53     private String JavaDoc action = null;
54
55     /**
56      * Global MBean Ejb properties
57      */

58     private int currentInstancePoolSize = 0;
59     private String JavaDoc displayName = null;
60     private String JavaDoc ejbClass = null;
61     private String JavaDoc ejbFileName = null;
62     private String JavaDoc ejbName = null;
63     private String JavaDoc homeClass = null;
64     private String JavaDoc jndiName = null;
65     private String JavaDoc localClass = null;
66     private String JavaDoc localHomeClass = null;
67     private String JavaDoc remoteClass = null;
68     private boolean dependency = false;
69     private boolean databaseServiceActivated = false;
70     private boolean dataSource = false;
71     private HashMap JavaDoc dataSources = new HashMap JavaDoc();
72     private boolean jmsServiceActivated = false;
73     private boolean joramResourceLoaded = false;
74     private boolean jmsConnection = false;
75     private ArrayList JavaDoc jmsConnections = new ArrayList JavaDoc();
76     private boolean jmsDestination = false;
77     private ArrayList JavaDoc jmsDestinations = new ArrayList JavaDoc();
78     private boolean mailServiceActivated = false;
79     private boolean mailSession = false;
80     private HashMap JavaDoc mailSessions = new HashMap JavaDoc();
81     private boolean mailMime = false;
82     private HashMap JavaDoc mailMimes = new HashMap JavaDoc();
83
84 // --------------------------------------------------------- Public Methods
85

86     /**
87      * Reset all properties to their default values.
88      *
89      * @param mapping The mapping used to select this instance
90      * @param request The servlet request we are processing
91      */

92
93     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
94         // Parameters properties
95
type = null;
96         file = null;
97         name = null;
98         objectName = null;
99         fullType = null;
100         action = null;
101
102         // Global MBean Ejb properties
103
currentInstancePoolSize = 0;
104         displayName = null;
105         ejbClass = null;
106         ejbFileName = null;
107         ejbName = null;
108         homeClass = null;
109         jndiName = null;
110         localClass = null;
111         localHomeClass = null;
112         remoteClass = null;
113
114         dependency = false;
115         databaseServiceActivated = false;
116         dataSources = new HashMap JavaDoc();
117         dataSource = false;
118         jmsServiceActivated = false;
119         joramResourceLoaded = false;
120         jmsConnection = false;
121         jmsConnections = new ArrayList JavaDoc();
122         jmsDestination = false;
123         jmsDestinations = new ArrayList JavaDoc();
124         mailServiceActivated = false;
125         mailSession = false;
126         mailSessions = new HashMap JavaDoc();
127         mailMime = false;
128         mailMimes = new HashMap JavaDoc();
129     }
130
131     /**
132      * Validate the properties that have been set from this HTTP request,
133      * and return an <code>ActionErrors</code> object that encapsulates any
134      * validation errors that have been found. If no errors are found, return
135      * <code>null</code> or an <code>ActionErrors</code> object with no
136      * recorded error messages.
137      *
138      * @param mapping The mapping used to select this instance
139      * @param request The servlet request we are processing
140      * @return List of errors or null
141      */

142     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
143       ActionErrors oErrors = new ActionErrors();
144         return oErrors;
145     }
146
147 // --------------------------------------------------------- Properties Methods
148

149     // Parameters properties
150

151     public String JavaDoc getFile() {
152         return file;
153     }
154
155     public String JavaDoc getFilename() {
156         String JavaDoc sFilename = null;
157         if (file != null) {
158             sFilename = file.replace('\\', '/');
159             int iPos = sFilename.lastIndexOf('/');
160             if (iPos > -1) {
161                 sFilename = sFilename.substring(iPos + 1);
162             }
163         }
164         return sFilename;
165     }
166
167     public String JavaDoc getName() {
168         return name;
169     }
170
171     public String JavaDoc getObjectName() {
172         return objectName;
173     }
174
175     public String JavaDoc getType() {
176         return type;
177     }
178
179     public void setFile(String JavaDoc file) {
180         this.file = file;
181     }
182
183     public void setName(String JavaDoc name) {
184         this.name = name;
185     }
186
187     public void setObjectName(String JavaDoc objectName) {
188         this.objectName = objectName;
189     }
190
191     public void setType(String JavaDoc type) {
192         this.type = type;
193     }
194
195     // Global MBean Ejb properties
196

197     public int getCurrentInstancePoolSize() {
198         return currentInstancePoolSize;
199     }
200
201     public String JavaDoc getDisplayName() {
202         return displayName;
203     }
204
205     public String JavaDoc getEjbClass() {
206         return ejbClass;
207     }
208
209     public String JavaDoc getEjbName() {
210         return ejbName;
211     }
212
213     public String JavaDoc getHomeClass() {
214         return homeClass;
215     }
216
217     public String JavaDoc getJndiName() {
218         return jndiName;
219     }
220
221     public String JavaDoc getLocalClass() {
222         return localClass;
223     }
224
225     public String JavaDoc getLocalHomeClass() {
226         return localHomeClass;
227     }
228
229     public String JavaDoc getRemoteClass() {
230         return remoteClass;
231     }
232
233     public void setCurrentInstancePoolSize(int currentInstancePoolSize) {
234         this.currentInstancePoolSize = currentInstancePoolSize;
235     }
236
237     public void setDisplayName(String JavaDoc displayName) {
238         this.displayName = displayName;
239     }
240
241     public void setEjbClass(String JavaDoc ejbClass) {
242         this.ejbClass = ejbClass;
243     }
244
245     public void setEjbName(String JavaDoc ejbName) {
246         this.ejbName = ejbName;
247     }
248
249     public void setHomeClass(String JavaDoc homeClass) {
250         this.homeClass = homeClass;
251     }
252
253     public void setJndiName(String JavaDoc jndiName) {
254         this.jndiName = jndiName;
255     }
256
257     public void setLocalClass(String JavaDoc localClass) {
258         this.localClass = localClass;
259     }
260
261     public void setLocalHomeClass(String JavaDoc localHomeClass) {
262         this.localHomeClass = localHomeClass;
263     }
264
265     public void setRemoteClass(String JavaDoc remoteClass) {
266         this.remoteClass = remoteClass;
267     }
268
269     public String JavaDoc getEjbFileName() {
270         return ejbFileName;
271     }
272
273     public void setEjbFileName(String JavaDoc ejbFileName) {
274         this.ejbFileName = ejbFileName;
275     }
276
277     public String JavaDoc getFullType() {
278         return fullType;
279     }
280
281     public void setFullType(String JavaDoc fullType) {
282         this.fullType = fullType;
283     }
284
285     public HashMap JavaDoc getDataSources() {
286         return dataSources;
287     }
288
289     public void setDataSources(HashMap JavaDoc dataSources) {
290         this.dataSources = dataSources;
291     }
292
293     public boolean isDataSource() {
294         return dataSource;
295     }
296
297     public void setDataSource(boolean dataSource) {
298         this.dataSource = dataSource;
299     }
300
301     public boolean isDependency() {
302         return dependency;
303     }
304
305     public void setDependency(boolean dependency) {
306         this.dependency = dependency;
307     }
308
309     public boolean isJmsConnection() {
310         return jmsConnection;
311     }
312
313     public void setJmsConnection(boolean jmsConnection) {
314         this.jmsConnection = jmsConnection;
315     }
316
317     public ArrayList JavaDoc getJmsConnections() {
318         return jmsConnections;
319     }
320
321     public void setJmsConnections(ArrayList JavaDoc jmsConnections) {
322         this.jmsConnections = jmsConnections;
323     }
324
325     public boolean isJmsDestination() {
326         return jmsDestination;
327     }
328
329     public void setJmsDestination(boolean jmsDestination) {
330         this.jmsDestination = jmsDestination;
331     }
332
333     public ArrayList JavaDoc getJmsDestinations() {
334         return jmsDestinations;
335     }
336
337     public void setJmsDestinations(ArrayList JavaDoc jmsDestinations) {
338         this.jmsDestinations = jmsDestinations;
339     }
340
341     public HashMap JavaDoc getMailSessions() {
342         return mailSessions;
343     }
344
345     public void setMailSessions(HashMap JavaDoc mailSessions) {
346         this.mailSessions = mailSessions;
347     }
348
349     public HashMap JavaDoc getMailMimes() {
350         return mailMimes;
351     }
352
353     public void setMailMimes(HashMap JavaDoc mailMimes) {
354         this.mailMimes = mailMimes;
355     }
356
357     public boolean isMailSession() {
358         return mailSession;
359     }
360
361     public void setMailSession(boolean mailSession) {
362         this.mailSession = mailSession;
363     }
364
365     public boolean isMailMime() {
366         return mailMime;
367     }
368
369     public void setMailMime(boolean mailMime) {
370         this.mailMime = mailMime;
371     }
372
373     public boolean isDatabaseServiceActivated() {
374         return databaseServiceActivated;
375     }
376
377     public void setDatabaseServiceActivated(boolean databaseServiceActivated) {
378         this.databaseServiceActivated = databaseServiceActivated;
379     }
380
381     public boolean isJmsServiceActivated() {
382         return jmsServiceActivated;
383     }
384
385     public void setJmsServiceActivated(boolean jmsServiceActivated) {
386         this.jmsServiceActivated = jmsServiceActivated;
387     }
388
389     public boolean isMailServiceActivated() {
390         return mailServiceActivated;
391     }
392
393     public void setMailServiceActivated(boolean mailServiceActivated) {
394         this.mailServiceActivated = mailServiceActivated;
395     }
396
397     /**
398      * @return Returns the joramResourceLoaded.
399      */

400     public boolean isJoramResourceLoaded() {
401         return joramResourceLoaded;
402     }
403     /**
404      * @param joramResourceLoaded The joramResourceLoaded to set.
405      */

406     public void setJoramResourceLoaded(boolean joramResourceLoaded) {
407         this.joramResourceLoaded = joramResourceLoaded;
408     }
409
410     /**
411      * @return Returns the action.
412      */

413     public String JavaDoc getAction() {
414         return action;
415     }
416     /**
417      * @param action The action to set.
418      */

419     public void setAction(String JavaDoc action) {
420         this.action = action;
421     }
422
423
424
425     /**
426      * Helper method to check that it is a required number and
427      * is a valid integer within the given range. (min, max).
428      *
429      * @param field The field name in the form for which this error occured.
430      * @param numText The string representation of the number.
431      * @param rangeCheck Boolean value set to true of reange check should be performed.
432      *
433      * @param min The lower limit of the range
434      * @param max The upper limit of the range
435      * error.webapp.setting.sessionTimeout.required
436      */

437     protected void numberCheck(ActionErrors p_Errors, String JavaDoc field, String JavaDoc numText, boolean rangeCheck
438         , int min, int max) {
439         // Check for 'is required'
440
if ((numText == null) || (numText.length() < 1)) {
441             p_Errors.add(field, new ActionMessage("error.ejb.type.session." + field + ".required"));
442         } else {
443
444             // check for 'must be a number' in the 'valid range'
445
try {
446                 int num = Integer.parseInt(numText);
447                 // perform range check only if required
448
if (rangeCheck) {
449                     if ((num < min) || (num > max)) {
450                         p_Errors.add(field
451                             , new ActionMessage("error.ejb.type.session." + field + ".range"));
452                     }
453                 }
454             } catch (NumberFormatException JavaDoc e) {
455                 p_Errors.add(field, new ActionMessage("error.ejb.type.session." + field + ".format"));
456             }
457         }
458     }
459
460
461
462
463 }
464
Popular Tags