/**
   * Blocking operation to resolve into the adaptee, if available.
   *
   * <p>Required adaptions:
   *
   * <ul>
   *   <li>GeoResource.class - this
   *   <li>IGeoResourceInfo.class - getInfo( monitor ) ie about this handles contents
   *   <li>IService.class - service( monitor ) ie that is responsible for this GeoResource
   * </ul>
   *
   * <p>Example Use (no casting required!):
   *
   * <pre>
   * <code>
   * IGeoResourceInfo info = resolve(IGeoResourceInfo.class);
   * </code>
   * </pre>
   *
   * <p>Recommended adaptions:
   *
   * <ul>
   *   <li>ImageDescriptor.class (for icon provided by external service)
   *   <li>List.class - members( monitor ) ie children of this georesource as in the wms layer case
   * </ul>
   *
   * @param adaptee
   * @param monitor
   * @return instance of adaptee, or null if unavailable (IGeoResourceInfo and IService must be
   *     supported)
   * @see IGeoResourceInfo
   * @see IService
   * @see IResolve#resolve(Class, IProgressMonitor)
   */
  public <T> T resolve(Class<T> adaptee, IProgressMonitor monitor) throws IOException {

    if (monitor == null) monitor = new NullProgressMonitor();

    if (adaptee == null) {
      throw new NullPointerException("No adaptor specified"); // $NON-NLS-1$
    }
    if (adaptee.isAssignableFrom(IGeoResourceInfo.class)) {
      return adaptee.cast(getInfo(monitor));
    }
    if (adaptee.isAssignableFrom(IService.class)) {
      return adaptee.cast(service(monitor));
    }
    if (adaptee.isAssignableFrom(IServiceInfo.class)) {
      try {
        monitor.beginTask("service info", 100); // $NON-NLS-1$
        IService service = service(new SubProgressMonitor(monitor, 40));
        if (service != null) {
          IServiceInfo info = service.getInfo(new SubProgressMonitor(monitor, 60));
          return adaptee.cast(info);
        }
      } finally {
        monitor.done();
      }
    }
    if (adaptee.isAssignableFrom(IGeoResource.class)) {
      monitor.done();
      return adaptee.cast(this);
    }
    if (adaptee.isAssignableFrom(getClass())) {
      return adaptee.cast(this);
    }
    IResolveManager rm = CatalogPlugin.getDefault().getResolveManager();
    if (rm.canResolve(this, adaptee)) {
      return rm.resolve(this, adaptee, monitor);
    }
    return null; // no adapter found (check to see if ResolveAdapter is registered?)
  }