KickJava   Java API By Example, From Geeks To Geeks.

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


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: DbCluster.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 org.objectweb.jonas.ant.jonasbase.Db;
31
32 /**
33  * Define DbCluster task
34  * @author Benoit Pelletier
35  */

36 public class DbCluster extends ClusterTasks {
37
38     /**
39      * Info for the logger
40      */

41     private static final String JavaDoc INFO = "[DbCluster] ";
42
43     /**
44      * ports range
45      */

46     private String JavaDoc[] portRange = null;
47
48     /**
49      * Default constructor
50      */

51     public DbCluster() {
52         super();
53     }
54
55     /**
56      * Set ports range
57      * @param portRange ports range
58      */

59     public void setPortRange(String JavaDoc portRange) {
60         this.portRange = portRange.split(",");
61
62     }
63
64     /**
65      * Generates the db tasks for each JOnAS's instances
66      */

67     public void generatesTasks() {
68
69         int portInd = 0;
70
71         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
72
73             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
74             log(INFO + "tasks generation for " + destDir);
75             // creation of the Db task
76
Db db = new Db();
77
78             db.setPort(portRange[portInd]);
79             db.setDestDir(new File JavaDoc(destDir));
80
81             addTask(db);
82
83             portInd++;
84
85         }
86     }
87 }
Popular Tags