Source Code Cross Referenced for GenerateWrapperConf.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » tools » 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.tools 
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:         *
022:         * --------------------------------------------------------------------------
023:         * $Id: GenerateWrapperConf.java 3830 2003-12-04 21:26:30Z ehardesty $
024:         * --------------------------------------------------------------------------
025:         */
026:
027:        package org.objectweb.jonas.tools;
028:
029:        import java.util.StringTokenizer;
030:
031:        /**
032:         * This class is called by 'jonas start' command to generate
033:         * properties for the Java Service Wrapper configuration file.
034:         */
035:        public class GenerateWrapperConf {
036:
037:            /**
038:             * Generate property file for Java Service Wrapper.
039:             * <p>
040:             * GenerateWrapperConf parses CLASSPATH or an array of JAVA options
041:             * for the current JONAS_BASEW
042:             * into individual property definitions for the Java Service Wrapper
043:             * configuration file.
044:             * <p>
045:             * <pre>
046:             * Usage: java org.objectweb.jonas.tools.GenerateWrapperConf
047:             *        [-h | -?] to display usage
048:             *        [-d <delimiter>] to define delimiter for StringTokenizer
049:             *                         <delimiter> is a string of one or more
050:             *                         characters to be used by StringTokenizer
051:             *        [-i <index>]     to define initial index for generated property
052:             *                         <index> is the initial value to be appended
053:             *                         to the generated property.name entries
054:             *        property.name    name of property(s) to be generated
055:             *        args             string(s) to be parsed into properties
056:             * </pre>
057:             * <p>
058:             * Refer to Java Service Wrapper documentation
059:             * for details on configuration file format.
060:             * http://wrapper.tanukisoftware.org
061:             */
062:            String propertyName = null;
063:            int index = 1;
064:
065:            /**
066:             * Display command syntax.
067:             */
068:            void syntax() {
069:                System.err
070:                        .println("syntax: GenerateWrapperConf [-d <delimiters>] [-i <indx>] property.name args");
071:                System.exit(1);
072:            }
073:
074:            /**
075:             * Display command syntax with unrecognized command line argument
076:             */
077:            void syntax(String arg) {
078:                System.err
079:                        .println("GenerateWrapperConf: unrecognized argument '"
080:                                + arg + "'");
081:                syntax();
082:            }
083:
084:            /**
085:             * Display command syntax with exception message
086:             */
087:            void syntax(Exception e) {
088:                System.err.println(e.toString());
089:                syntax();
090:            }
091:
092:            /**
093:             * Generate Wrapper.conf property
094:             */
095:            void generateKey(String val) {
096:                System.out.println(propertyName + "." + index + "=" + val);
097:                index += 1;
098:            }
099:
100:            /**
101:             * Process command line args and generate requested
102:             * wrapper.conf property entries to STDOUT.
103:             */
104:            void run(String[] args) {
105:                String delimiter = null;
106:                int i = 0; // index into args[]
107:
108:                for (; i < args.length; i++) {
109:                    if (args[i].charAt(0) != '-')
110:                        break;
111:                    try {
112:                        switch (args[i].charAt(1)) {
113:                        case 'h':
114:                        case '?':
115:                            usage();
116:
117:                        case 'd':
118:                            delimiter = args[++i];
119:                            break;
120:
121:                        case 'i':
122:                            index = Integer.parseInt(args[++i]);
123:                            break;
124:
125:                        default:
126:                            syntax(args[i]);
127:                        }
128:                    } catch (StringIndexOutOfBoundsException e) {
129:                        syntax(args[i]);
130:                    } catch (NumberFormatException e) {
131:                        syntax(e);
132:                    }
133:                }
134:
135:                // first positional arg after -d is the property.name
136:                if ((args.length - i) < 2)
137:                    syntax();
138:                propertyName = args[i];
139:                i += 1;
140:
141:                if (delimiter == null) // process array of individual args
142:                {
143:                    for (; i < args.length; ++i)
144:                        generateKey(args[i]);
145:                }
146:
147:                else // use StringTokenizer to parse single string
148:                {
149:                    StringTokenizer st = new StringTokenizer(args[i], delimiter);
150:                    while (st.hasMoreTokens())
151:                        generateKey(st.nextToken());
152:                    i += 1;
153:                }
154:
155:                if ((args.length - i) > 0)
156:                    syntax();
157:            }
158:
159:            /**
160:             * run a new instance of the class
161:             */
162:            public static void main(String[] args) {
163:                if (args.length == 0)
164:                    usage();
165:                else
166:                    new GenerateWrapperConf().run(args);
167:            }
168:
169:            /**
170:             * Display syntax
171:             */
172:            private static void usage() {
173:                System.out
174:                        .println("\nUsage: java org.objectweb.java.tools.GenerateWrapperConf [-h | -?]\n"
175:                                + "           [-d <delimiters>] [-i <index>] property.name args\n"
176:                                + "\n"
177:                                + "  -h or -? display this help message.\n"
178:                                + "  -d <delimiters> specifies a string of delimiters used to parse\n"
179:                                + "                  args into individual tokens.\n"
180:                                + "  -i <index>      specifies the initial index for generated property\n"
181:                                + "                  values.  The default value is 1.\n"
182:                                + "  property.name   specifies the property name to be generated.\n"
183:                                + "                  Property names for the individual tokens are formed\n"
184:                                + "                  as 'property.name.index' where 'index' is incremented\n"
185:                                + "                  for each token.\n"
186:                                + "  args            Either a single string to be parsed using StringTokenizer\n"
187:                                + "                  and the delimiter specified by the -d option.\n"
188:                                + "                  This form is used to process the CLASSPATH variable.\n\n"
189:                                + "                  Or, an array of strings to be processed as individual tokens.\n"
190:                                + "                  This form is used to process JAVA_OPTS style variables.\n");
191:                System.exit(1);
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.