Source Code Cross Referenced for Executable.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » 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.cPlanner.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.cPlanner.toolkit;
016:
017:        import org.griphyn.cPlanner.common.LogManager;
018:        import org.griphyn.cPlanner.common.PegasusProperties;
019:
020:        import org.griphyn.common.util.FactoryException;
021:
022:        import org.griphyn.common.util.Version;
023:        import org.griphyn.common.util.VDSProperties;
024:
025:        import gnu.getopt.LongOpt;
026:
027:        /**
028:         * The interface which defines all the methods , any executable should implement.
029:         *
030:         * @author GAURANG MEHTA
031:         * @author KARAN VAHI
032:         * @version $Revision: 65 $
033:         *
034:         */
035:        public abstract class Executable {
036:
037:            /**
038:             * The LogManager object which is used to log all the messages.
039:             *
040:             * @see org.griphyn.cPlanner.common.LogManager
041:             */
042:            protected LogManager mLogger;
043:
044:            /**
045:             * The object holding all the properties pertaining to Pegasus.
046:             */
047:            protected PegasusProperties mProps;
048:
049:            /**
050:             * It stores the verison of the Griphyn Virtual Data System software.
051:             */
052:            protected String mVersion;
053:
054:            /**
055:             * The error message to be logged.
056:             */
057:            protected String mLogMsg;
058:
059:            /**
060:             * The constructor which ends up initialising the PegasusProperties object.
061:             */
062:            public Executable() {
063:                //setup logging before doing anything with properties
064:                setupLogging();
065:                mLogMsg = new String();
066:                mProps = PegasusProperties.getInstance();
067:                loadProperties();
068:                mVersion = Version.instance().toString();
069:            }
070:
071:            /**
072:             * Returns an error message that chains all the lower order error messages
073:             * that might have been thrown.
074:             *
075:             * @param e  the Exception for which the error message has to be composed.
076:             * @return  the error message.
077:             */
078:            public static String convertException(Exception e) {
079:                StringBuffer message = new StringBuffer();
080:                int i = 0;
081:                //append all the causes
082:                for (Throwable cause = e; cause != null; cause = cause
083:                        .getCause()) {
084:                    if (cause instanceof  FactoryException) {
085:                        //do the specialized convert for Factory Exceptions
086:                        message.append(((FactoryException) cause)
087:                                .convertException(i));
088:                        break;
089:                    }
090:                    message.append("\n [").append(Integer.toString(++i))
091:                            .append("] ").append(cause.getClass().getName())
092:                            .append(": ").append(cause.getMessage());
093:
094:                    //append just one elment of stack trace for each exception
095:                    message.append(" at ").append(cause.getStackTrace()[0]);
096:                }
097:                return message.toString();
098:            }
099:
100:            /**
101:             * Sets up the logging options for this class. Looking at the properties
102:             * file, sets up the appropriate writers for output and stderr.
103:             */
104:            protected void setupLogging() {
105:                //setup the logger for the default streams.
106:                mLogger = LogManager.getInstance();
107:
108:                //get the logging value set in properties
109:                //cannot ask for PegasusProperties, as deprecation warnings could be
110:                //logged. So get it directly from VDS Properties. Karan May 11, 2006.
111:                String value = VDSProperties.noHassleInstance().getProperty(
112:                        "pegasus.log.*");
113:
114:                //use defaults if nothing is set.
115:                if (value == null) {
116:                    mLogger.log("Logging to default streams",
117:                            LogManager.DEBUG_MESSAGE_LEVEL);
118:                    return;
119:                } else {
120:                    //log both output and error messages to value specified
121:                    mLogger.setWriters(value);
122:                }
123:
124:            }
125:
126:            /**
127:             * Loads all the properties that would be needed by the Toolkit classes.
128:             */
129:            public abstract void loadProperties();
130:
131:            /**
132:             * This method is used to print the long version of the command.
133:             */
134:            public abstract void printLongVersion();
135:
136:            /**
137:             * This is used to print the short version of the command.
138:             */
139:            public abstract void printShortVersion();
140:
141:            /**
142:             * This function is passed command line arguments. In this function you
143:             * generate the valid options and parse the options specified at run time.
144:             */
145:            public abstract void executeCommand(String[] args);
146:
147:            /**
148:             * Generates an array of valid <code>LongOpt</code> objects which contain
149:             * all the valid options to the Executable.
150:             */
151:            public abstract LongOpt[] generateValidOptions();
152:
153:            /**
154:             * Returns the version of the Griphyn Virtual Data System.
155:             */
156:            public String getGVDSVersion() {
157:                StringBuffer sb = new StringBuffer();
158:                sb.append("Pegasus Release Version ").append(mVersion);
159:                return sb.toString();
160:            }
161:
162:            /**
163:             * Logs messages to the singleton logger.
164:             *
165:             * @param msg is the message itself.
166:             * @param level is the level to generate the log message for.
167:             */
168:            public void log(String msg, int level) {
169:                mLogger.log(msg, level);
170:            }
171:
172:            /**
173:             * Get the value of the environment variable.
174:             *
175:             * @param envVariable   the environment variable whose value you want.
176:             *
177:             * @return  String corresponding to the value of the environment
178:             *          variable if it is set.
179:             *          null if the environment variable is not set
180:             */
181:            public String getEnvValue(String envVariable) {
182:                String value = null;
183:                value = System.getProperty(envVariable);
184:                return value;
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.