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


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2004 Bull S.A.
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: Florent BENOIT
022:         * --------------------------------------------------------------------------
023:         * $Id: BootstrapTask.java 8647 2006-06-16 13:26:10Z duvauchn $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.ant;
026:
027:        import java.io.File;
028:
029:        import org.apache.tools.ant.BuildException;
030:        import org.apache.tools.ant.Task;
031:        import org.apache.tools.ant.taskdefs.Java;
032:        import org.apache.tools.ant.types.Path;
033:
034:        /**
035:         * Allow to use the BootStrap class <br/>It allows to do some operations like
036:         * <ul><li>starting/stopping JOnAS</li><li>Deploying some apps</li><li>
037:         * etc... </li</ul>
038:         * @author Florent Benoit
039:         */
040:        public abstract class BootstrapTask extends Task {
041:
042:            /**
043:             * Bootstrap class name
044:             */
045:            private static final String BOOTSTRAP_CLASS = "org.objectweb.jonas.server.Bootstrap";
046:
047:            /**
048:             * Default JOnAS server name
049:             */
050:            private static final String DEFAULT_SERVER_NAME = "jonas";
051:
052:            /**
053:             * Name of the task (to be displayed in log : default to JOnAS)
054:             */
055:            private String taskName = "JOnAS";
056:
057:            /**
058:             * JOnAS Root
059:             */
060:            private File jonasRoot = null;
061:
062:            /**
063:             * Name of the server (default 'jonas')
064:             */
065:            private String serverName = DEFAULT_SERVER_NAME;
066:
067:            /**
068:             * Name of the server (default 'jonas')
069:             */
070:            private String domainName = null;
071:
072:            /**
073:             * JOnAS Base
074:             */
075:            private File jonasBase = null;
076:
077:            /**
078:             * Catalina Home
079:             */
080:            private String catalinaHome = null;
081:
082:            /**
083:             * Jetty home
084:             */
085:            private String jettyHome = null;
086:
087:            /**
088:             * Options given to the JVM
089:             */
090:            private String jvmOpts = null;
091:
092:            /**
093:             * Classpath used for this task
094:             */
095:            private Path classpath = null;
096:
097:            /**
098:             * Set the JOnAS root directory.
099:             * @param jonasRoot the JOnAS root directory.
100:             */
101:            public void setJonasRoot(File jonasRoot) {
102:                this .jonasRoot = jonasRoot;
103:            }
104:
105:            /**
106:             * Set the JOnAS base directory.
107:             * @param jonasBase the JOnAS base directory.
108:             */
109:            public void setJonasbase(File jonasBase) {
110:                this .jonasBase = jonasBase;
111:            }
112:
113:            /**
114:             * Set the additional args to pass to the JVM.
115:             * @param jvmOpts the options.
116:             */
117:            public void setJvmopts(String jvmOpts) {
118:                this .jvmOpts = jvmOpts;
119:            }
120:
121:            /**
122:             * Adds to the classpath the class of the project
123:             * @return the path to be configured.
124:             */
125:            public Path createClasspath() {
126:                return new Path(getProject());
127:            }
128:
129:            /**
130:             * Set the classpath for this task
131:             * @param classpath the classpath to use.
132:             */
133:            public void setClasspath(Path classpath) {
134:                this .classpath = classpath;
135:            }
136:
137:            /**
138:             * Run the task
139:             * @see org.apache.tools.ant.Task#execute()
140:             */
141:            protected Java getBootstraptask(String definedClass) {
142:
143:                if (jonasRoot == null) {
144:                    // get ant property
145:                    String jr = getProject().getProperty("jonas.root");
146:                    jonasRoot = new File(jr);
147:
148:                    if (jr == null) {
149:                        throw new BuildException(
150:                                "attribute jonasroot is necessary.");
151:                    }
152:                }
153:
154:                if (jonasBase == null) {
155:                    jonasBase = jonasRoot;
156:                }
157:
158:                Java bootstrapTask = (Java) getProject().createTask("java");
159:                bootstrapTask.setTaskName(taskName);
160:                bootstrapTask.setFork(true);
161:                bootstrapTask.setFailonerror(true);
162:
163:                // Name of the server
164:                bootstrapTask.createJvmarg().setValue(
165:                        "-Djonas.name=" + serverName);
166:
167:                // Name of the domain
168:                if (domainName != null) {
169:                    bootstrapTask.createJvmarg().setValue(
170:                            "-Ddomain.name=" + domainName);
171:                }
172:
173:                // jonas root
174:                bootstrapTask.createJvmarg().setValue(
175:                        "-Dinstall.root=" + jonasRoot);
176:
177:                // jonas base
178:                bootstrapTask.createJvmarg().setValue(
179:                        "-Djonas.base=" + jonasBase);
180:
181:                // set headless (for unix without X running)
182:                bootstrapTask.createJvmarg().setValue(
183:                        "-Djava.awt.headless=true");
184:
185:                // Properties of JVM
186:                bootstrapTask.createJvmarg().setValue(
187:                        "-Djonas.default.classloader=true");
188:                bootstrapTask.createJvmarg().setValue("-Djonas.classpath=");
189:                bootstrapTask
190:                        .createJvmarg()
191:                        .setValue(
192:                                "-Djava.naming.factory.initial=org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
193:
194:                // iiop
195:                bootstrapTask.createJvmarg().setValue(
196:                        "-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB");
197:                bootstrapTask
198:                        .createJvmarg()
199:                        .setValue(
200:                                "-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton");
201:                bootstrapTask
202:                        .createJvmarg()
203:                        .setValue(
204:                                "-Dorg.omg.PortableInterceptor.ORBInitializerClass.standard_init=org.jacorb.orb.standardInterceptors.IORInterceptorInitializer");
205:
206:                File jonasLibDir = new File(jonasRoot, "lib");
207:                File jonasLibEndorsedDir = new File(jonasLibDir, "endorsed");
208:                bootstrapTask
209:                        .createJvmarg()
210:                        .setValue(
211:                                "-Djavax.rmi.CORBA.PortableRemoteObjectClass=org.objectweb.carol.rmi.multi.MultiPRODelegate");
212:                bootstrapTask
213:                        .createJvmarg()
214:                        .setValue(
215:                                "-Djava.naming.factory.initial=org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
216:                bootstrapTask.createJvmarg()
217:                        .setValue(
218:                                "-Djava.endorsed.dirs="
219:                                        + jonasLibEndorsedDir.getPath());
220:
221:                // Rmi annotation
222:                bootstrapTask
223:                        .createJvmarg()
224:                        .setValue(
225:                                "-Djava.rmi.server.RMIClassLoaderSpi=org.objectweb.jonas.server.RemoteClassLoaderSpi");
226:
227:                // Webcontainer
228:                if (catalinaHome != null) {
229:                    bootstrapTask.createJvmarg().setValue(
230:                            "-Dcatalina.home=" + catalinaHome);
231:                }
232:                bootstrapTask.createJvmarg().setValue(
233:                        "-Dcatalina.base=" + jonasBase);
234:
235:                if (jettyHome != null) {
236:                    bootstrapTask.createJvmarg().setValue(
237:                            "-Djetty.home=" + jettyHome);
238:                }
239:
240:                // java policy file
241:                String jonasConfigDir = jonasBase + File.separator + "conf";
242:                File javaPolicyFile = new File(jonasConfigDir, "java.policy");
243:                if (javaPolicyFile.exists()) {
244:                    bootstrapTask.createJvmarg().setValue(
245:                            "-Djava.security.policy="
246:                                    + javaPolicyFile.getPath());
247:                }
248:                File javaAuthLoginFile = new File(jonasConfigDir, "jaas.config");
249:                bootstrapTask.createJvmarg().setValue(
250:                        "-Djava.security.auth.login.config="
251:                                + javaAuthLoginFile.getPath());
252:
253:                // The bootstrap class must launch the defined class
254:                bootstrapTask.createArg().setValue(definedClass);
255:
256:                // add jonas_base/conf
257:                classpath = new Path(getProject(), jonasConfigDir);
258:
259:                // then add ow_jonas_bootstrap.jar to classloader
260:                String bootJar = jonasRoot + File.separator + "lib"
261:                        + File.separator + "common" + File.separator
262:                        + "ow_jonas_bootstrap.jar";
263:                classpath.append(new Path(getProject(), bootJar));
264:
265:                // Add tools.jar
266:                String toolsJar = System.getProperty("java.home")
267:                        + File.separator + ".." + File.separator + "lib"
268:                        + File.separator + "tools.jar";
269:                classpath.append(new Path(getProject(), toolsJar));
270:
271:                // Set the classpath
272:                bootstrapTask.setClasspath(classpath);
273:
274:                // class to use = bootstrap class
275:                bootstrapTask.setClassname(BOOTSTRAP_CLASS);
276:
277:                // add user defined jvmopts
278:                if (jvmOpts != null && !jvmOpts.equals("")) {
279:                    bootstrapTask.createJvmarg().setLine(jvmOpts);
280:                }
281:
282:                // add jonas name
283:                if (serverName != null) {
284:                    bootstrapTask.createArg().setValue("-n");
285:                    bootstrapTask.createArg().setValue(getServerName());
286:                }
287:
288:                return bootstrapTask;
289:
290:            }
291:
292:            /**
293:             * @return the taskName.
294:             */
295:            public String getTaskName() {
296:                return taskName;
297:            }
298:
299:            /**
300:             * Set the name of the task
301:             * @param taskName Name of the task
302:             */
303:            public void setTaskName(String taskName) {
304:                this .taskName = taskName;
305:            }
306:
307:            /**
308:             * @return the server Name.
309:             */
310:            public String getServerName() {
311:                return serverName;
312:            }
313:
314:            /**
315:             * Set the name of the server
316:             * @param serverName The serverName to set.
317:             */
318:            public void setServerName(String serverName) {
319:                this .serverName = serverName;
320:            }
321:
322:            /**
323:             * @return the catalinaHome.
324:             */
325:            public String getCatalinaHome() {
326:                return catalinaHome;
327:            }
328:
329:            /**
330:             * Set catalina Home
331:             * @param catalinaHome The catalinaHome to set.
332:             */
333:            public void setCatalinaHome(String catalinaHome) {
334:                this .catalinaHome = catalinaHome;
335:            }
336:
337:            /**
338:             * @return the jettyHome.
339:             */
340:            public String getJettyHome() {
341:                return jettyHome;
342:            }
343:
344:            /**
345:             * Set jetty home path
346:             * @param jettyHome The jettyHome to set.
347:             */
348:            public void setJettyHome(String jettyHome) {
349:                this .jettyHome = jettyHome;
350:            }
351:
352:            /**
353:             * @return the jonasRoot.
354:             */
355:            public File getJonasRoot() {
356:                return jonasRoot;
357:            }
358:
359:            /**
360:             * @return the domainName.
361:             */
362:            public String getDomainName() {
363:                return domainName;
364:            }
365:
366:            /**
367:             * Set domainName
368:             * @param domainName The domainName to set.
369:             */
370:            public void setDomainName(String domainName) {
371:                this.domainName = domainName;
372:            }
373:
374:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.