Agent.java
上传用户:qing5858
上传日期:2015-10-27
资源大小:6056k
文件大小:2k
源码类别:

搜索引擎

开发平台:

Java

  1. package net.javacoding.jspider.core;
  2. import net.javacoding.jspider.core.event.CoreEvent;
  3. import net.javacoding.jspider.core.exception.TaskAssignmentException;
  4. import net.javacoding.jspider.core.task.WorkerTask;
  5. import java.net.URL;
  6. /**
  7.  * Inteface of the JSpider agent, the instance to which all worker tasks will
  8.  * report and via which tasks can be obtained from the scheduler.
  9.  *
  10.  * $Id: Agent.java,v 1.5 2003/03/27 17:44:01 vanrogu Exp $
  11.  *
  12.  * @author G黱ther Van Roey
  13.  */
  14. public interface Agent {
  15.     public void start ( );
  16.     /**
  17.      * Registers that a certain taks is completed.
  18.      * @param task the Thinker task that is completed
  19.      */
  20.     public void flagDone ( WorkerTask task );
  21.     /**
  22.      * Returns a thinker task that must be executed
  23.      * @return the task to be carried out
  24.      * @throws net.javacoding.jspider.core.exception.TaskAssignmentException if there are no tasks (for now or anymore)
  25.      */
  26.     public WorkerTask getThinkerTask() throws TaskAssignmentException;
  27.     /**
  28.      * Returns a spider task that must be executed
  29.      * @return the task to be carried out
  30.      * @throws net.javacoding.jspider.core.exception.TaskAssignmentException if there are no tasks (for now or anymore)
  31.      */
  32.     public WorkerTask getSpiderTask() throws TaskAssignmentException;
  33.     /**
  34.      * Asks to schedule spidering on a certain URL.
  35.      * @param url the URL to be spidered
  36.      */
  37.     public void scheduleForSpidering ( URL url );
  38.     /**
  39.      * Asks to schedule parsing for a certain fetched URL.
  40.      * @param url the URL to be spidered
  41.      */
  42.     public void scheduleForParsing ( URL url );
  43.     /**
  44.      * Notifies the agent of a certain event.
  45.      * @param url the URL that was being processed while the event was raised
  46.      * @param event the event that was raised
  47.      */
  48.     public void registerEvent(URL url, CoreEvent event);
  49. }