1 26 27 package org.objectweb.jonas.ant.jonasbase; 28 29 import org.objectweb.jonas.ant.JOnASBaseTask; 30 31 35 public class Carol extends Tasks { 36 37 40 private static final String INFO = "[Carol] "; 41 42 45 private static final String PROTOCOLS_PROPERTY = "carol.protocols"; 46 47 50 private static final String DEFAULT_PROTOCOLS = "jrmp"; 51 52 55 private static final String DEFAULT_HOST = "localhost"; 56 57 60 private static final String PROTOCOL_HEADER = "://"; 61 62 65 private static final String DEFAULT_JRMP_PORT = "1099"; 66 67 70 private static final String DEFAULT_JEREMIE_PORT = "2000"; 71 72 75 private static final String DEFAULT_IIOP_PORT = "2001"; 76 77 80 private static final String DEFAULT_CMI_PORT = "2002"; 81 82 85 private static final String DEFAULT_IRMI_PORT = "1098"; 86 87 90 private static final String DEFAULT_CMI_MCASTADDR = "224.0.0.35:35467"; 91 92 95 private static final String OPTIMIZATION_PROPERTY = "carol.jvm.rmi.local.call="; 96 97 100 private static final String OPTIMIZATION_OFF = OPTIMIZATION_PROPERTY + "false"; 101 102 105 private static final String OPTIMIZATION_ON = OPTIMIZATION_PROPERTY + "true"; 106 107 110 private static final String CMI_MCASTADDR_PROPERTY = "carol.cmi.multicast.address"; 111 112 115 public Carol() { 116 super(); 117 } 118 119 127 private void setURL(String protocolName, String hostName, String portNumber, String protocolUrl, String token) { 128 String url = null; 129 130 token = protocolName + PROTOCOL_HEADER + DEFAULT_HOST + ":" + token; 132 133 if (protocolUrl != null) { 134 url = protocolUrl; 135 } else { 136 url = protocolName + PROTOCOL_HEADER + hostName + ":" + portNumber; 137 } 138 JReplace propertyReplace = new JReplace(); 139 propertyReplace.setLogInfo(INFO + "Setting URL for protocol '" + protocolName + "' to : " + url); 140 propertyReplace.setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE); 141 propertyReplace.setToken(token); 142 propertyReplace.setValue(url); 143 addTask(propertyReplace); 144 } 145 146 150 public void setJrmpPort(String portNumber) { 151 setURL("rmi", DEFAULT_HOST, portNumber, null, DEFAULT_JRMP_PORT); 152 } 153 154 158 public void setJeremiePort(String portNumber) { 159 setURL("jrmi", DEFAULT_HOST, portNumber, null, DEFAULT_JEREMIE_PORT); 160 } 161 162 166 public void setIiopPort(String portNumber) { 167 setURL("iiop", DEFAULT_HOST, portNumber, null, DEFAULT_IIOP_PORT); 168 } 169 170 174 public void setCmiPort(String portNumber) { 175 setURL("cmi", DEFAULT_HOST, portNumber, null, DEFAULT_CMI_PORT); 176 } 177 178 182 public void setIrmiPort(String portNumber) { 183 setURL("rmi", DEFAULT_HOST, portNumber, null, DEFAULT_IRMI_PORT); 184 } 185 186 190 public void setCmiMcastAddr(String mcastAddr) { 191 192 String token = CMI_MCASTADDR_PROPERTY + "=" + DEFAULT_CMI_MCASTADDR; 194 String value = CMI_MCASTADDR_PROPERTY + "=" + mcastAddr; 195 JReplace propertyReplace = new JReplace(); 196 propertyReplace.setLogInfo(INFO + "Setting mcastaddr for protocol cmi"); 197 propertyReplace.setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE); 198 propertyReplace.setToken(token); 199 propertyReplace.setValue(value); 200 addTask(propertyReplace); 201 202 } 203 204 208 public void setDefaultPort(String portNumber) { 209 setJrmpPort(portNumber); 210 setJeremiePort(portNumber); 211 setIiopPort(portNumber); 212 setCmiPort(portNumber); 213 setIrmiPort(portNumber); 214 } 215 216 220 public void setProtocols(String protocols) { 221 JReplace propertyReplace = new JReplace(); 222 propertyReplace.setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE); 223 propertyReplace.setToken(PROTOCOLS_PROPERTY + "=" + DEFAULT_PROTOCOLS); 224 propertyReplace.setValue(PROTOCOLS_PROPERTY + "=" + protocols); 225 propertyReplace.setLogInfo(INFO + "Setting protocols to : " + protocols); 226 addTask(propertyReplace); 227 } 228 229 233 public void setJrmpOptimization(boolean enabled) { 234 if (!enabled) { 236 return; 237 } 238 JReplace propertyReplace = new JReplace(); 239 propertyReplace.setConfigurationFile(JOnASBaseTask.CAROL_CONF_FILE); 240 propertyReplace.setToken(OPTIMIZATION_OFF); 241 propertyReplace.setValue(OPTIMIZATION_ON); 242 propertyReplace.setLogInfo(INFO + "Enable JRMP optimization"); 243 addTask(propertyReplace); 244 } 245 246 247 } | Popular Tags |