* @param serviceType The MQ Connection Service type "NORMAL" or "ADMIN"
*
* @return a MQ Message Service Address for this broker
*/
public String getBrokerServiceAddress(String protocol, String serviceType) throws Exception {
PortMapperEntry pme = null, e = null;;
Iterator itr = Globals.getPortMapper().getServices().values().iterator();
while (itr.hasNext()) {
e = (PortMapperEntry)itr.next();
if (e.getProtocol().toLowerCase().equals(protocol.toLowerCase()) &&
e.getType().equals(serviceType)) {
pme = e;
break;
}
}
if (pme == null) {
throw new Exception(
"No available service found with protocol "+protocol+" and type "+serviceType);
}
String h = pme.getProperty("hostname");
if (h == null || h.length() == 0 || h.equals(Globals.HOSTNAME_ALL)) {
h = Globals.getMQAddress().getHostName();
if (DEBUG) {
logger.log(logger.INFO, "getBrokerServiceAddress:"+
serviceType+" "+protocol+" global hostname="+h);
}
} else {
h = MQAddress.getMQAddress(h, pme.getPort()).getHostName();
if (DEBUG) {
logger.log(logger.INFO, "getBrokerServiceAddress:"+
serviceType+" "+protocol+" service hostname="+h);
}
}
return "mq"+protocol.toLowerCase()+"://"+h+":"+pme.getPort()+"/"+pme.getName();
}