KickJava   Java API By Example, From Geeks To Geeks.

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


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: CarolCluster.java,v 1.2 2005/06/09 12:37:09 pelletib Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.cluster;
28
29 import java.io.File JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 import org.objectweb.jonas.ant.jonasbase.BaseTaskItf;
33 import org.objectweb.jonas.ant.jonasbase.Carol;
34
35 /**
36  * Define CarolCluster task
37  * @author Benoit Pelletier
38  */

39 public class CarolCluster extends ClusterTasks {
40
41     /**
42      * Info for the logger
43      */

44     private static final String JavaDoc INFO = "[CarolCluster] ";
45
46     /**
47      * ports range
48      */

49     private String JavaDoc[] portRange = null;
50
51     /**
52      * protocols
53      */

54     private String JavaDoc protocols = null;
55
56     /**
57      * multicast addr
58      */

59     private String JavaDoc mcastAddr = null;
60
61     /**
62      * jrmp optimization
63      */

64     private boolean jrmpOptimization = false;
65
66     /**
67      * Default constructor
68      */

69     public CarolCluster() {
70         super();
71     }
72
73     /**
74      * Set protocols
75      * @param protocols protocols to set
76      */

77     public void setProtocols(String JavaDoc protocols) {
78         this.protocols = protocols;
79     }
80
81     /**
82      * Set mcastAddr
83      * @param mcastAddr multicast address to set
84      */

85     public void setMcastAddr(String JavaDoc mcastAddr) {
86         this.mcastAddr = mcastAddr;
87     }
88
89     /**
90      * Set ports range
91      * @param portRange ports range
92      */

93     public void setPortRange(String JavaDoc portRange) {
94         this.portRange = portRange.split(",");
95
96     }
97
98     /**
99      * Set jrmp optimization
100      * @param jrmpOptimization jrmp optimization
101      */

102     public void setJrmpOptimization(boolean jrmpOptimization) {
103         this.jrmpOptimization = jrmpOptimization;
104
105     }
106
107     /**
108      * Generates the carol tasks for each JOnAS's instances
109      */

110     public void generatesTasks() {
111
112         int portInd = 0;
113
114         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
115
116             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
117
118             // creation of the Carol tasks
119
Carol carol = new Carol();
120             log(INFO + "tasks generation for " + destDir);
121             carol.setDefaultPort(portRange[portInd]);
122             carol.setProtocols(protocols);
123             carol.setCmiMcastAddr(mcastAddr);
124             carol.setJrmpOptimization(jrmpOptimization);
125
126             // set destDir for each carol task
127
for (Iterator JavaDoc it = carol.getTasks().iterator(); it.hasNext();) {
128                 BaseTaskItf task = (BaseTaskItf) it.next();
129                 task.setDestDir(new File JavaDoc(destDir));
130             }
131
132             addTasks(carol);
133
134             portInd++;
135
136         }
137     }
138 }
Popular Tags