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


001:        /*
002:
003:        	 Loader - tool for transfering data from one JDBC source to another and 
004:        	 doing transformations during copy.
005:
006:            Copyright (C) 2002  Together
007:
008:            This library is free software; you can redistribute it and/or
009:            modify it under the terms of the GNU Lesser General Public
010:            License as published by the Free Software Foundation; either
011:            version 2.1 of the License, or (at your option) any later version.
012:
013:            This library is distributed in the hope that it will be useful,
014:            but WITHOUT ANY WARRANTY; without even the implied warranty of
015:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:            Lesser General Public License for more details.
017:
018:            You should have received a copy of the GNU Lesser General Public
019:            License along with this library; if not, write to the Free Software
020:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
021:
022:         LoaderTask.java
023:         Date: 15.06.2002.
024:         @version 1.0 
025:         @author: 
026:         Milosevic Sinisa sinisami@eunet.yu
027:         Radeka Dusan diradeka@neobee.net
028:         */
029:
030:        package org.webdocwf.util.loader.task;
031:
032:        import java.io.BufferedReader;
033:        import java.io.InputStreamReader;
034:
035:        import org.apache.tools.ant.BuildException;
036:        import org.apache.tools.ant.Task;
037:
038:        /**
039:         * <p>
040:         * Loader Task class extends jakarta-ant Task class and uses to start Loader 
041:         * application as a jakarta-ant task in build.xml file.
042:         * </p>
043:         * <p>
044:         * Attributes of LoaderTask represents Loader parameters:<br>
045:         * <br>
046:         * loadJobFileName attribute - defines loader job<br>
047:         * mode attribute - defines mode <br>
048:         * restartIndicator attribute - defines restart <br>
049:         * userID attribute - defines user ID <br>
050:         * logDirName attribute - defines log directory <br>
051:         * logFileName attribute - defines log file <br>
052:         * vendorFileName attribute - defines vendor file <br>
053:         * onErrorContinue attribute - defines continue or not on error<br>
054:         * commitCount attribute - defines commit count<br>
055:         * additionalPaths tag - defines single or group of additionalPath tags<br>
056:         * additionalPath tag - defines tag with path attribute <br>
057:         * pathToConfFile attribute - defines path to conf file in jar<br>
058:         * variables tag - defines single or group of variable tags<br>
059:         * variable tag - defines tag with path attribute <br>
060:         * name attribute - defines variable name<br>
061:         * value attribute - defines variable value<br>
062:         * <br>
063:         * </p>
064:         **/
065:        public class LoaderTask extends Task {
066:            private String loadJobFileName;
067:            private String mode;
068:            private String restartIndicator;
069:            private String userID;
070:            private String logDirName;
071:            private String logFileName;
072:            private String vendorFileName;
073:            private String onErrorContinue;
074:            private String commitCount;
075:            private String tableNames;
076:            private String additionalPaths;
077:            private String additionalPath;
078:
079:            private String variables;
080:
081:            private String strLoaderExec = "";
082:
083:            private String returnCode;
084:            private String pathToConfFile;
085:
086:            private String JAVAEXE = "java";
087:            private final String LOADER = "org.webdocwf.util.loader.Loader";
088:
089:            /**
090:             * The method executing the task
091:             **/
092:            public void execute() throws BuildException {
093:
094:                try {
095:                    //find java.exe
096:                    String sep = System.getProperty("file.separator");
097:                    JAVAEXE = System.getProperty("java.home") + sep + "bin"
098:                            + sep + "java";
099:
100:                    if (this .loadJobFileName == null) {
101:                        throw (new BuildException(
102:                                "loadJobFileName attribute must be set! ",
103:                                location));
104:                    } else {
105:
106:                        if (this .additionalPath != null) {
107:                            this .strLoaderExec += "-classpath "
108:                                    + this .additionalPath.substring(0,
109:                                            this .additionalPath.length() - 1)
110:                                    + " ";
111:                        }
112:
113:                        this .strLoaderExec += LOADER + " ";
114:
115:                        if (this .mode != null) {
116:                            if (this .mode.equalsIgnoreCase("none")) {
117:                                this .strLoaderExec += "-m none ";
118:                            } else if (this .mode.equalsIgnoreCase("normal")) {
119:                                this .strLoaderExec += "-m normal ";
120:                            } else if (this .mode.equalsIgnoreCase("full")) {
121:                                this .strLoaderExec += "-m full ";
122:                            }
123:                        }
124:                        if (this .restartIndicator != null
125:                                && this .restartIndicator
126:                                        .equalsIgnoreCase("yes")) {
127:                            this .strLoaderExec += "-r ";
128:                        }
129:
130:                        if (this .userID != null) {
131:                            this .strLoaderExec += "-u " + this .userID + " ";
132:                        }
133:
134:                        if (this .variables != null) {
135:                            if (this .variables.endsWith(";"))
136:                                this .variables = this .variables.substring(0,
137:                                        this .variables.length() - 1);
138:                            this .strLoaderExec += "-v " + this .variables + " ";
139:                        }
140:
141:                        if (this .logDirName != null) {
142:                            this .strLoaderExec += "-l " + this .logDirName + " ";
143:                        }
144:
145:                        if (this .logFileName != null) {
146:                            this .strLoaderExec += "-f " + this .logFileName
147:                                    + " ";
148:                        }
149:
150:                        if (this .vendorFileName != null) {
151:                            this .strLoaderExec += "-d " + this .vendorFileName
152:                                    + " ";
153:                        }
154:
155:                        if (this .onErrorContinue != null
156:                                && this .onErrorContinue
157:                                        .equalsIgnoreCase("true")) {
158:                            this .strLoaderExec += "-e ";
159:                        }
160:
161:                        if (this .commitCount != null) {
162:                            this .strLoaderExec += "-c " + this .commitCount
163:                                    + " ";
164:                        }
165:                        if (this .returnCode != null) {
166:                            this .strLoaderExec += "-rc " + this .returnCode
167:                                    + " ";
168:                        }
169:                        if (this .pathToConfFile != null) {
170:                            this .strLoaderExec += "-cjs " + this .pathToConfFile
171:                                    + " ";
172:                        }
173:                        if (this .tableNames != null) {
174:                            if (this .tableNames.endsWith(";"))
175:                                this .tableNames = this .tableNames.substring(0,
176:                                        this .tableNames.length() - 1);
177:                            this .strLoaderExec += "-it " + this .tableNames
178:                                    + " ";
179:                        }
180:
181:                        this .strLoaderExec += this .loadJobFileName;
182:
183:                        String command = JAVAEXE + " " + this .strLoaderExec;
184:                        Process process = Runtime.getRuntime().exec(command);
185:                        java.io.InputStream inputstream = process
186:                                .getInputStream();
187:                        BufferedReader bufferedreader = new BufferedReader(
188:                                new InputStreamReader(inputstream));
189:                        java.io.InputStream inputstream1 = process
190:                                .getErrorStream();
191:                        BufferedReader bufferedreader1 = new BufferedReader(
192:                                new InputStreamReader(inputstream1));
193:                        (new ErrorReader(bufferedreader1)).start();
194:                        String s1;
195:                        while ((s1 = bufferedreader.readLine()) != null) {
196:                            System.out.println(s1);
197:
198:                        }
199:                        int k = process.waitFor();
200:                        if (k != 0)
201:                            throw (new BuildException("Loader: Error occured!",
202:                                    location));
203:                    }
204:                } catch (Throwable le) {
205:                    System.out.println(le);
206:                }
207:
208:            }
209:
210:            /**
211:             *  The setter for the "loadJob" attribute
212:             **/
213:            public void setLoadJob(String msg) {
214:                this .loadJobFileName = msg;
215:            }
216:
217:            /**
218:             * The setter for the "mode" attribute
219:             **/
220:            public void setMode(String msg) {
221:                this .mode = msg;
222:            }
223:
224:            /**
225:             * The setter for the "userID" attribute
226:             **/
227:            public void setUserID(String msg) {
228:                this .userID = msg;
229:            }
230:
231:            /**
232:             * The setter for the "logDir" attribute
233:             **/
234:            public void setLogDir(String msg) {
235:                this .logDirName = msg;
236:            }
237:
238:            /**
239:             * The setter for the "logFile" attribute
240:             **/
241:            public void setLogFile(String msg) {
242:                this .logFileName = msg;
243:            }
244:
245:            /**
246:             * The setter for the "restartIndicator" attribute
247:             **/
248:            public void setRestartIndicator(String msg) {
249:                this .restartIndicator = msg;
250:            }
251:
252:            /**
253:             * The setter for the "vendorFile" attribute
254:             **/
255:            public void setVendorFile(String msg) {
256:                this .vendorFileName = msg;
257:            }
258:
259:            /**
260:             * The setter for the "onErrorContinue" attribute
261:             **/
262:            public void setOnErrorContinue(String msg) {
263:                this .onErrorContinue = msg;
264:            }
265:
266:            /**
267:             * The setter for the "commitCount" attribute
268:             **/
269:            public void setCommitCount(String msg) {
270:                this .commitCount = msg;
271:            }
272:
273:            /**
274:             * The setter for the "returnCode" attribute
275:             **/
276:            public void setReturnCode(String rc) {
277:                this .returnCode = rc;
278:            }
279:
280:            /**
281:             * The setter for the "AdditionalPaths" tag
282:             **/
283:            public void addConfiguredAdditionalPaths(AdditionalPaths anInner) {
284:                this .additionalPath = anInner.additionalPaths.substring(0,
285:                        anInner.additionalPaths.indexOf("null"))
286:                        + anInner.additionalPaths.substring(
287:                                anInner.additionalPaths.indexOf("null") + 4,
288:                                anInner.additionalPaths.length());
289:            }
290:
291:            /**
292:             * The setter for the "Variables" tag
293:             **/
294:            public void addConfiguredVariables(Variables anInner) {
295:                this .variables = anInner.variables.substring(0,
296:                        anInner.variables.indexOf("null"))
297:                        + anInner.variables.substring(anInner.variables
298:                                .indexOf("null") + 4, anInner.variables
299:                                .length());
300:            }
301:
302:            /**
303:             * The setter for the "pathToConfFile" attribute
304:             */
305:            public void setPathToConfFile(String string) {
306:                this .pathToConfFile = string;
307:            }
308:
309:            /**
310:             * The setter for the "tableNames" attribute
311:             */
312:            public void setTableNames(String string) {
313:                this.tableNames = string;
314:            }
315:
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.