Source Code Cross Referenced for ParameterSet.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » newbean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.newbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         * 
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         * 
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer(s): Nicolas Christin
022:         * Contributor(s): ______________________________________.
023:         *
024:         * --------------------------------------------------------------------------
025:         * $Id: ParameterSet.java 3736 2003-11-21 01:13:25Z skrupanszky $
026:         * --------------------------------------------------------------------------
027:         */
028:
029:        package org.objectweb.jonas.newbean;
030:
031:        import org.apache.velocity.VelocityContext;
032:
033:        /**
034:         * This class defines the set of parameters used by the application.
035:         */
036:        public class ParameterSet {
037:
038:            private Parameter beanNameParameter = null;
039:            private Parameter beanFlavorParameter = null;
040:            private Parameter sessionTypeParameter = null;
041:            private Parameter persistenceManagerParameter = null;
042:            private Parameter isLocalParameter = null;
043:            private Parameter pkgNameParameter = null;
044:            private Parameter jarNameParameter = null;
045:            private Parameter pkClassParameter = null;
046:
047:            /**
048:             * Creates a new set of parameters associated to the specified
049:             * Velocity context.
050:             */
051:            public ParameterSet(VelocityContext context) {
052:
053:                // ----------------------------
054:                // beanNameParameter definition
055:                // ----------------------------
056:
057:                beanNameParameter = new Parameter(context) {
058:
059:                    public String getPrompt() {
060:                        return "Bean Name";
061:                    }
062:
063:                    public String getArgKeyword() {
064:                        return "-beanName";
065:                    }
066:
067:                    public boolean isValid() {
068:                        return (value.length() > 0);
069:                    }
070:
071:                    public void export() {
072:                        vContext.put("beanName", value);
073:                    }
074:
075:                    public Parameter getNextParameter() {
076:                        return beanFlavorParameter;
077:                    }
078:
079:                };
080:
081:                // ------------------------------
082:                // beanFlavorParameter definition
083:                // ------------------------------
084:
085:                beanFlavorParameter = new Parameter(context) {
086:
087:                    private final Integer SESSION_BEAN = new Integer(0);
088:                    private final Integer ENTITY_BEAN = new Integer(1);
089:                    private final Integer MESSAGE_DRIVEN_BEAN = new Integer(2);
090:
091:                    public String getPrompt() {
092:                        return "Bean type\n  S   Session bean\n  E   Entity bean\n  MD  Message-Driven bean";
093:                    }
094:
095:                    public String getArgKeyword() {
096:                        return "-beanType";
097:                    }
098:
099:                    public void setValue(String input) {
100:                        value = input.toUpperCase();
101:                    }
102:
103:                    public boolean isValid() {
104:                        return (value.equals("S") || value.equals("E") || value
105:                                .equals("MD"));
106:                    }
107:
108:                    public void export() {
109:                        vContext.put("SESSION_BEAN", SESSION_BEAN);
110:                        vContext.put("ENTITY_BEAN", ENTITY_BEAN);
111:                        vContext
112:                                .put("MESSAGE_DRIVEN_BEAN", MESSAGE_DRIVEN_BEAN);
113:                        Integer beanFlavor = null;
114:                        String beanType = null;
115:                        if (value.equals("S")) {
116:                            beanFlavor = SESSION_BEAN;
117:                            beanType = "S";
118:                        } else if (value.equals("E")) {
119:                            beanFlavor = ENTITY_BEAN;
120:                            beanType = "E";
121:                        } else if (value.equals("MD")) {
122:                            beanFlavor = MESSAGE_DRIVEN_BEAN;
123:                            beanType = "MD";
124:                        }
125:                        vContext.put("beanFlavor", beanFlavor);
126:                        vContext.put("beanType", beanType);
127:                    }
128:
129:                    public Parameter getNextParameter() {
130:                        Integer beanFlavor = (Integer) vContext
131:                                .get("beanFlavor");
132:                        if (beanFlavor == SESSION_BEAN) {
133:                            return sessionTypeParameter;
134:                        } else if (beanFlavor == ENTITY_BEAN) {
135:                            return persistenceManagerParameter;
136:                        }
137:                        return pkgNameParameter;
138:                    }
139:
140:                };
141:
142:                // -------------------------------
143:                // sessionTypeParameter definition
144:                // -------------------------------
145:
146:                sessionTypeParameter = new Parameter(context) {
147:
148:                    private final Integer STATELESS = new Integer(0);
149:                    private final Integer STATEFUL = new Integer(1);
150:
151:                    public String getPrompt() {
152:                        return "Session type\n  L  Staless\n  F  Stateful";
153:                    }
154:
155:                    public String getArgKeyword() {
156:                        return "-sessionType";
157:                    }
158:
159:                    public void setValue(String input) {
160:                        value = input.toUpperCase();
161:                    }
162:
163:                    public boolean isValid() {
164:                        return (value.equals("L") || value.equals("F"));
165:                    }
166:
167:                    public void export() {
168:                        vContext.put("STATELESS", STATELESS);
169:                        vContext.put("STATEFUL", STATEFUL);
170:                        Integer sessionType = null;
171:                        String beanType = (String) vContext.get("beanType");
172:                        if (value.equals("L")) {
173:                            sessionType = STATELESS;
174:                            beanType += "L";
175:                        } else if (value.equals("F")) {
176:                            sessionType = STATEFUL;
177:                            beanType += "F";
178:                        }
179:                        vContext.put("sessionType", sessionType);
180:                        vContext.put("beanType", beanType);
181:                    }
182:
183:                    public Parameter getNextParameter() {
184:                        return isLocalParameter;
185:                    }
186:
187:                };
188:
189:                // --------------------------------------
190:                // persistenceManagerParameter definition
191:                // --------------------------------------
192:
193:                persistenceManagerParameter = new Parameter(context) {
194:
195:                    private final Integer BMP = new Integer(0);
196:                    private final Integer CMP1 = new Integer(1);
197:                    private final Integer CMP2 = new Integer(2);
198:
199:                    public String getPrompt() {
200:                        return "Persistance manager\n    B  BMP\n    C  CMP 1.x\n    C2 CMP 2.x";
201:                    }
202:
203:                    public String getArgKeyword() {
204:                        return "-persistence";
205:                    }
206:
207:                    public void setValue(String input) {
208:                        value = input.toUpperCase();
209:                    }
210:
211:                    public boolean isValid() {
212:                        return (value.equals("C") || value.equals("B") || value
213:                                .equals("C2"));
214:                    }
215:
216:                    public void export() {
217:                        vContext.put("CMP1", CMP1);
218:                        vContext.put("CMP2", CMP2);
219:                        vContext.put("BMP", BMP);
220:                        Integer persistenceManager = null;
221:
222:                        String beanType = (String) vContext.get("beanType");
223:                        if (value.equals("C")) {
224:                            persistenceManager = CMP1;
225:                            beanType += "C";
226:                        } else if (value.equals("B")) {
227:                            persistenceManager = BMP;
228:                            beanType += "B";
229:                        } else if (value.equals("C2")) {
230:                            persistenceManager = CMP2;
231:                            beanType += "C2";
232:                        }
233:                        vContext.put("persistenceManager", persistenceManager);
234:                        vContext.put("beanType", beanType);
235:                    }
236:
237:                    public Parameter getNextParameter() {
238:                        return isLocalParameter;
239:                    }
240:
241:                };
242:
243:                // ---------------------------
244:                // isLocalParameter definition
245:                // ---------------------------
246:
247:                isLocalParameter = new Parameter(context) {
248:
249:                    private final Boolean FALSE = Boolean.FALSE;
250:                    private final Boolean TRUE = Boolean.TRUE;
251:
252:                    public String getPrompt() {
253:                        return "Bean location\n  R  Remote\n  L  Local";
254:                    }
255:
256:                    public String getArgKeyword() {
257:                        return "-location";
258:                    }
259:
260:                    public void setValue(String input) {
261:                        value = input.toUpperCase();
262:                    }
263:
264:                    public boolean isValid() {
265:                        return (value.equals("R") || value.equals("L"));
266:                    }
267:
268:                    public void export() {
269:                        Boolean isLocal = null;
270:                        String beanType = (String) vContext.get("beanType");
271:                        if (value.equals("L")) {
272:                            isLocal = TRUE;
273:                            beanType += "L";
274:                        } else if (value.equals("R")) {
275:                            isLocal = FALSE;
276:                            beanType += "R";
277:                        }
278:                        vContext.put("isLocal", isLocal);
279:                        vContext.put("beanType", beanType);
280:                    }
281:
282:                    public Parameter getNextParameter() {
283:                        return pkgNameParameter;
284:                    }
285:
286:                };
287:
288:                // ---------------------------
289:                // pkgNameParameter definition
290:                // ---------------------------
291:
292:                pkgNameParameter = new Parameter(context) {
293:
294:                    public String getPrompt() {
295:                        return "Package name";
296:                    }
297:
298:                    public String getArgKeyword() {
299:                        return "-pkgName";
300:                    }
301:
302:                    public boolean isValid() {
303:                        return (value.length() > 0);
304:                    }
305:
306:                    public void export() {
307:                        vContext.put("pkgName", value);
308:                    }
309:
310:                    public Parameter getNextParameter() {
311:                        return jarNameParameter;
312:                    }
313:
314:                };
315:
316:                // ---------------------------
317:                // jarNameParameter definition
318:                // ---------------------------
319:
320:                jarNameParameter = new Parameter(context) {
321:
322:                    public String getPrompt() {
323:                        return "Jar name";
324:                    }
325:
326:                    public String getArgKeyword() {
327:                        return "-jarName";
328:                    }
329:
330:                    public void setValue(String input) {
331:                        if (input.endsWith(".jar")) {
332:                            value = input.substring(0, input.length() - 4);
333:                        } else {
334:                            value = input;
335:                        }
336:                    }
337:
338:                    public boolean isValid() {
339:                        return (value.length() > 0);
340:                    }
341:
342:                    public void export() {
343:                        vContext.put("jarName", value);
344:                    }
345:
346:                    public Parameter getNextParameter() {
347:                        final Integer ENTITY_BEAN = (Integer) vContext
348:                                .get("ENTITY_BEAN");
349:                        Integer beanFlavor = (Integer) vContext
350:                                .get("beanFlavor");
351:                        if (beanFlavor == ENTITY_BEAN)
352:                            return pkClassParameter;
353:                        else
354:                            return null;
355:                    }
356:
357:                };
358:
359:                // ---------------------------
360:                // pkClassParameter definition
361:                // ---------------------------
362:
363:                pkClassParameter = new Parameter(context) {
364:
365:                    public String getPrompt() {
366:                        return "Primary Key class\n  S  String\n  I  Integer\n  O  Object";
367:                    }
368:
369:                    public String getArgKeyword() {
370:                        return "-primaryKey";
371:                    }
372:
373:                    public void setValue(String input) {
374:                        value = input.toUpperCase();
375:                    }
376:
377:                    public boolean isValid() {
378:                        return (value.equals("S") || value.equals("I") || value
379:                                .equals("O"));
380:                    }
381:
382:                    public void export() {
383:                        String pkClass = null;
384:                        if (value.equals("S"))
385:                            pkClass = "java.lang.String";
386:                        else if (value.equals("I"))
387:                            pkClass = "java.lang.Integer";
388:                        else if (value.equals("O"))
389:                            pkClass = "java.lang.Object";
390:                        vContext.put("pkClass", pkClass);
391:                    }
392:
393:                    public Parameter getNextParameter() {
394:                        return null;
395:                    }
396:
397:                };
398:
399:            }
400:
401:            /**
402:             * Walk through ({@link Parameter#walkThrough()}) the whole
403:             * parameters set.
404:             */
405:            public void walkThrough() {
406:                beanNameParameter.walkThrough();
407:            }
408:
409:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.