Clermont, Roger C EIS-NWD Contractor wrote:
My idea is along the lines of throwing a
RedirectException from the protocol, catching it in the appropriate place and
then handling it.

As a design rule, Exceptions should not be used for normal control flow, and redirects are arguably normal control flow.


A better design might be something like:

public interface Protocol {
  Response getResponse(String url);
}

public abstract class Response {
  public abstract Okay extends Response {
    public Content getContent();
  }

  public abstract Redirect extends Response {
    public String toUrl();
  }

  public abstract RetryLater extends Response {
    public String getReason();
  }

  public abstract Gone extends Response {
    public String getReason();
  }
}

Then, the fetcher could easily implement redirect logic.

What do folks think of this API proposal?

Doug


------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Nutch-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nutch-developers

Reply via email to