Source Code Cross Referenced for OctopusLoaderThread.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » loader » wizard » 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 JDBC Connection Pool » octopus » org.webdocwf.util.loader.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:             LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003:            Copyright (C) 2003  Together
004:            This library is free software; you can redistribute it and/or
005:            modify it under the terms of the GNU Lesser General Public
006:            License as published by the Free Software Foundation; either
007:            version 2.1 of the License, or (at your option) any later version.
008:            This library is distributed in the hope that it will be useful,
009:            but WITHOUT ANY WARRANTY; without even the implied warranty of
010:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011:            Lesser General Public License for more details.
012:            You should have received a copy of the GNU Lesser General Public
013:            License along with this library; if not, write to the Free Software
014:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
015:         */
016:
017:        package org.webdocwf.util.loader.wizard;
018:
019:        import java.util.HashMap;
020:        import java.util.Map;
021:        import java.util.StringTokenizer;
022:
023:        import javax.swing.JTextArea;
024:
025:        import org.webdocwf.util.loader.BufferOctopusClass;
026:        import org.webdocwf.util.loader.Loader;
027:        import org.webdocwf.util.loader.LoaderException;
028:        import org.webdocwf.util.loader.ReturnCode;
029:
030:        /**
031:         * ExecOctopusThread class execute thread which control Octopus application
032:         * @author Radoslav Dutina
033:         * @version 1.0
034:         */
035:        public class OctopusLoaderThread extends Thread {
036:            private OctopusLoaderData initData;
037:            //  TraceDialog td = null; //trace dialog of this Thread
038:            private JTextArea td;
039:            private String errorMsg = null;
040:
041:            /**
042:             * Construct the objecto of ExecOctopusThread class with associated parameters
043:             * @param traceArea is desktop frame of wizard application
044:             * @param initData is object which contain input parameters of wizard application
045:             * @param errorMsg is error message
046:             */
047:            public OctopusLoaderThread(OctopusLoaderData initData,
048:                    String errorMsg, JTextArea traceArea) {
049:                this .initData = initData;
050:                this .errorMsg = errorMsg;
051:                td = traceArea;
052:                //    desktop.add(td);
053:            }
054:
055:            /**
056:             * This method append line in to trace area
057:             * @param s is value which to be set
058:             */
059:            public void appendLine(String s) {
060:                td.append(s);
061:                td.getCaret().setDot(td.getText().length() - 1);
062:            }
063:
064:            /**
065:             * Run the thread
066:             */
067:            public void run() {
068:                td.setVisible(true);
069:                //    td.setDefaultFocus();
070:                if (errorMsg != null) {
071:                    appendLine(errorMsg + "\n");
072:                    //      td.setButtonEnabled();
073:                    //      td.setButtonName("Open");
074:
075:                } else {
076:                    OctopusLoader octopus = null;
077:                    OctopusThread octopusThread = null;
078:                    try {
079:                        octopus = new OctopusLoader(initData);
080:                        String[] process = octopus.generateAll();
081:                        if (process.length != 0) {
082:                            BufferOctopusClass.getInstance();
083:                            BufferOctopusClass.getInstance().setUsed();
084:
085:                            octopusThread = new OctopusThread(process);
086:                            octopusThread.start();
087:
088:                            while (octopusThread.isAlive()) {
089:                                String value = BufferOctopusClass.getInstance()
090:                                        .readFromBuffer();
091:                                if (value.indexOf("***TogetherGroop***") == -1)
092:                                    appendLine(value + "\n");
093:                                else
094:                                    break;
095:                            }
096:                            //          setButtonEnabled();
097:                        } else {
098:                            appendLine("Some error is occur! " + "\n"
099:                                    + "Application build fails!");
100:                        }
101:
102:                        //        setButtonName("Open");
103:                        //        td.setTitle("Building TDT Application(Done)");
104:                    } catch (Exception e) {
105:                        //        td.setTitle("Building TDT Application(ERROR)");
106:                        String message = e.getMessage();
107:                        if (message.indexOf(-1) != -1
108:                                || message.indexOf(0) != -1)
109:                            message = "Application build fails!";
110:
111:                        BufferOctopusClass.getInstance().writeToBuffer(
112:                                message + "\n");
113:                        BufferOctopusClass.getInstance().writeToBuffer(
114:                                "***TogetherGroop***");
115:                        BufferOctopusClass.getInstance().empty();
116:                        //        td.setButtonEnabled();
117:                        //        td.setButtonName("Open");
118:                        e.printStackTrace(System.out);
119:                    }
120:                    BufferOctopusClass.getInstance().empty();
121:                }
122:            }
123:
124:            /**
125:             * This class creates new thread
126:             */
127:            class OctopusThread extends Thread {
128:                private String[] args;
129:
130:                /**
131:                 * Initialise the thread
132:                 * @param args represents the arguments
133:                 */
134:                public OctopusThread(String[] args) {
135:                    this .args = args;
136:                }
137:
138:                /**
139:                 * Run the thread
140:                 */
141:                public void run() {
142:                    String loadJobFileName = null;
143:                    String mode = null;
144:                    String userID = null;
145:                    String logDirName = null;
146:                    String logFileName = null;
147:                    boolean restartIndicator = false;
148:                    Map variableValues = null;
149:                    String strVariableValues = null;
150:                    String vendorFileName = null;
151:                    boolean onErrorContinue = false;
152:                    String additionalPaths = null;
153:                    String includeTables[] = null;
154:                    String confJarStructure = null;
155:                    int defaultReturnCode = 1;
156:                    int commitCount = 100;
157:                    if (args.length > 0 && args.length < 24) {
158:                        loadJobFileName = args[args.length - 1];
159:                        for (int i = 0; i < args.length - 1; i = i + 1) {
160:                            if (args[i].equalsIgnoreCase("-m"))
161:                                mode = args[++i];
162:                            else if (args[i].equalsIgnoreCase("-r"))
163:                                restartIndicator = true;
164:                            else if (args[i].equalsIgnoreCase("-u"))
165:                                userID = args[++i];
166:                            else if (args[i].equalsIgnoreCase("-l"))
167:                                logDirName = args[++i];
168:                            else if (args[i].equalsIgnoreCase("-f"))
169:                                logFileName = args[++i];
170:                            else if (args[i].equalsIgnoreCase("-d"))
171:                                vendorFileName = args[++i];
172:                            else if (args[i].equalsIgnoreCase("-e")) {
173:                                String value = args[++i];
174:                                if (value.equalsIgnoreCase("true"))
175:                                    onErrorContinue = true;
176:                                else
177:                                    onErrorContinue = false;
178:                            } else if (args[i].equalsIgnoreCase("-p"))
179:                                additionalPaths = args[++i];
180:                            else if (args[i].equalsIgnoreCase("-c"))
181:                                commitCount = (new Integer(args[++i]))
182:                                        .intValue();
183:                            else if (args[i].equalsIgnoreCase("-v")) {
184:                                strVariableValues = args[++i];
185:                                variableValues = new HashMap(
186:                                        convertToMap(strVariableValues));
187:                            } else if (args[i].equalsIgnoreCase("-rc")) {
188:                                defaultReturnCode = (new Integer(args[++i]))
189:                                        .intValue();
190:                                ReturnCode.isParameter = true;
191:                            } else if (args[i].equalsIgnoreCase("-cjs"))
192:                                confJarStructure = args[++i];
193:                            else if (args[i].equalsIgnoreCase("-it")) {
194:                                String array = args[++i];
195:                                StringTokenizer st = new StringTokenizer(array,
196:                                        ";");
197:                                includeTables = new String[st.countTokens()];
198:                                int pos = 0;
199:                                while (st.hasMoreTokens()) {
200:                                    includeTables[pos] = st.nextToken();
201:                                    pos++;
202:                                }
203:                            }
204:                        }
205:                    } else
206:                        printUsage();
207:                    Loader l = new Loader(loadJobFileName, mode, userID,
208:                            logDirName, logFileName, restartIndicator,
209:                            variableValues, vendorFileName, onErrorContinue,
210:                            additionalPaths, commitCount, defaultReturnCode,
211:                            includeTables, confJarStructure);
212:
213:                    try {
214:                        l.load();
215:                    } catch (LoaderException le) {
216:                        //        td.setTitle("Building TDT Application(ERROR)");
217:                        //        td.setButtonEnabled();
218:                        //        td.setButtonName("Open");
219:                        BufferOctopusClass.getInstance().writeToBuffer(
220:                                "LoaderException: " + "\n");
221:                        BufferOctopusClass.getInstance().writeToBuffer(
222:                                le.getStackTraceAsString() + "\n");
223:                        try {
224:                            Thread.sleep(100);
225:                            BufferOctopusClass.getInstance().writeToBuffer(
226:                                    "***TogetherGroop***");
227:                        } catch (Exception ex) {
228:                            appendLine(ex.getMessage());
229:                        }
230:                        l = null;
231:                        return;
232:                    } catch (Throwable th) {
233:                        //        td.setTitle("Building TDT Application(ERROR)");
234:                        //        td.setButtonEnabled();
235:                        //        td.setButtonName("Open");
236:                        BufferOctopusClass.getInstance().writeToBuffer(
237:                                th.getMessage());
238:                        try {
239:                            Thread.sleep(100);
240:                            BufferOctopusClass.getInstance().writeToBuffer(
241:                                    "***TogetherGroop***");
242:                        } catch (Exception ex) {
243:                            appendLine(ex.getMessage());
244:                        }
245:                        th.printStackTrace(System.out);
246:                        l = null;
247:                        return;
248:                    }
249:                    try {
250:                        Thread.sleep(1000);
251:                        BufferOctopusClass.getInstance().writeToBuffer(
252:                                "***TogetherGroop***");
253:                    } catch (Exception ex) {
254:                        appendLine(ex.getMessage());
255:                    }
256:                    l = null;
257:                    return;
258:                }
259:
260:                /**
261:                 * put your documentation comment here
262:                 */
263:                public void printUsage() {
264:                    System.out
265:                            .println("Usage: java org.webdocwf.util.loader.Loader [options] loadJob_xml_filename");
266:                    BufferOctopusClass
267:                            .getInstance()
268:                            .writeToBuffer(
269:                                    "Usage: java org.webdocwf.util.loader.Loader [options] loadJob_xml_filename");
270:                    System.out.println(" Options:");
271:                    BufferOctopusClass.getInstance().writeToBuffer(" Options:");
272:                    System.out
273:                            .println(" -m defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
274:                    BufferOctopusClass
275:                            .getInstance()
276:                            .writeToBuffer(
277:                                    " -m defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
278:                    System.out
279:                            .println(" -r starts the Loader in restart mode after abnormal termination in a prior execution. \n");
280:                    BufferOctopusClass
281:                            .getInstance()
282:                            .writeToBuffer(
283:                                    " -r starts the Loader in restart mode after abnormal termination in a prior execution. \n");
284:                    System.out
285:                            .println(" -u defines the current UserID used in UserID value columns. \n");
286:                    BufferOctopusClass
287:                            .getInstance()
288:                            .writeToBuffer(
289:                                    " -u defines the current UserID used in UserID value columns. \n");
290:                    System.out
291:                            .println(" -v defines variables used in variable columns.  \n");
292:                    BufferOctopusClass
293:                            .getInstance()
294:                            .writeToBuffer(
295:                                    " -v defines variables used in variable columns.  \n");
296:                    System.out
297:                            .println(" -l defines the logfile directory. The default is the current working directory.   \n");
298:                    BufferOctopusClass
299:                            .getInstance()
300:                            .writeToBuffer(
301:                                    " -v defines variables used in variable columns.  \n");
302:                    System.out
303:                            .println(" -f defines the logfile name. The default is 'LoaderLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
304:                    BufferOctopusClass
305:                            .getInstance()
306:                            .writeToBuffer(
307:                                    " -f defines the logfile name. The default is 'LoaderLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
308:                    System.out
309:                            .println(" -d the filename of the XML DB-vendor configuration file. The default is 'OctopusDBVendors.xml'. \n");
310:                    BufferOctopusClass
311:                            .getInstance()
312:                            .writeToBuffer(
313:                                    " -d the filename of the XML DB-vendor configuration file. The default is 'OctopusDBVendors.xml'. \n");
314:                    System.out
315:                            .println(" -e defines to set the default of 'onErrorContinue' to 'true'. Is false otherwise. \n");
316:                    BufferOctopusClass
317:                            .getInstance()
318:                            .writeToBuffer(
319:                                    " -e defines to set the default of 'onErrorContinue' to 'true'. Is false otherwise. \n");
320:                    System.out
321:                            .println(" -p Extend the classpath with additional paths \n");
322:                    BufferOctopusClass
323:                            .getInstance()
324:                            .writeToBuffer(
325:                                    " -p Extend the classpath with additional paths \n");
326:                    System.out
327:                            .println(" -c Sets the default commit count. System default is '100'.  \n");
328:                    BufferOctopusClass
329:                            .getInstance()
330:                            .writeToBuffer(
331:                                    " -c Sets the default commit count. System default is '100'.  \n");
332:                    System.out
333:                            .println(" -rc Sets the default error return code. System default is '1'.  \n");
334:                    BufferOctopusClass
335:                            .getInstance()
336:                            .writeToBuffer(
337:                                    " -rc Sets the default error return code. System default is '1'.  \n");
338:                    System.out
339:                            .println(" -it Sets the table names which will be proccesed ");
340:                    BufferOctopusClass
341:                            .getInstance()
342:                            .writeToBuffer(
343:                                    " -it Sets the table names which will be proccesed ");
344:
345:                }
346:
347:                /**
348:                 * put your documentation comment here
349:                 * @param values represents map values
350:                 * @return those values
351:                 */
352:                private Map convertToMap(String values) {
353:                    Map mapValues = new HashMap();
354:                    int i = values.indexOf(";");
355:                    int k = 0;
356:                    String part = new String(values);
357:                    if (i != -1) {
358:                        while (i != -1) {
359:                            part = new String(values.substring(k, k + i));
360:                            int j = part.indexOf("=");
361:                            String strObject = part.substring(0, j);
362:                            String strValue = part.substring(j + 1);
363:                            if (strValue.equals(""))
364:                                strValue = null;
365:                            mapValues.put(strObject, strValue);
366:                            k += i + 1;
367:                            i = values.substring(k).indexOf(";");
368:                        }
369:                        if (!(values.substring(k).trim().equals("") || values
370:                                .substring(k).trim().equals(";"))) {
371:                            part = new String(values.substring(k));
372:                            int j = part.indexOf("=");
373:                            String strObject = part.substring(0, j);
374:                            String strValue = part.substring(j + 1);
375:                            if (strValue.equals(""))
376:                                strValue = null;
377:                            mapValues.put(strObject, strValue);
378:                        }
379:                    } else {
380:                        int j = values.indexOf("=");
381:                        String strObject = values.substring(k, j);
382:                        String strValue = values.substring(j + 1);
383:                        if (strValue.equals(""))
384:                            strValue = null;
385:                        mapValues.put(strObject, strValue);
386:                    }
387:                    return mapValues;
388:                }
389:            }
390:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.