List<ImportRegistration> irs = importedServices.get(filter);
List<EndpointDescription> ips = importPossibilities.get(filter);
Iterator<ImportRegistration> it = irs.iterator();
while (it.hasNext()) {
ImportRegistration ir = it.next();
EndpointDescription ep = ir.getImportReference().getImportedEndpoint();
// if service is already imported, check if endpoint is still in the list of
// possible imports
if ((ips != null && !ips.contains(ep)) || ips == null) {
// unexport service
ir.close();
it.remove();
}
}
if (irs.size() == 0) {
// if there are other import possibilities available, try to import them...
if (ips != null && ips.size() > 0) {
triggerImport(filter);
}
}
// TODO but optional: if the service is already imported and the endpoint is still
// in the list
// of possible imports check if a "better" endpoint is now in the list ?
} else {
// if the service is not yet imported, try ...
if (importPossibilities.get(filter).size() > 0) {
for (EndpointDescription ep : importPossibilities.get(filter)) {
ImportRegistration ir = importService(ep);
if (ir != null) {
// import was successful
List<ImportRegistration> irs = importedServices.get(filter);
if (irs == null) {
irs = new ArrayList<ImportRegistration>(1);