serviceAddress = (String) services.get(serviceName);
if (serviceAddress == null) {
// Send the disco packet to the server itself
try {
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(serviceName);
// Check if the server supports JEP-33
if (info.containsFeature("http://jabber.org/protocol/address")) {
serviceAddress = serviceName;
}
else {
// Get the disco items and send the disco packet to each server item
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
.discoverItems(serviceName);
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = it.next();
info = ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(item.getEntityID(), item.getNode());
if (info.containsFeature("http://jabber.org/protocol/address")) {
serviceAddress = serviceName;
break;
}
}