KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

40 public class JmsCluster extends ClusterTasks {
41
42     /**
43      * Info for the logger
44      */

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

50     private String JavaDoc[] portRange = null;
51
52     /**
53      * initialTopics
54      */

55     private String JavaDoc initialTopics = null;
56
57     /**
58      * initialQueues
59      */

60     private String JavaDoc initialQueues = null;
61
62     /**
63      * Default constructor
64      */

65     public JmsCluster() {
66         super();
67     }
68
69     /**
70      * Set ports range
71      * @param portRange ports range
72      */

73     public void setPortRange(String JavaDoc portRange) {
74         this.portRange = portRange.split(",");
75
76     }
77
78     /**
79      * Set the initial topics
80      * @param initialTopics comma separated list of topics
81      */

82     public void setInitialTopics(String JavaDoc initialTopics) {
83         this.initialTopics = initialTopics;
84     }
85
86     /**
87      * Set the initial queues when JOnAS start
88      * @param initialQueues comma separated list of topics
89      */

90     public void setInitialQueues(String JavaDoc initialQueues) {
91         this.initialQueues = initialQueues;
92     }
93
94     /**
95      * Generates the Jms tasks for each JOnAS's instances
96      */

97     public void generatesTasks() {
98
99         int portInd = 0;
100
101         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
102
103             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
104             log(INFO + "tasks generation for " + destDir);
105             // creation of the Db task
106
Jms jms = new Jms();
107
108             jms.setPort(portRange[portInd]);
109             jms.setInitialQueues(initialQueues);
110             jms.setInitialTopics(initialTopics);
111
112             // set destDir for each carol task
113
for (Iterator JavaDoc it = jms.getTasks().iterator(); it.hasNext();) {
114                 BaseTaskItf task = (BaseTaskItf) it.next();
115                 task.setDestDir(new File JavaDoc(destDir));
116             }
117
118             addTasks(jms);
119
120             portInd++;
121
122         }
123     }
124 }
Popular Tags