public static W3CEndpointReference discoverGateway()
throws InterruptedException {
LOG.debug("Discovering gateway ...");
W3CEndpointReference gatewayEPR = null;
USMTNucleiDiscoveryUtil util = USMTNucleiDiscoveryUtil.getInstance();
List<I_USMTNucleus> nList = util.getNuclei();
for (int i = 0; i < MAX_RETRY_FOR_GATEWAY; i++) {
for (I_USMTNucleus nucleus : nList) {
List<ServiceInstanceDescriptionType> sidtList = util
.getServiceInstances(nucleus, new QName(
"http://www.admire-project.eu/gateway",
"Gateway"));
if (sidtList.size() > 0) {
gatewayEPR = sidtList.get(0).getEndpointReference();
}
if (gatewayEPR != null) {
break;
}
}
if (gatewayEPR != null) {
break;
}
Thread.sleep(1000);
nList = util.getNuclei();
}
util.stopDiscovering();
return gatewayEPR;
}