1 26 27 package org.objectweb.jonas.ant.jonasbase; 28 29 import java.util.StringTokenizer ; 30 31 import org.objectweb.jonas.ant.JOnASBaseTask; 32 33 37 public class Jms extends Tasks { 38 39 42 private static final String INFO = "[JMS] "; 43 44 47 private static final String DEFAULT_PORT = "16010"; 48 49 52 private static final String DEFAULT_TOPIC = "sampleTopic"; 53 54 57 private static final String TOPIC_PROPERTY = "Topic"; 58 59 62 private static final String QUEUE_PROPERTY = "Queue"; 63 64 67 private static final String DEFAULT_QUEUE = "sampleQueue"; 68 69 72 public Jms() { 73 super(); 74 } 75 76 80 public void setPort(String portNumber) { 81 82 JReplace propertyReplace = new JReplace(); 84 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_CONF_FILE); 85 propertyReplace.setToken(DEFAULT_PORT); 86 propertyReplace.setValue(portNumber); 87 propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in " 88 + JOnASBaseTask.JORAM_CONF_FILE + " file."); 89 addTask(propertyReplace); 90 91 propertyReplace = new JReplace(); 93 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE); 94 propertyReplace.setToken(DEFAULT_PORT); 95 propertyReplace.setValue(portNumber); 96 propertyReplace.setLogInfo(INFO + "Setting Joram port number to : " + portNumber + " in " 97 + JOnASBaseTask.JORAM_ADMIN_CONF_FILE + " file."); 98 addTask(propertyReplace); 99 } 100 101 105 public void setInitialTopics(String initialTopics) { 106 JReplace propertyReplace = new JReplace(); 107 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE); 108 propertyReplace.setToken(DEFAULT_TOPIC); 109 String tokenValue = ""; 110 StringTokenizer st = new StringTokenizer (initialTopics, ","); 111 112 while (st.hasMoreTokens()) { 113 String topic = st.nextToken(); 114 if (st.hasMoreTokens()) { 115 tokenValue += topic + "\n" + TOPIC_PROPERTY + " "; 116 } else { 117 tokenValue += topic; 118 } 119 } 120 121 propertyReplace.setValue(tokenValue); 122 propertyReplace.setLogInfo(INFO + "Setting initial topics to : " + initialTopics); 123 addTask(propertyReplace); 124 } 125 126 130 public void setInitialQueues(String initialQueues) { 131 JReplace propertyReplace = new JReplace(); 132 propertyReplace.setConfigurationFile(JOnASBaseTask.JORAM_ADMIN_CONF_FILE); 133 propertyReplace.setToken(DEFAULT_QUEUE); 134 135 String tokenValue = ""; 136 StringTokenizer st = new StringTokenizer (initialQueues, ","); 137 138 while (st.hasMoreTokens()) { 139 String topic = st.nextToken(); 140 if (st.hasMoreTokens()) { 141 tokenValue += topic + "\n" + QUEUE_PROPERTY + " "; 142 } else { 143 tokenValue += topic; 144 } 145 } 146 147 propertyReplace.setValue(tokenValue); 148 propertyReplace.setLogInfo(INFO + "Setting initial queues to : " + initialQueues); 149 addTask(propertyReplace); 150 } 151 } | Popular Tags |