Source Code Cross Referenced for Script.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ant » cluster » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.ant.cluster 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer: Benoit Pelletier
022:         * --------------------------------------------------------------------------
023:         * $Id: Script.java 9719 2006-10-11 09:45:08Z pelletib $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.ant.cluster;
026:
027:        import java.io.File;
028:
029:        //import org.apache.tools.ant.taskdefs.Chmod;
030:        import org.objectweb.common.Env;
031:        import org.objectweb.jonas.ant.jonasbase.JEcho;
032:        import org.objectweb.jonas.ant.jonasbase.JMkdir;
033:        import org.objectweb.jonas.ant.jonasbase.JTouch;
034:
035:        /**
036:         * Allow to launch the cluster nodes
037:         * @author Benoit Pelletier
038:         */
039:        public class Script extends ClusterTasks {
040:
041:            /**
042:             * Info for the logger
043:             */
044:            private static final String INFO = "[Script] ";
045:
046:            /**
047:             * Name of the unix script file
048:             */
049:            private static final String UNIX_SCRIPT_FILE = "jcl4sc2";
050:
051:            /**
052:             * Name of the unix script file
053:             */
054:            private static final String WIN_SCRIPT_FILE = "jcl4sc2.bat";
055:
056:            /**
057:             * Script file Unix
058:             */
059:            private File unixScriptFile = null;
060:
061:            /**
062:             * Script file
063:             */
064:            private File winScriptFile = null;
065:
066:            /**
067:             * domain name
068:             */
069:            private String domainName = null;
070:
071:            /**
072:             * node name prefix
073:             */
074:            private String nodeNamePrefix = null;
075:
076:            /**
077:             * script dir
078:             */
079:            private String scriptDir = null;
080:
081:            /**
082:             * nodes nb
083:             */
084:            private int instNb = 0;
085:
086:            /**
087:             * cluster daemon directory
088:             */
089:            private String cdDir = null;
090:
091:            /**
092:             * db directory
093:             */
094:            private String dbDir = null;
095:
096:            /**
097:             * db instance name
098:             */
099:            private String dbName = null;
100:
101:            /**
102:             * master directory
103:             */
104:            private String masterDir = null;
105:
106:            /**
107:             * master instance name
108:             */
109:            private String masterName = null;
110:
111:            /**
112:             * Default constructor
113:             */
114:            public Script() {
115:                super ();
116:            }
117:
118:            /**
119:             * Creation of the script files
120:             * @param destDir destination directory
121:             */
122:            public void createFiles(String destDir) {
123:                JMkdir mkdir = new JMkdir();
124:                mkdir.setDestDir(new File(destDir));
125:                addTask(mkdir);
126:
127:                // depending the os, the unix or the windows script is created
128:                if (Env.isOsWindows()) {
129:                    JTouch touchWin = new JTouch();
130:                    winScriptFile = new File(destDir + "/" + WIN_SCRIPT_FILE);
131:                    touchWin.setDestDir(winScriptFile);
132:                    addTask(touchWin);
133:
134:                } else {
135:                    JTouch touchUnix = new JTouch();
136:                    unixScriptFile = new File(destDir + "/" + UNIX_SCRIPT_FILE);
137:                    touchUnix.setDestDir(unixScriptFile);
138:                    addTask(touchUnix);
139:
140:                }
141:            }
142:
143:            /**
144:             * creation of the unix file
145:             */
146:            private void flushUnixScriptFile() {
147:                JEcho echo = new JEcho();
148:                echo.setDestDir(unixScriptFile);
149:
150:                String contentFile = "\n"
151:                        + "# -----------------------------------------------------------"
152:                        + "\n"
153:                        + "# start/stop/kill the cluster nodes"
154:                        + "\n"
155:                        + "# Note : "
156:                        + "\n"
157:                        + "#   - JONAS_ROOT has to be set"
158:                        + "\n"
159:                        + "#   - XWINDOWS can be set to 'yes' for starting the process in xterm"
160:                        + "\n"
161:                        + "# -----------------------------------------------------------"
162:                        + "\n" + "\n" + "JCL_NUMBER_OF_NODES="
163:                        + this .instNb
164:                        + "\n"
165:                        + "\n"
166:                        + "JCL_CLUSTER_DAEMON_DIR="
167:                        + this .cdDir
168:                        + "\n"
169:                        + "JCL_BASE_PREFIX="
170:                        + this .getDestDirPrefix()
171:                        + "\n"
172:                        + "\n"
173:                        + "JCL_NODE_NAME_PREFIX="
174:                        + this .nodeNamePrefix
175:                        + "\n"
176:                        + "JCL_DOMAIN_NAME="
177:                        + this .domainName
178:                        + "\n"
179:                        + "\n"
180:                        + "JCL_EAR_FILE=$JONAS_ROOT/examples/sampleCluster2/output/apps/sampleCluster2.ear"
181:                        + "\n"
182:                        + "JCL_HA_EAR_FILE=$JONAS_ROOT/examples/sampleCluster2/output/apps/haTransactions.ear"
183:                        + "\n"
184:                        + "\n"
185:                        + "JCL_DB_DIR="
186:                        + this .dbDir
187:                        + "\n"
188:                        + "JCL_DB_NAME="
189:                        + this .dbName
190:                        + "\n"
191:                        + "\n"
192:                        + "JCL_MASTER_DIR="
193:                        + this .masterDir
194:                        + "\n"
195:                        + "JCL_MASTER_NAME="
196:                        + this .masterName
197:                        + "\n"
198:                        + "\n"
199:                        + "export JCL_MASTER_NAME JCL_MASTER_DIR JCL_DB_NAME JCL_DB_DIR JCL_HA_EAR_FILE JCL_EAR_FILE JCL_DOMAIN_NAME JCL_NODE_NAME_PREFIX"
200:                        + "\n"
201:                        + "export JCL_NUMBER_OF_NODES JCL_CLUSTER_DAEMON_DIR JCL_BASE_PREFIX"
202:                        + "\n"
203:                        + "$JONAS_ROOT/examples/sampleCluster2/scripts/jcl.sh $*"
204:                        + "\n";
205:
206:                echo.setMessage(contentFile);
207:                echo.setLogInfo(INFO + "Flushing Configuration in '"
208:                        + unixScriptFile + "'");
209:                addTask(echo);
210:            }
211:
212:            /**
213:             * creation of the windows file
214:             */
215:            private void flushWinScriptFile() {
216:                JEcho echo = new JEcho();
217:                echo.setDestDir(winScriptFile);
218:
219:                String contentFile = "\n" + "@echo off" + "\n"
220:                        + ":: -----------------------" + "\n"
221:                        + ":: start/stop the cluster nodes" + "\n"
222:                        + ":: Note : JONAS_ROOT has to be set" + "\n"
223:                        + ":: -----------------------" + "\n"
224:                        + "set JCL_NUMBER_OF_NODES="
225:                        + this .instNb
226:                        + "\n"
227:                        + "set JCL_BASE_PREFIX="
228:                        + this .getDestDirPrefix().replace('/', '\\')
229:                        + "\n"
230:                        + "set JCL_DOMAIN_NAME="
231:                        + this .domainName
232:                        + "\n"
233:                        + "set JCL_EAR_FILE=%JONAS_ROOT%\\examples\\sampleCluster2\\output\\apps\\sampleCluster2.ear"
234:                        + "\n"
235:                        + "set JCL_HA_EAR_FILE=%JONAS_ROOT%\\examples\\sampleCluster2\\output\\apps\\haTransactions.ear"
236:                        + "\n"
237:                        + "set JCL_NODE_NAME_PREFIX="
238:                        + this .nodeNamePrefix
239:                        + "\n"
240:                        + "set JCL_CLUSTER_DAEMON_DIR="
241:                        + this .cdDir
242:                        + "\n"
243:                        + "set JCL_DB_DIR="
244:                        + this .dbDir
245:                        + "\n"
246:                        + "set JCL_DB_NAME="
247:                        + this .dbName
248:                        + "\n"
249:                        + "set JCL_MASTER_DIR="
250:                        + this .masterDir
251:                        + "\n"
252:                        + "set JCL_MASTER_NAME="
253:                        + this .masterName
254:                        + "\n"
255:                        + "%JONAS_ROOT%\\examples\\sampleCluster2\\scripts\\jcl.bat %*"
256:                        + "\n";
257:
258:                echo.setMessage(contentFile);
259:                echo.setLogInfo(INFO + "Flushing Configuration in '"
260:                        + winScriptFile + "'");
261:                addTask(echo);
262:            }
263:
264:            /**
265:             * Generation of the config files
266:             */
267:            public void flushFiles() {
268:                flushUnixScriptFile();
269:                flushWinScriptFile();
270:            }
271:
272:            /**
273:             * Set domainName
274:             * @param domainName domain name
275:             */
276:            public void setDomainName(String domainName) {
277:                this .domainName = domainName;
278:            }
279:
280:            /**
281:             * Set nodeNamePrefix
282:             * @param nodeNamePrefix node name prefix
283:             */
284:            public void setNodeNamePrefix(String nodeNamePrefix) {
285:                this .nodeNamePrefix = nodeNamePrefix;
286:            }
287:
288:            /**
289:             * Set script directory
290:             * @param scriptDir Script directory
291:             */
292:            public void setScriptDir(String scriptDir) {
293:                this .scriptDir = scriptDir;
294:            }
295:
296:            /**
297:             * Set nodes number
298:             * @param instNb nodes nb
299:             */
300:            public void setInstNb(int instNb) {
301:                this .instNb = instNb;
302:            }
303:
304:            /**
305:             * cluster daemon directory
306:             * @param cdDir directory
307:             */
308:            public void setCdDir(String cdDir) {
309:                this .cdDir = cdDir;
310:                if (File.separatorChar == '/') {
311:                    this .cdDir = this .cdDir.replace('\\', File.separatorChar);
312:                } else {
313:                    this .cdDir = this .cdDir.replace('/', File.separatorChar);
314:                }
315:            }
316:
317:            /**
318:             * db instance directory
319:             * @param dbDir directory
320:             */
321:            public void setDbDir(String dbDir) {
322:                this .dbDir = dbDir;
323:                if (File.separatorChar == '/') {
324:                    this .dbDir = this .dbDir.replace('\\', File.separatorChar);
325:                } else {
326:                    this .dbDir = this .dbDir.replace('/', File.separatorChar);
327:                }
328:            }
329:
330:            /**
331:             * db instance name
332:             * @param dbName name
333:             */
334:            public void setDbName(String dbName) {
335:                this .dbName = dbName;
336:            }
337:
338:            /**
339:             * master instance directory
340:             * @param dbDir directory
341:             */
342:            public void setMasterDir(String masterDir) {
343:                this .masterDir = masterDir;
344:                if (File.separatorChar == '/') {
345:                    this .masterDir = this .masterDir.replace('\\',
346:                            File.separatorChar);
347:                } else {
348:                    this .masterDir = this .masterDir.replace('/',
349:                            File.separatorChar);
350:                }
351:            }
352:
353:            /**
354:             * master instance name
355:             * @param dbName name
356:             */
357:            public void setMasterName(String masterName) {
358:                this .masterName = masterName;
359:            }
360:
361:            /**
362:             * Generates the script tasks
363:             */
364:            public void generatesTasks() {
365:
366:                // creation of the Script tasks
367:                createFiles(scriptDir);
368:                flushFiles();
369:            }
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.