KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > JOnASAntTool


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Benoit Pelletier
22  * --------------------------------------------------------------------------
23  * $Id: JOnASAntTool.java,v 1.1 2005/06/07 08:21:27 pelletib Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant;
28
29 import java.io.File JavaDoc;
30
31 import org.apache.tools.ant.Project;
32 import org.apache.tools.ant.Task;
33 import org.apache.tools.ant.types.FileSet;
34 import org.apache.tools.ant.types.PatternSet.NameEntry;
35
36 import org.objectweb.jonas.ant.jonasbase.Apps;
37 import org.objectweb.jonas.ant.jonasbase.Archives;
38 import org.objectweb.jonas.ant.jonasbase.Ejbjars;
39 import org.objectweb.jonas.ant.jonasbase.Rars;
40 import org.objectweb.jonas.ant.jonasbase.Wars;
41
42 /**
43  * Common constants or methods used by several classes of the package
44  * @author Benoit Pelletier
45  */

46 public class JOnASAntTool {
47
48     /**
49      * Name of JOnAS configuration file
50      */

51     public static final String JavaDoc JONAS_CONF_FILE = "jonas.properties";
52
53     /**
54      * Name of Joram configuration file
55      */

56     public static final String JavaDoc JORAM_CONF_FILE = "a3servers.xml";
57
58     /**
59      * Name of Joram admin configuration file (resource adaptor)
60      */

61     public static final String JavaDoc JORAM_ADMIN_CONF_FILE = "joram-admin.cfg";
62
63     /**
64      * Name of Carol configuration file
65      */

66     public static final String JavaDoc CAROL_CONF_FILE = "carol.properties";
67
68     /**
69      * Name of Tomcat configuration file
70      */

71     public static final String JavaDoc TOMCAT_CONF_FILE = "server.xml";
72
73     /**
74      * Name of Tomcat configuration file
75      */

76     public static final String JavaDoc JETTY_CONF_FILE = "jetty5.xml";
77
78     /**
79      * Name of P6Spy configuration file
80      */

81     public static final String JavaDoc P6SPY_CONF_FILE = "spy.properties";
82
83     /**
84      * List of Wars to copy for each JONAS_BASE
85      */

86     public static final String JavaDoc[] WARS_LIST = new String JavaDoc[] {"juddi.war", "autoload/jonasAdmin.war"};
87
88     /**
89      * List of Rars to copy for each JONAS_BASE
90      */

91     public static final String JavaDoc[] RARS_LIST = new String JavaDoc[] {"autoload/JOnAS_jdbcCP.rar", "autoload/JOnAS_jdbcDM.rar", "autoload/JOnAS_jdbcDS.rar", "autoload/JOnAS_jdbcXA.rar", "autoload/joram_for_jonas_ra.rar"};
92
93     /**
94      * List of EjbJars to copy for each JONAS_BASE
95      */

96     public static final String JavaDoc[] EJBJARS_LIST = new String JavaDoc[] {""};
97
98     /**
99      * List of Apps to copy for each JONAS_BASE
100      */

101     public static final String JavaDoc[] APPS_LIST = new String JavaDoc[] {"autoload/mejb.ear"};
102
103     /**
104      * Private constructor for tool class
105      */

106     private JOnASAntTool() {
107
108     }
109
110     /**
111      * Update the JONAS_BASE directory with ejbjars, webapps, rars, etc.
112      * @param antTask target task
113      * @param jonasRoot JONAS_ROOT
114      * @param destDir destination directory
115      **/

116     public static void updateJonasBase(Task antTask, File JavaDoc jonasRoot, File JavaDoc destDir) {
117         Archives wars = new Wars();
118         updateJonasBaseForArchives(antTask, jonasRoot, destDir, wars, "webapps", WARS_LIST);
119
120         Archives ejbjars = new Ejbjars();
121         updateJonasBaseForArchives(antTask, jonasRoot, destDir, ejbjars, "ejbjars", EJBJARS_LIST);
122
123         Archives rars = new Rars();
124         updateJonasBaseForArchives(antTask, jonasRoot, destDir, rars, "rars", RARS_LIST);
125
126         Archives apps = new Apps();
127         updateJonasBaseForArchives(antTask, jonasRoot, destDir, apps, "apps", APPS_LIST);
128
129
130     }
131
132     /**
133      * Update JONAS_BASE with given archives with lists of includes
134      * @param antTask target task
135      * @param jonasRoot JONAS_ROOT
136      * @param destDir destination directory
137      * @param archives tasks (webapps, rars, ejbjars)
138      * @param folderName where to put files
139      * @param listOfIncludes files to include
140      */

141     public static void updateJonasBaseForArchives(Task antTask, File JavaDoc jonasRoot, File JavaDoc destDir, Archives archives, String JavaDoc folderName, String JavaDoc[] listOfIncludes) {
142         configure(antTask, archives);
143         archives.setDestDir(destDir);
144         FileSet fileSet = new FileSet();
145         fileSet.setDir(new File JavaDoc(jonasRoot, folderName));
146         for (int f = 0; f < listOfIncludes.length; f++) {
147             NameEntry ne = fileSet.createInclude();
148             ne.setName(listOfIncludes[f]);
149         }
150         archives.addFileset(fileSet);
151         archives.setOverwrite(true);
152         String JavaDoc info = archives.getLogInfo();
153         if (info != null) {
154             antTask.log(info, Project.MSG_INFO);
155         }
156         archives.execute();
157     }
158
159     /**
160      * Configure the given task by setting name, project root, etc
161      * @param srcTask source task
162      * @param dstTask destination task
163      */

164     public static void configure(Task srcTask, Task dstTask) {
165         dstTask.setTaskName(srcTask.getTaskName());
166         dstTask.setProject(srcTask.getProject());
167     }
168
169 }
Popular Tags