001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 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: Benoit Pelletier
022: * --------------------------------------------------------------------------
023: * $Id: LibCluster.java 6896 2005-06-07 08:21:28Z pelletib $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas.ant.cluster;
026:
027: import java.io.File;
028: import java.util.ArrayList;
029: import java.util.Iterator;
030: import java.util.List;
031:
032: import org.apache.tools.ant.types.FileSet;
033:
034: import org.objectweb.jonas.ant.jonasbase.Lib;
035:
036: /**
037: * Define LibCluster task
038: * @author Benoit Pelletier
039: */
040: public class LibCluster extends ClusterTasks {
041:
042: /**
043: * Info for the logger
044: */
045: private static final String INFO = "[LibCluster] ";
046:
047: /**
048: * List of files (WSDL publish)
049: */
050: private List files = new ArrayList();
051:
052: /**
053: * destination Directory
054: */
055: private File destDir = null;
056:
057: /**
058: * Default constructor
059: */
060: public LibCluster() {
061: super ();
062: }
063:
064: /**
065: * Add file (wsdl publish)
066: * @param file properties file
067: */
068: public void addConfiguredFileSet(FileSet file) {
069: files.add(file);
070: }
071:
072: /**
073: * Override method to copy files to custom folder and not for several JONAS_BASE
074: * @param destDir The destDir to set.
075: */
076: public void setDestDir(File destDir) {
077: this .destDir = destDir;
078: }
079:
080: /**
081: * Generates the LibCluster tasks for each JOnAS's instances
082: */
083: public void generatesTasks() {
084:
085: for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
086:
087: String destDir = getDestDir(getDestDirPrefix(), i);
088: log(INFO + "tasks generation for " + destDir);
089:
090: // creation of the Lib task
091: Lib lib = new Lib();
092:
093: for (Iterator it = files.iterator(); it.hasNext();) {
094: FileSet fileSet = (FileSet) it.next();
095: lib.addFileset(fileSet);
096: if (this .destDir == null) {
097: lib.setDestDir(new File(destDir));
098: } else {
099: // bypass the adding of '/lib/ext' suffix
100: lib.setTodir(this.destDir);
101: }
102:
103: addTask(lib);
104: }
105: }
106: }
107: }
|