Source Code Cross Referenced for KickstartParser.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » visualize » 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.visualize 
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:
016:        package org.griphyn.cPlanner.visualize;
017:
018:        import org.griphyn.cPlanner.common.LogManager;
019:
020:        import org.griphyn.vdl.util.ChimeraProperties;
021:
022:        import org.griphyn.vdl.directive.ParseKickstart;
023:
024:        import org.griphyn.vdl.invocation.InvocationRecord;
025:        import org.griphyn.vdl.invocation.StatCall;
026:        import org.griphyn.vdl.invocation.Data;
027:        import org.griphyn.vdl.invocation.Regular;
028:
029:        import org.griphyn.vdl.parser.InvocationParser;
030:
031:        import org.griphyn.common.util.Currently;
032:
033:        import java.util.List;
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:
037:        import java.io.File;
038:        import java.io.IOException;
039:        import java.io.StringReader;
040:        import java.io.StringWriter;
041:
042:        /**
043:         * A helper class that parses the kickstart records and has calls to callbacks
044:         * for working on data sections of standard out, standard error, and standard
045:         * input.
046:         *
047:         * @author Karan Vahi vahi@isi.edu
048:         * @version $Revision: 50 $
049:         */
050:
051:        public class KickstartParser {
052:
053:            /**
054:             * The parser class that is used to parse a kickstart record and return
055:             * the invocation record.
056:             */
057:            private ParseKickstart mParseKickstart;
058:
059:            /**
060:             * The handle to the logging object.
061:             */
062:            private LogManager mLogger;
063:
064:            /**
065:             * The callback object.
066:             */
067:            private Callback mCallback;
068:
069:            /**
070:             * Semi-singleton, dynamically instantiated once for the lifetime.
071:             * The properties determine which Xerces parser is being used.
072:             */
073:            private InvocationParser mInvocationParser;
074:
075:            /**
076:             * The default constructor.
077:             */
078:            public KickstartParser() {
079:                mLogger = LogManager.getInstance();
080:            }
081:
082:            /**
083:             * Sets the callback to which to callout to while parsing a kickstart
084:             * record.
085:             *
086:             * @param c  the Callback to call out to.
087:             */
088:            public void setCallback(Callback c) {
089:                mCallback = c;
090:                mLogger = LogManager.getInstance();
091:            }
092:
093:            /**
094:             *
095:             */
096:            public List parseKickstartFile(String file) throws IOException {
097:                List result = new ArrayList();
098:
099:                //sanity check
100:                if (mCallback == null) {
101:                    throw new RuntimeException("Callback not initialized");
102:                }
103:
104:                //initialize the parser if required
105:                if (mParseKickstart == null) {
106:                    mParseKickstart = new ParseKickstart();
107:                }
108:
109:                // get access to the invocation parser
110:                if (mInvocationParser == null) {
111:                    ChimeraProperties props = ChimeraProperties.instance();
112:                    String psl = props.getPTCSchemaLocation();
113:                    mLogger.log("Using XML schema location " + psl,
114:                            LogManager.DEBUG_MESSAGE_LEVEL);
115:                    mInvocationParser = new InvocationParser(psl);
116:                }
117:
118:                //do some sanity checks for the file.
119:
120:                //extract to memory
121:                File f = new java.io.File(file);
122:                List extract = mParseKickstart.extractToMemory(f);
123:
124:                org.griphyn.vdl.invocation.File invocationFile = null;
125:
126:                // testme: for each record obtained, work on it
127:                for (int j = 1; j - 1 < extract.size(); ++j) {
128:                    String temp = (String) extract.get(j - 1);
129:
130:                    // test 5: try to parse XML
131:                    InvocationRecord invocation = mInvocationParser
132:                            .parse(new StringReader(temp));
133:                    mCallback.cbInvocationStart(getJobName(f.getName()),
134:                            invocation.getResource());
135:
136:                    //get the data about the various jobs
137:                    List jobs = invocation.getJobList();
138:
139:                    //callback for the data sections of various streams
140:                    List stats = invocation.getStatList();
141:                    StringWriter writer = new StringWriter();
142:                    for (Iterator it = stats.iterator(); it.hasNext();) {
143:                        StatCall statC = (StatCall) it.next();
144:                        String handle = statC.getHandle();
145:                        invocationFile = statC.getFile();
146:
147:                        //call out appropriate callback functions with the data
148:                        char c = handle.charAt(0);
149:                        Data data = statC.getData();
150:                        String value = (data == null) ? "" : data.getValue();
151:                        switch (c) {
152:                        case 's': //stdout, //stderr,//stdin
153:                            if (handle.equals("stdout")) {
154:                                mCallback.cbStdOut(jobs, value);
155:                            } else if (handle.equals("stdin")) {
156:                                mCallback.cbStdIN(jobs, value);
157:                            } else if (handle.equals("stderr")) {
158:                                mCallback.cbStdERR(jobs, value);
159:                            }
160:                            break;
161:
162:                        case 'i'://initial
163:                            if (handle.equals("initial")) {
164:                                if (invocationFile instanceof  Regular) {
165:                                    //we are interested in Regular files only
166:                                    mCallback.cbInputFile(
167:                                            ((Regular) invocationFile)
168:                                                    .getFilename(), statC
169:                                                    .getStatInfo());
170:                                }
171:                            }
172:                            break;
173:
174:                        case 'f'://final
175:                            if (handle.equals("final")) {
176:                                if (invocationFile instanceof  Regular) {
177:                                    //we are interested in Regular files only
178:                                    mCallback.cbOutputFile(
179:                                            ((Regular) invocationFile)
180:                                                    .getFilename(), statC
181:                                                    .getStatInfo());
182:                                }
183:
184:                            }
185:
186:                        default:
187:                            break;
188:                        }
189:                    }
190:
191:                    //successfully done with an invocation record
192:                    mCallback.cbInvocationEnd();
193:                }
194:                return result;
195:            }
196:
197:            /**
198:             * Returns the name of the job from the kickstart output filename.
199:             *
200:             * @param outName  the name of the out file.
201:             *
202:             * @return the job name.
203:             */
204:            protected String getJobName(String outName) {
205:                return outName.substring(0, outName.indexOf('.'));
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.