* @param url URL used to start searching in the catalog
* @param type The returned service must resolve to this type
* @return URL of resulting service
*/
static final private URL service( URL url, Class<?> type ) {
ICatalog local = CatalogPlugin.getDefault().getLocalCatalog();
List<IResolve> services = local.find(url, ProgressManager.instance().get());
for( IResolve service : services ) {
if (service.canResolve(type)) {
return service.getIdentifier();
}
}
IServiceFactory serviceFactory = CatalogPlugin.getDefault().getServiceFactory();
List<IService> candidates = serviceFactory.createService(url);
try {
for( Iterator<IService> i=candidates.iterator(); i.hasNext();){
IService service = i.next();
if (service.canResolve(type)) {
IService registered = local.add(service);
i.remove(); // don't clean this one up
return registered.getIdentifier();
}
}
}