Source Code Cross Referenced for OPP.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » tools » OPP » 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 » Database DBMS » Ozone 1.1 » org.ozoneDB.tools.OPP 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Library License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: OPP.java,v 1.4 2002/06/08 00:49:39 mediumnet Exp $
008:
009:        package org.ozoneDB.tools.OPP;
010:
011:        import java.io.File;
012:
013:        import org.ozoneDB.DxLib.DxHashSet;
014:        import org.ozoneDB.DxLib.DxIterator;
015:        import org.ozoneDB.core.ObjectContainer;
016:
017:        /**
018:         * Command line driver of the OPP tool.
019:         *
020:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
021:         * @version $Revision: 1.4 $Date: 2002/06/08 00:49:39 $
022:         */
023:        public class OPP {
024:
025:            public final static String SIGNATURE_DELIMITER = "|";
026:
027:            /**
028:             * Update methods can marked with a
029:             * <pre>
030:             *   /*update * /
031:             * </pre>
032:             * in the lines following the method signature.
033:             */
034:            public final static String UPDATE_SIGN = "/[*]+ *update *[*]/|// *update";
035:
036:            /**
037:             * All method signatures in java interfaces must look like:
038:             * <pre>
039:             *   public package.return.Class[] methodname (
040:             * </pre>
041:             * Otherwise OPP is unable to find them.
042:             */
043:            public final static String METHOD_PATTERN = "^[ \\t]*public[ \\t]+[_a-zA-Z][_a-zA-Z0-9\\.\\[\\]]*[ \\t]+([_a-zA-Z][\\w]*)[ \\t]*\\(";
044:
045:            /**
046:             * Update methods can marked with a
047:             * <pre>
048:             *   @update
049:             * </pre>
050:             * in its appropriate Javadoc Comment.
051:             */
052:            public final static String JAVADOC_PATTERN = "^[ \\t]+\\*[ \\t]*@update";
053:
054:            static boolean odmg = false;
055:            static boolean quiet = false;
056:            static boolean cache = true;
057:            static boolean keepSource = false;
058:            static boolean compileSource = true;
059:            static boolean printStackTrace = false;
060:            static boolean searchInterfaceSource = true;
061:            static String methodPattern = ".*_update";
062:            static String outputDirName = "." + File.separator;
063:            static String sourceDirName = "." + File.separator;
064:
065:            public static void main(String[] args) {
066:
067:                DxHashSet classes = new DxHashSet();
068:
069:                if (args.length == 0) {
070:                    printUsage();
071:                    System.exit(0);
072:                }
073:
074:                boolean preservePackageNames = true;
075:
076:                for (int argCount = 0; argCount < args.length; argCount++) {
077:                    if (args[argCount].equals("-q")) {
078:                        quiet = true;
079:                    } else if (args[argCount].equals("-ks")) {
080:                        keepSource = true;
081:                    } else if (args[argCount].equals("-KS")) {
082:                        keepSource = true;
083:                        compileSource = false;
084:                    } else if (args[argCount].equals("-odmg")) {
085:                        odmg = true;
086:                    } else if (args[argCount].equals("-nc")) {
087:                        cache = false;
088:                    } else if (args[argCount].equals("-st")) {
089:                        printStackTrace = true;
090:                    } else if (args[argCount].equals("-ni")) {
091:                        searchInterfaceSource = false;
092:                    } else if (args[argCount].startsWith("-p")) {
093:                        methodPattern = args[argCount].substring(2);
094:                    } else if (args[argCount].equals("-version")) {
095:                        System.out
096:                                .println("$Id: OPP.java,v 1.4 2002/06/08 00:49:39 mediumnet Exp $");
097:                        System.exit(0);
098:                    } else if (args[argCount].equals("-h")) {
099:                        printUsage();
100:                        System.exit(0);
101:                    } else if (args[argCount].startsWith("-o")) {
102:                        outputDirName = args[argCount].substring(2)
103:                                + File.separator;
104:                    } else if (args[argCount].startsWith("-s")) {
105:                        sourceDirName = args[argCount].substring(2)
106:                                + File.separator;
107:                    } else if (args[argCount].equals("-ip")) {
108:                        preservePackageNames = false;
109:                    } else {
110:                        if (args[argCount].startsWith("-")) {
111:                            System.out.println("Unknown option '"
112:                                    + args[argCount] + "'!\n");
113:                            printUsage();
114:                            System.exit(0);
115:                        } else {
116:                            classes.add(args[argCount]);
117:                        }
118:                    }
119:                }
120:                // We internally use the new directory parameter format,
121:                // but the user has specified the directory parameters in the old format
122:                // where packages were ignored
123:                if (!preservePackageNames) {
124:                    DxIterator i = classes.iterator();
125:
126:                    if (i.next() != null) {
127:                        String className = (String) i.key();
128:
129:                        if (className != null) {
130:                            int dotCount = 0;
131:                            int index = 0;
132:
133:                            while ((index = className.indexOf('.', index)) != -1) {
134:                                dotCount++;
135:                                index++;
136:                            }
137:
138:                            outputDirName = parentDirectoryName(outputDirName,
139:                                    dotCount);
140:                            sourceDirName = parentDirectoryName(sourceDirName,
141:                                    dotCount);
142:                        }
143:                    }
144:                }
145:                try {
146:                    if (odmg) {
147:                        makeODMGProxies(classes);
148:                    } else {
149:                        makeProxies(classes);
150:                    }
151:                } catch (Exception e) {
152:                    e.printStackTrace(System.out);
153:                    System.exit(1);
154:                }
155:            }
156:
157:            protected static String parentDirectoryName(String directoryName,
158:                    int dotCount) {
159:                StringBuffer b = new StringBuffer(directoryName);
160:                for (int i = 0; i < dotCount; i++) {
161:                    b.append("..");
162:                    b.append(File.separatorChar);
163:                }
164:
165:                return b.toString();
166:            }
167:
168:            protected static void makeODMGProxies(DxHashSet classes)
169:                    throws Exception {
170:
171:                DxIterator it = classes.iterator();
172:                while (it.next() != null) {
173:                    String name = (String) it.object();
174:
175:                    OPPHelper.progressMsg(name + ":", quiet);
176:
177:                    // create the *_Impl class of the original class
178:                    Class cl = Class.forName(name);
179:                    String newClassName = cl.getName()
180:                            + ObjectContainer.IMPLNAME_POSTFIX;
181:
182:                    ImplManipulator manipulator = new ImplManipulator(cl,
183:                            outputDirName, quiet);
184:                    manipulator.changeClassFile(classes, outputDirName
185:                            + OPPHelper.classFileBasename(cl) + ".class",
186:                            newClassName);
187:
188:                    // generate source and class file of the *_Proxy proxy class
189:                    makeProxy(name);
190:
191:                    // create the *_Impl class of the original class
192:                    cl = Class
193:                            .forName(name + ObjectContainer.PROXYNAME_POSTFIX);
194:                    newClassName = name;
195:                    manipulator.changeClassFile(null, outputDirName
196:                            + OPPHelper.classFileBasename(cl) + ".class",
197:                            newClassName);
198:                }
199:            }
200:
201:            protected static void makeProxies(DxHashSet classes)
202:                    throws Exception {
203:                DxIterator it = classes.iterator();
204:                while (it.next() != null) {
205:                    String name = (String) it.object();
206:
207:                    OPPHelper.progressMsg(name + ":", quiet);
208:
209:                    makeProxy(name);
210:                }
211:            }
212:
213:            protected static void makeODMGProxy(String arg) throws Exception {
214:
215:                // create the *_Impl class of the original class
216:                Class cl = Class.forName(arg);
217:                ImplManipulator manipulator = new ImplManipulator(cl,
218:                        outputDirName, quiet);
219:                String newClassName = cl.getName()
220:                        + ObjectContainer.IMPLNAME_POSTFIX;
221:                manipulator.changeClassFile(null, outputDirName
222:                        + OPPHelper.classFileBasename(cl) + ".class",
223:                        newClassName);
224:
225:                // generate source and class file of the *_Proxy proxy class
226:                makeProxy(arg);
227:
228:                // create the *_Impl class of the original class
229:                cl = Class.forName(arg + ObjectContainer.PROXYNAME_POSTFIX);
230:                manipulator = new ImplManipulator(cl, outputDirName, quiet);
231:                newClassName = arg;
232:                manipulator.changeClassFile(null, outputDirName
233:                        + OPPHelper.classFileBasename(cl) + ".class",
234:                        newClassName);
235:            }
236:
237:            protected static void makeProxy(String arg) throws Exception {
238:                Class cl = Class.forName(arg);
239:
240:                ProxyGenerator generator = new ProxyGenerator(cl,
241:                        methodPattern, outputDirName, quiet, cache);
242:                generator.generateSource(searchInterfaceSource);
243:
244:                if (compileSource) {
245:                    generator.compileSource();
246:                }
247:
248:                if (!keepSource) {
249:                    generator.deleteSource();
250:                }
251:            }
252:
253:            public static void printUsage() {
254:                System.out.println("Ozone Post Processor");
255:                System.out
256:                        .println("usage: opp [-ks] [-st] [-p<pattern>] [-ni] [-nc] [-q] [-h] [-o<directory>] [-odmg] [-ip] class [class]*");
257:                System.out
258:                        .println("   -ks       save the generated source files");
259:                System.out
260:                        .println("   -KS       save the generated source files; do not invoke compiler");
261:                System.out.println("   -st       print stack trace");
262:                System.out
263:                        .println("   -p        regular expression to specify update methods");
264:                System.out
265:                        .println("   -ni       do not search interface code for update methods");
266:                System.out
267:                        .println("   -q        supress output of any messages");
268:                System.out.println("   -o        output directory");
269:                System.out.println("   -s        source directory");
270:                System.out
271:                        .println("   -odmg     create proxies for the ozone ODMG interface");
272:                System.out.println("   -ip       ignore package names");
273:                System.out
274:                        .println("   -nc       do not create code needed for direct invokes and ClientCacheDatabase");
275:                System.out.println("   -version  shows version information");
276:                System.out.println("   -h        shows this help");
277:            }
278:
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.