Source Code Cross Referenced for ToDAG.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » vdl » router » 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.router 
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.vdl.router;
017:
018:        import org.griphyn.vdl.classes.*;
019:        import org.griphyn.vdl.parser.*;
020:        import org.griphyn.vdl.router.*;
021:        import org.griphyn.vdl.toolkit.*;
022:        import org.griphyn.vdl.dbschema.*;
023:        import org.griphyn.vdl.util.ChimeraProperties;
024:        import org.griphyn.vdl.util.Logging;
025:        import org.griphyn.vdl.directive.*;
026:        import org.griphyn.common.util.Version;
027:
028:        import java.io.Writer;
029:        import java.io.PrintWriter;
030:        import java.io.BufferedWriter;
031:        import gnu.getopt.*;
032:
033:        public class ToDAG extends Toolkit {
034:            /**
035:             * ctor: Constructs a new instance object with the given application name.
036:             */
037:            public ToDAG(String appName) {
038:                super (appName);
039:            }
040:
041:            /**
042:             * Shows the usage.
043:             */
044:            public void showUsage() {
045:                String m_usage = "[-d dbname] [-l t|x] -f lfn";
046:
047:                String linefeed = System.getProperty("line.separator", "\r\n");
048:
049:                System.out
050:                        .println("$Id: ToDAG.java 50 2007-05-19 00:48:32Z gmehta $"
051:                                + linefeed
052:                                + "VDS version "
053:                                + Version.instance().toString() + linefeed);
054:
055:                System.out.println("Usage: " + this .m_application
056:                        + " [-d db] [-l t|x] -f lfn" + linefeed);
057:
058:                System.out
059:                        .println(" -V|--version   print version information and exit."
060:                                + linefeed
061:                                + " -d|--dbase dbx associates the dbname with the database, unused."
062:                                + linefeed
063:                                + " -l|--list x|t  output format, textual or XML, default is XML."
064:                                + linefeed
065:                                + " -f|--file lfn  request a filename to be produced"
066:                                + linefeed);
067:            }
068:
069:            /**
070:             * Creates a set of long options.
071:             * @return the long option vector.
072:             */
073:            protected LongOpt[] generateValidOptions() {
074:                LongOpt[] lo = new LongOpt[6];
075:
076:                lo[0] = new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h');
077:                lo[1] = new LongOpt("dbase", LongOpt.REQUIRED_ARGUMENT, null,
078:                        'd');
079:                lo[2] = new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V');
080:
081:                lo[3] = new LongOpt("file", LongOpt.REQUIRED_ARGUMENT, null,
082:                        'f');
083:                lo[4] = new LongOpt("lfn", LongOpt.REQUIRED_ARGUMENT, null, 'f');
084:                lo[5] = new LongOpt("list", LongOpt.REQUIRED_ARGUMENT, null,
085:                        'l');
086:
087:                return lo;
088:            }
089:
090:            public static void main(String[] args)
091:                    throws IllegalArgumentException {
092:                // create debug output
093:                Logging.instance().register("app", System.err);
094:                Logging.instance().register("dag", System.err);
095:                Logging.instance().register("state", System.err);
096:                Logging.instance().register("route", System.err);
097:                Logging.instance().register("trace", System.err);
098:                Logging.instance().register("stack", System.err);
099:
100:                try {
101:                    // new instance
102:                    ToDAG me = new ToDAG("ToDAG");
103:
104:                    // get the commandline options
105:                    Getopt opts = new Getopt(me.m_application, args,
106:                            "hd:f:l:V", me.generateValidOptions());
107:                    opts.setOpterr(false);
108:
109:                    String dbase = null;
110:                    String lfn = null;
111:                    String t = null;
112:                    int option = 0;
113:                    while ((option = opts.getopt()) != -1) {
114:                        switch (option) {
115:                        case 'V':
116:                            System.out
117:                                    .println("$Id: ToDAG.java 50 2007-05-19 00:48:32Z gmehta $");
118:                            System.out.println("VDS version "
119:                                    + Version.instance().toString());
120:                            return;
121:
122:                        case 'd':
123:                            dbase = opts.getOptarg();
124:                            break;
125:
126:                        case 'f':
127:                            lfn = opts.getOptarg();
128:                            break;
129:
130:                        case 'l':
131:                            t = opts.getOptarg().toLowerCase();
132:                            break;
133:
134:                        case 'h':
135:                        default:
136:                            me.showUsage();
137:                            return;
138:                        }
139:                    }
140:
141:                    // sanity check
142:                    if (lfn == null || lfn.length() == 0) {
143:                        me.showUsage();
144:                        System.err.println("You must specify a value for -f");
145:                        System.exit(1);
146:                    }
147:
148:                    // user supplied database, set up me.m_dbschema
149:                    String vdcSchemaName = ChimeraProperties.instance()
150:                            .getVDCSchemaName();
151:                    Connect connect = new Connect();
152:                    DatabaseSchema dbschema = connect
153:                            .connectDatabase(vdcSchemaName);
154:
155:                    // output format, defaults to XML
156:                    boolean wantText = (t != null && Character.toLowerCase(t
157:                            .charAt(0)) == 't');
158:
159:                    Definitions defs = null;
160:                    if (dbschema instanceof  InMemorySchema) {
161:                        // already everything in main memory, use backdoor (Yuck! Dirty!)
162:                        // avoid duplicating DVs in main memory.
163:                        defs = ((InMemorySchema) dbschema).backdoor();
164:                    } else {
165:                        // Load all Definitions into an in-memory database (uiuiui)
166:                        me.m_logger.log("app", 1,
167:                                "loading *all* definitions into memory");
168:                        defs = new Definitions();
169:                        defs.setDefinition(((VDC) dbschema).searchDefinition(
170:                                null, null, null, -1));
171:                    }
172:
173:                    if (defs == null) {
174:                        System.err.println("No input data, nothing to route");
175:                        return;
176:                    }
177:
178:                    // create new route object, in memory classes
179:                    Route r = new Route(new InMemorySchema(defs));
180:
181:                    // actually do some routing
182:                    BookKeeper bk = r.requestLfn(lfn);
183:
184:                    // what is it to be, xml or text
185:                    Writer bw = new BufferedWriter(new PrintWriter(System.out));
186:                    if (wantText) {
187:                        if (bk != null)
188:                            bk.toString(bw);
189:                        else
190:                            bw.write("# no jobs generated"
191:                                    + System.getProperty("line.separator",
192:                                            "\r\n"));
193:                    } else {
194:                        if (bk != null)
195:                            bk.toXML(bw, "");
196:                        else
197:                            bw.write("<!-- no jobs generated -->"
198:                                    + System.getProperty("line.separator",
199:                                            "\r\n"));
200:                    }
201:                } catch (Exception e) {
202:                    e.printStackTrace();
203:                }
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.