00001
00027 package org.objectweb.jonas.ant.jonasbase;
00028
00029 import java.util.StringTokenizer;
00030
00031 import org.objectweb.jonas.ant.JOnASBaseTask;
00032
00037 public class Jms extends Tasks {
00038
00042 private static final String INFO = "[JMS] ";
00043
00047 private static final String DEFAULT_PORT = "16010";
00048
00052 private static final String DEFAULT_TOPIC = "sampleTopic";
00053
00057 private static final String TOPIC_PROPERTY = "Topic";
00058
00062 private static final String QUEUE_PROPERTY = "Queue";
00063
00067 private static final String DEFAULT_QUEUE = "sampleQueue";
00068
00072 public Jms() {
00073 super();
00074 }
00075
00080 public void setPort(String portNumber) {
00081
00082
00083 JReplace propertyReplace = new JReplace();
00084 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_CONF_FILE);
00085 propertyReplace.setToken(DEFAULT_PORT);
00086 propertyReplace.setValue(portNumber);
00087 propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in "
00088 + JOnASBaseTask.JORAM_CONF_FILE + " file.");
00089 addTask(propertyReplace);
00090
00091
00092 propertyReplace = new JReplace();
00093 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
00094 propertyReplace.setToken(DEFAULT_PORT);
00095 propertyReplace.setValue(portNumber);
00096 propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in "
00097 + JOnASBaseTask.JORAM_ADMIN_CONF_FILE + " file.");
00098 addTask(propertyReplace);
00099 }
00100
00105 public void setInitialTopics(String initialTopics) {
00106 JReplace propertyReplace = new JReplace();
00107 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
00108 propertyReplace.setToken(DEFAULT_TOPIC);
00109 String tokenValue = "";
00110 StringTokenizer st = new StringTokenizer(initialTopics, ",");
00111
00112 while (st.hasMoreTokens()) {
00113 String topic = st.nextToken();
00114 if (st.hasMoreTokens()) {
00115 tokenValue += topic + "\n" + TOPIC_PROPERTY + " ";
00116 } else {
00117 tokenValue += topic;
00118 }
00119 }
00120
00121 propertyReplace.setValue(tokenValue);
00122 propertyReplace.setLogInfo(INFO + "Setting initial topics to : " + initialTopics);
00123 addTask(propertyReplace);
00124 }
00125
00130 public void setInitialQueues(String initialQueues) {
00131 JReplace propertyReplace = new JReplace();
00132 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE);
00133 propertyReplace.setToken(DEFAULT_QUEUE);
00134
00135 String tokenValue = "";
00136 StringTokenizer st = new StringTokenizer(initialQueues, ",");
00137
00138 while (st.hasMoreTokens()) {
00139 String topic = st.nextToken();
00140 if (st.hasMoreTokens()) {
00141 tokenValue += topic + "\n" + QUEUE_PROPERTY + " ";
00142 } else {
00143 tokenValue += topic;
00144 }
00145 }
00146
00147 propertyReplace.setValue(tokenValue);
00148 propertyReplace.setLogInfo(INFO + "Setting initial queues to : " + initialQueues);
00149 addTask(propertyReplace);
00150 }
00151 }