KickJava   Java API By Example, From Geeks To Geeks.

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


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: LibCluster.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.io.File JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.List JavaDoc;
33
34 import org.apache.tools.ant.types.FileSet;
35
36 import org.objectweb.jonas.ant.jonasbase.Lib;
37
38 /**
39  * Define LibCluster task
40  * @author Benoit Pelletier
41  */

42 public class LibCluster extends ClusterTasks {
43
44     /**
45      * Info for the logger
46      */

47     private static final String JavaDoc INFO = "[LibCluster] ";
48
49     /**
50      * List of files (WSDL publish)
51      */

52     private List JavaDoc files = new ArrayList JavaDoc();
53
54     /**
55      * destination Directory
56      */

57     private File JavaDoc destDir = null;
58
59     /**
60      * Default constructor
61      */

62     public LibCluster() {
63         super();
64     }
65
66     /**
67      * Add file (wsdl publish)
68      * @param file properties file
69      */

70     public void addConfiguredFileSet(FileSet file) {
71         files.add(file);
72     }
73
74     /**
75      * Override method to copy files to custom folder and not for several JONAS_BASE
76      * @param destDir The destDir to set.
77      */

78     public void setDestDir(File JavaDoc destDir) {
79         this.destDir = destDir;
80     }
81
82     /**
83      * Generates the LibCluster tasks for each JOnAS's instances
84      */

85     public void generatesTasks() {
86
87         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
88
89             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
90             log(INFO + "tasks generation for " + destDir);
91
92             // creation of the Lib task
93
Lib lib = new Lib();
94
95             for (Iterator JavaDoc it = files.iterator(); it.hasNext();) {
96                 FileSet fileSet = (FileSet) it.next();
97                 lib.addFileset(fileSet);
98                 if (this.destDir == null) {
99                     lib.setDestDir(new File JavaDoc(destDir));
100                 } else {
101                     // bypass the adding of '/lib/ext' suffix
102
lib.setTodir(this.destDir);
103                 }
104
105                 addTask(lib);
106             }
107         }
108     }
109 }
Popular Tags