Source Code Cross Referenced for Toolkit.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » toolkit » 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 » Workflow Engines » pegasus 2.1.0 » org.griphyn.vdl.toolkit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found in file ../GTPL, or at
004:         * http://www.globus.org/toolkit/download/license.html. This notice must
005:         * appear in redistributions of this file, with or without modification.
006:         *
007:         * Redistributions of this Software, with or without modification, must
008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009:         * some other similar material which is provided with the Software (if
010:         * any).
011:         *
012:         * Copyright 1999-2004 University of Chicago and The University of
013:         * Southern California. All rights reserved.
014:         */
015:        package org.griphyn.vdl.toolkit;
016:
017:        import java.io.*;
018:        import java.sql.SQLException;
019:        import java.util.Collection;
020:        import java.util.MissingResourceException;
021:        import org.griphyn.vdl.util.Logging;
022:        import org.griphyn.vdl.util.ChimeraProperties;
023:        import org.griphyn.vdl.dbschema.*;
024:
025:        /**
026:         * This class is the base class for other toolkits. It provides
027:         * basical common functions, to be extended, used or restricted
028:         * by siblings as necessary.
029:         *
030:         * @author Jens-S. Vöckler
031:         * @author Yong Zhao
032:         * @version $Revision: 50 $
033:         *
034:         * @see org.griphyn.vdl.util.Logging
035:         * @see org.griphyn.vdl.util.ChimeraProperties
036:         * @see org.griphyn.vdl.dbschema.DatabaseSchema
037:         */
038:        public abstract class Toolkit {
039:            /**
040:             * Maintains an application specific set of properties
041:             */
042:            protected ChimeraProperties m_props;
043:
044:            /**
045:             * Stores the name of the application as which this one was run
046:             */
047:            protected String m_application;
048:
049:            /**
050:             * Stores the name of the home directory for the Chimera system.
051:             */
052:            protected String m_home;
053:
054:            /**
055:             * Stores the logging instance
056:             */
057:            protected Logging m_logger;
058:
059:            /**
060:             * Stores the verbosity level of the app logging queue.
061:             */
062:            protected int m_verbosity;
063:
064:            /**
065:             * Helper for the constructors
066:             *
067:             * @param self is the reference to self (the unit to be constructed)
068:             */
069:            private static void setup(Toolkit self) {
070:                // set up logger
071:                self.m_logger = Logging.instance();
072:
073:                // setting up properties -- might throw things at us
074:                try {
075:                    self.m_props = ChimeraProperties.instance();
076:                } catch (IOException e) {
077:                    Logging.instance().log(
078:                            "default",
079:                            0,
080:                            "error while reading properties file: "
081:                                    + e.getMessage());
082:                } catch (MissingResourceException e) {
083:                    Logging
084:                            .instance()
085:                            .log("default", 0,
086:                                    "You probably forgot to set -Dvds.home=$PEGASUS_HOME");
087:                    System.exit(1);
088:                }
089:
090:                self.m_props.setupLogging(self.m_logger);
091:            }
092:
093:            /**
094:             * Default ctor: Sets up the system 
095:             *
096:             * @param appName is the name of the shell wrapper with which to report. 
097:             */
098:            public Toolkit(String appName) {
099:                m_application = appName;
100:                setup(this );
101:
102:                // Register app by default, but only with level 0
103:                // jsv: 20050815, bugzilla#79
104:                if (m_logger.isUnset("app")) {
105:                    m_verbosity = 0;
106:                    m_logger.register("app", System.out, m_verbosity);
107:                } else {
108:                    m_verbosity = m_logger.getLevel("app");
109:                    if (m_verbosity == Integer.MAX_VALUE || m_verbosity < 0) {
110:                        m_verbosity = 0;
111:                        m_logger.setLevel("app", m_verbosity);
112:                    }
113:                }
114:            }
115:
116:            /**
117:             * Default ctor: Sets up the system 
118:             *
119:             * @param appName is the name of the shell wrapper with which to report. 
120:             * @param verbosity sets the verbosity level of the "app" logging queue. 
121:             */
122:            public Toolkit(String appName, int verbosity) {
123:                m_application = appName;
124:                setup(this );
125:
126:                // Register app by default, but only with level 0
127:                // jsv: 20050815, bugzilla#79
128:                if (m_logger.isUnset("app")) {
129:                    m_verbosity = verbosity;
130:                    m_logger.register("app", System.out, m_verbosity);
131:                } else {
132:                    m_verbosity = m_logger.getLevel("app");
133:                    if (m_verbosity == Integer.MAX_VALUE || m_verbosity < 0) {
134:                        m_verbosity = 0;
135:                        m_logger.setLevel("app", m_verbosity);
136:                    }
137:                }
138:            }
139:
140:            /**
141:             * Helper function to set the verbosity level of the app logging
142:             * queue.
143:             *
144:             * @param verbosity is the new verbosity level
145:             * @see #getVerbosity()
146:             * @see #increaseVerbosity()
147:             */
148:            public void setVerbosity(int verbosity) {
149:                this .m_verbosity = verbosity;
150:                this .m_logger.setLevel("app", verbosity);
151:            }
152:
153:            /**
154:             * Helper function to obtain the verbosity level of the app logging
155:             * queue.
156:             *
157:             * @return the verbosity level as non-negative integer, or -1 for
158:             * error.
159:             * @see #setVerbosity( int )
160:             * @see #increaseVerbosity()
161:             */
162:            public int getVerbosity() {
163:                int result = this .m_logger.getLevel("app");
164:                this .m_verbosity = result;
165:                return result;
166:            }
167:
168:            /**
169:             * Helper function to increase the verbosity level of the app logging
170:             * queue using the internal verbosity state. 
171:             *
172:             * @return the new verbosity level
173:             * @see #setVerbosity( int )
174:             * @see #getVerbosity()
175:             */
176:            public int increaseVerbosity() {
177:                this .m_logger.setLevel("app", ++this .m_verbosity);
178:                return this .m_verbosity;
179:            }
180:
181:            /**
182:             * Prints the short usage string onto stdout. No exiting.
183:             * The application name is maintained by the c'tor.
184:             */
185:            public abstract void showUsage();
186:
187:            /**
188:             * This helper method reads lines from a file and add non-empty,
189:             * no-comment lines to a collection of lines. Invoke with a set to
190:             * prohibit duplicates, or with a list to permit duplicates.
191:             *
192:             * @param fn is the name of the file to read.
193:             * @param list is the container to add lines to
194:             * @return number of items read.
195:             * @throws IOException if any file operation failed.
196:             */
197:            protected int readFile(String fn, Collection list)
198:                    throws IOException {
199:                String line;
200:                int count = 0;
201:                LineNumberReader in = null;
202:                if (fn == null)
203:                    return 0;
204:
205:                in = new LineNumberReader(new FileReader(fn));
206:                while ((line = in.readLine()) != null) {
207:                    // remove comments
208:                    int p = line.indexOf('#');
209:                    if (p != -1)
210:                        line = line.substring(0, p);
211:
212:                    // remove superflous whitespace
213:                    line = line.trim();
214:
215:                    // add anything non-empty
216:                    if (line.length() >= 1) {
217:                        list.add(line);
218:                        count++;
219:                    }
220:                }
221:
222:                in.close();
223:                return count;
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.