KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > cluster > ClusterTasks


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: ClusterTasks.java,v 1.1 2005/06/07 08:21:27 pelletib Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.cluster;
28
29 import java.util.ArrayList JavaDoc;
30 import java.util.List JavaDoc;
31
32 import org.apache.tools.ant.Task;
33
34 import org.objectweb.jonas.ant.jonasbase.Tasks;
35
36 /**
37  * Defines a common cluster task
38  * @author Benoit Pelletier
39  */

40 public abstract class ClusterTasks extends Tasks {
41
42     /**
43      * Archictecture of the JOnAS's instances : contain both Web level and Ejb level
44      */

45     protected static final String JavaDoc ARCH_BOTH_WEB_EJB = "bothWebEjb";
46
47     /**
48      * Archictecture of the JOnAS's instances : separate Web level and Ejb level
49      */

50     protected static final String JavaDoc ARCH_SEPARATED_WEB_EJB = "separatedWebEjb";
51
52     /**
53      * Information for the logger
54      */

55     private String JavaDoc logInfo = null;
56
57     /**
58      * Prefix to the destination directory (JONAS_BASE)
59      */

60     private String JavaDoc destDirPrefix = null;
61
62     /**
63      * First index for the destDir suffix
64      */

65     private int destDirSuffixIndFirst = -1;
66
67     /**
68      * Last index for the destDir suffix
69      */

70     private int destDirSuffixIndLast = -1;
71
72     /**
73      * Cluster tasks List
74      */

75     private List JavaDoc clusterTasks = null;
76
77     /**
78      * Cluster architecture : share instance for web/ejb or separate them
79      */

80     private String JavaDoc arch = null;
81
82     /**
83      * Root task set just for logging purpose
84      */

85     private Task rootTask = null;
86
87     /**
88      * Constructor
89      */

90     public ClusterTasks() {
91         clusterTasks = new ArrayList JavaDoc();
92     }
93
94     /**
95      * Set directory prefix
96      * @param destDirPrefix The destDirPrefix to set.
97      */

98     public void setDestDirPrefix(String JavaDoc destDirPrefix) {
99         this.destDirPrefix = destDirPrefix;
100     }
101
102     /**
103      * Gets the prefix of the destination directory
104      * @return the prefix of the destination directory
105      */

106     public String JavaDoc getDestDirPrefix() {
107         return destDirPrefix;
108     }
109
110     /**
111      * @param destDirSuffixIndFirst The destDirSuffixIndFirst to set.
112      */

113     public void setDestDirSuffixIndFirst(int destDirSuffixIndFirst) {
114         this.destDirSuffixIndFirst = destDirSuffixIndFirst;
115     }
116
117     /**
118      * Gets the first index of the destDir suffix
119      * @return the first index of the destDir suffix
120      */

121     public int getDestDirSuffixIndFirst() {
122         return destDirSuffixIndFirst;
123     }
124
125     /**
126      * @param destDirSuffixIndLast The destDirSuffixIndLast to set.
127      */

128     public void setDestDirSuffixIndLast(int destDirSuffixIndLast) {
129         this.destDirSuffixIndLast = destDirSuffixIndLast;
130     }
131     /**
132      * Gets the last index of the destDir suffix
133      * @return the last index of the destDir suffix
134      */

135     public int getDestDirSuffixIndLast() {
136         return destDirSuffixIndLast;
137     }
138
139     /**
140      * Gets logger info (to be displayed)
141      * @return logger info
142      * @see org.objectweb.jonas.ant.jonasbase.BaseTaskItf#getLogInfo()
143      */

144     public String JavaDoc getLogInfo() {
145         return logInfo;
146     }
147
148     /**
149      * Set the info to be displayed by the logger
150      * @param logInfo information to be displayed
151      * @see org.objectweb.jonas.ant.jonasbase.BaseTaskItf#setLogInfo(java.lang.String)
152      */

153     public void setLogInfo(String JavaDoc logInfo) {
154         this.logInfo = logInfo;
155     }
156
157     /**
158      * Build dest dir with an index
159      * @param destDirPrefix destination directory prefix
160      * @param i index
161      * @return destination directory
162      */

163     public static String JavaDoc getDestDir(String JavaDoc destDirPrefix, int i) {
164         String JavaDoc destDir = destDirPrefix + i;
165         return destDir;
166     }
167
168     /**
169      * Set architecture
170      * @param arch the architecture
171      */

172     public void setArch(String JavaDoc arch) {
173         this.arch = arch;
174     }
175
176     /**
177      * Get architecture
178      * @return architecture
179      */

180     public String JavaDoc getArch() {
181         return arch;
182     }
183
184     /**
185      * Set root task
186      * @param rootTask root task
187      */

188     public void setRootTask(Task rootTask) {
189         this.rootTask = rootTask;
190     }
191
192     /**
193      * Get root Task
194      * @return rootTask root task
195      */

196     public Task getRootTask() {
197         return rootTask;
198     }
199
200     /**
201      * Add a task to the list of defined tasks
202      * @param ct task to add
203      */

204     public void addClusterTask(ClusterTasks ct) {
205         clusterTasks.add(ct);
206     }
207
208     /**
209      * @return a list of all tasks to do
210      */

211     public List JavaDoc getClusterTasks() {
212         return clusterTasks;
213     }
214
215     /**
216      * Logging
217      * @param msg message to log
218      */

219     public void log(String JavaDoc msg) {
220
221         if (rootTask != null) {
222             rootTask.log(msg);
223         }
224     }
225
226     /**
227      * Abstract generatesTasks()
228      */

229     public abstract void generatesTasks();
230 }
Popular Tags