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: JmsCluster.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.Iterator;
029:
030: import org.objectweb.jonas.ant.jonasbase.BaseTaskItf;
031: import org.objectweb.jonas.ant.jonasbase.Jms;
032:
033: /**
034: * Define JmsCluster task
035: * @author Benoit Pelletier
036: */
037: public class JmsCluster extends ClusterTasks {
038:
039: /**
040: * Info for the logger
041: */
042: private static final String INFO = "[JmsCluster] ";
043:
044: /**
045: * ports range
046: */
047: private String[] portRange = null;
048:
049: /**
050: * initialTopics
051: */
052: private String initialTopics = null;
053:
054: /**
055: * initialQueues
056: */
057: private String initialQueues = null;
058:
059: /**
060: * Default constructor
061: */
062: public JmsCluster() {
063: super ();
064: }
065:
066: /**
067: * Set ports range
068: * @param portRange ports range
069: */
070: public void setPortRange(String portRange) {
071: this .portRange = portRange.split(",");
072:
073: }
074:
075: /**
076: * Set the initial topics
077: * @param initialTopics comma separated list of topics
078: */
079: public void setInitialTopics(String initialTopics) {
080: this .initialTopics = initialTopics;
081: }
082:
083: /**
084: * Set the initial queues when JOnAS start
085: * @param initialQueues comma separated list of topics
086: */
087: public void setInitialQueues(String initialQueues) {
088: this .initialQueues = initialQueues;
089: }
090:
091: /**
092: * Generates the Jms tasks for each JOnAS's instances
093: */
094: public void generatesTasks() {
095:
096: int portInd = 0;
097:
098: for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
099:
100: String destDir = getDestDir(getDestDirPrefix(), i);
101: log(INFO + "tasks generation for " + destDir);
102: // creation of the Db task
103: Jms jms = new Jms();
104:
105: jms.setPort(portRange[portInd]);
106: jms.setInitialQueues(initialQueues);
107: jms.setInitialTopics(initialTopics);
108:
109: // set destDir for each carol task
110: for (Iterator it = jms.getTasks().iterator(); it.hasNext();) {
111: BaseTaskItf task = (BaseTaskItf) it.next();
112: task.setDestDir(new File(destDir));
113: }
114:
115: addTasks(jms);
116:
117: portInd++;
118:
119: }
120: }
121: }
|