You are viewing a plain text version of this content. The canonical link for it is here.
Posted to droids-commits@incubator.apache.org by to...@apache.org on 2012/12/18 08:41:41 UTC

svn commit: r1423322 [1/2] - in /incubator/droids/branches/0.2.x-cleanup: ./ droids-core/ droids-core/src/main/java/org/apache/droids/core/ droids-core/src/main/java/org/apache/droids/delay/ droids-core/src/main/java/org/apache/droids/exception/ droids...

Author: tobr
Date: Tue Dec 18 08:41:30 2012
New Revision: 1423322

URL: http://svn.apache.org/viewvc?rev=1423322&view=rev
Log:
reformat code base

Modified:
    incubator/droids/branches/0.2.x-cleanup/droids-core/pom.xml
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/DroidsException.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Handler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/MultiThreadedTaskMaster.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SequentialTaskMaster.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/DelayTimer.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/RandomDelayTimer.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/SimpleDelayTimer.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/DefaultTaskExceptionHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidLinkException.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidTaskException.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/ProtocolNotFoundException.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionResult.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/AlreadyVisitedFilter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/ChainTaskFilter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/Filter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/HostFilter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/MaxDepthTaskFilter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexRule.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexURLFilter.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/DefaultSaveContentHandlerStrategy.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/ReportHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SaveContentHandlerStrategy.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SaveHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/WriterHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/helper/factories/HandlerFactory.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/monitor/SimpleWorkMonitor.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/monitor/WorkBean.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/monitor/WorkMonitor.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/Parser.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/util/FileUtil.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/site/site.xml
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/SimpleTask.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/TestSimpleQueue.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/core/TestSimpleTaskQueueWithHistory.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java
    incubator/droids/branches/0.2.x-cleanup/droids-walker/pom.xml
    incubator/droids/branches/0.2.x-cleanup/droids-walker/src/main/java/org/apache/droids/protocol/file/FileProtocol.java
    incubator/droids/branches/0.2.x-cleanup/droids-walker/src/main/java/org/apache/droids/walker/FileTask.java
    incubator/droids/branches/0.2.x-cleanup/droids-walker/src/main/java/org/apache/droids/walker/WalkingDroid.java
    incubator/droids/branches/0.2.x-cleanup/droids-walker/src/test/java/org/apache/droids/walker/WalkingDroidTest.java
    incubator/droids/branches/0.2.x-cleanup/droids-walker/src/test/resources/logback.xml
    incubator/droids/branches/0.2.x-cleanup/pom.xml
    incubator/droids/branches/0.2.x-cleanup/src/site/resources/css/site.css
    incubator/droids/branches/0.2.x-cleanup/src/site/site.xml

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/pom.xml?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/pom.xml (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/pom.xml Tue Dec 18 08:41:30 2012
@@ -25,56 +25,57 @@
    <http://www.apache.org />.
  -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>droids</artifactId>
-    <groupId>org.apache.droids</groupId>
-    <version>0.3.0-incubating-SNAPSHOT</version>
-    <relativePath>../pom.xml</relativePath>
-  </parent>
-  <artifactId>droids-core</artifactId>
-  <name>Apache Droids Core</name>
-  <inceptionYear>2007</inceptionYear>
-  <description>
-   Apache Droids API and core components
-  </description>
-  <packaging>jar</packaging>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.droids</groupId>
-      <artifactId>droids-norobots</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-      <version>10.0.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-      <version>${slf4j.version}</version>
-    </dependency>
-    <dependency>
-	    <groupId>org.slf4j</groupId>
-	    <artifactId>jcl-over-slf4j</artifactId>
-	    <version>${slf4j.version}</version>
-    </dependency>    
-    <!-- TEST -->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-simple</artifactId>
-      <version>${slf4j.version}</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-  
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>droids</artifactId>
+        <groupId>org.apache.droids</groupId>
+        <version>0.3.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>droids-core</artifactId>
+    <name>Apache Droids Core</name>
+    <inceptionYear>2007</inceptionYear>
+    <description>
+        Apache Droids API and core components
+    </description>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.droids</groupId>
+            <artifactId>droids-norobots</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>10.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <version>${slf4j.version}</version>
+        </dependency>
+        <!-- TEST -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
 </project>

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/DroidsException.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/DroidsException.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/DroidsException.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/DroidsException.java Tue Dec 18 08:41:30 2012
@@ -18,43 +18,41 @@ package org.apache.droids.core;
 
 /**
  * Wrapper object to limit the number of different Exception we can throw.
- * 
+ *
  * @version 1.0
- * 
  */
 public class DroidsException extends Exception {
 
-  private static final long serialVersionUID = -6910418914635962957L;
+    private static final long serialVersionUID = -6910418914635962957L;
 
-  /**
-   * Constructs a new exception with the specified detail message. The cause is
-   * not initialized, and may subsequently be initialized by a call to
-   * {@link #initCause}.
-   * 
-   * @param message
-   *                the detail message. The detail message is saved for later
-   *                retrieval by the {@link #getMessage()} method.
-   */
-  public DroidsException(String message) {
-    super(message);
-  }
+    /**
+     * Constructs a new exception with the specified detail message. The cause is
+     * not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for later
+     *                retrieval by the {@link #getMessage()} method.
+     */
+    public DroidsException(String message) {
+        super(message);
+    }
 
-  /**
-   * For more information {@link Exception}
-   * 
-   * @param message
-   * @param cause
-   */
-  public DroidsException(String message, Throwable cause) {
-    super(message, cause);
-  }
+    /**
+     * For more information {@link Exception}
+     *
+     * @param message
+     * @param cause
+     */
+    public DroidsException(String message, Throwable cause) {
+        super(message, cause);
+    }
 
-  /**
-   * For more information {@link Exception}
-   * 
-   * @param cause
-   */
-  public DroidsException(Throwable cause) {
-    super(cause);
-  }
+    /**
+     * For more information {@link Exception}
+     *
+     * @param cause
+     */
+    public DroidsException(Throwable cause) {
+        super(cause);
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Handler.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Handler.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Handler.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Handler.java Tue Dec 18 08:41:30 2012
@@ -22,18 +22,15 @@ import java.io.IOException;
 /**
  * A handler is a component that uses the stream, the parse and url to invoke
  * arbitrary business logic on the objects.
- * 
+ *
  * @version 1.0
- * 
  */
 public interface Handler {
-  /**
-   * @param openStream
-   *                the underlying stream
-   * @param uri
-   *                the uri we are currently processing
-   * @throws Exception
-   */
-  void handle(Task task) 
-    throws DroidsException, IOException;
+    /**
+     * @param openStream the underlying stream
+     * @param uri        the uri we are currently processing
+     * @throws Exception
+     */
+    void handle(Task task)
+            throws DroidsException, IOException;
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/MultiThreadedTaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/MultiThreadedTaskMaster.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/MultiThreadedTaskMaster.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/MultiThreadedTaskMaster.java Tue Dec 18 08:41:30 2012
@@ -22,6 +22,7 @@ import java.util.concurrent.LinkedBlocki
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.droids.delay.DelayTimer;
 import org.apache.droids.exception.TaskExceptionHandler;
 import org.apache.droids.exception.TaskExceptionResult;
@@ -32,376 +33,351 @@ import org.slf4j.LoggerFactory;
 /**
  * Responsible for running all the tasks
  */
-public class MultiThreadedTaskMaster<T extends Task> implements TaskMaster<T>
-{
+public class MultiThreadedTaskMaster<T extends Task> implements TaskMaster<T> {
 
-  protected static final Logger LOG = LoggerFactory.getLogger(MultiThreadedTaskMaster.class);
-  private static final long TICKLE_TIME = 1000L;
-  
-  /**
-   * The execution state
-   */
-  protected volatile ExecutionState state = ExecutionState.STOPPED;
-  /**
-   * The delay timer
-   */
-  protected DelayTimer delayTimer;
-  /**
-   * The start time
-   */
-  protected Date startTime;
-  /**
-   * The end time
-   */
-  protected Date endTime;
-  /**
-   * The last completed task
-   */
-  protected T lastCompletedTask;
-  /**
-   * The completed task counter
-   */
-  protected AtomicLong completedTasks = new AtomicLong();
-  /**
-   * The monitor that that records the processing of tasks
-   */
-  protected WorkMonitor<T> monitor;
-  /**
-   * The task exception handler
-   */
-  protected TaskExceptionHandler exceptionHandler;
-
-  /*
-   * The pool size
-   */
-  private int poolSize = 1;
-  /**
-   * The pool
-   */
-  private TaskExecutorPool pool;
-
-  @Override
-  public void start(Queue<T> queue, Droid<T> droid)
-  {
-    if (LOG.isInfoEnabled()) {
-      LOG.info("Start the executor service.");
-    }
-
-    state = ExecutionState.RUNNING;
-
-    if (pool == null) {
-      this.pool = new TaskExecutorPool();
-      this.pool.setCorePoolSize(this.poolSize);
-    }
-
-    // Stagger startup
-    for (int i = 0; i < poolSize; i++) {
-      try {
-        Thread.sleep(TICKLE_TIME);
-      } catch(InterruptedException ignored) {
-        LOG.error("", ignored);
-      }
-      pool.execute(new TaskExecutor(queue, droid));
-    }
-  }
-
-  /**
-   * Stops the TaskMaster
-   */
-  public void stop()
-  {
-    // debug
-    if (LOG.isInfoEnabled()) {
-      LOG.info("Stop the executor service.");
-    }
-
-    state = ExecutionState.STOPPED;
-
-    // Disable new tasks from being submitted
-    pool.shutdown();
-
-    // Wait a while for existing tasks to terminate
-    try {
-      if (!pool.awaitTermination(1, TimeUnit.SECONDS)) {
-
-        // Cancel currently executing tasks
-        pool.shutdownNow();
-
-        // Wait a while for to respond to being canceled
-        if (!pool.awaitTermination(1, TimeUnit.SECONDS)) {
-          if (LOG.isInfoEnabled()) {
-            LOG.info("Scheduler did not stop.");
-          }
-        }
-      }
-    } catch (InterruptedException ex) {
-
-      if (LOG.isInfoEnabled()) {
-        LOG.info("Force scheduler to stop.");
-      }
-
-      // (Re-)Cancel if current thread also interrupted
-      pool.shutdownNow();
-
-      // Preserve interrupt status
-      Thread.currentThread().interrupt();
-    }
-
-    // debug
-    if (LOG.isInfoEnabled()) {
-      LOG.info("Scheduler stopped.");
-    }
-
-  }
-
-  @Override
-  public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
-  {
-    return pool.awaitTermination(timeout, unit);
-  }
-
-  /**
-   * @inheritDoc
-   */
-  @Override
-  public ExecutionState getExecutionState()
-  {
-    return state;
-  }
-
-  /**
-   * @return
-   * @inheritDoc
-   */
-  public WorkMonitor<T> getMonitor()
-  {
-    return monitor;
-  }
-
-  /**
-   * @param monitor
-   * @inheritDoc
-   */
-  public void setMonitor(WorkMonitor<T> monitor)
-  {
-    if (state == ExecutionState.RUNNING) {
-      throw new IllegalStateException("The TaskMaster must be stopped to set a Monitor.");
-    }
-    this.monitor = monitor;
-  }
-
-  @Override
-  public void setExceptionHandler(TaskExceptionHandler exceptionHandler)
-  {
-    this.exceptionHandler = exceptionHandler;
-  }
-
-  @Override
-  public void setDelayTimer(DelayTimer delayTimer)
-  {
-    this.delayTimer = delayTimer;
-  }
-
-  @Override
-  public Date getFinishedWorking()
-  {
-    return endTime;
-  }
-
-  @Override
-  public T getLastCompletedTask()
-  {
-    return lastCompletedTask;
-  }
-
-  @Override
-  public long getCompletedTasks()
-  {
-    return completedTasks.get();
-  }
-
-  @Override
-  public Date getStartTime()
-  {
-    return startTime;
-  }
-
-  /**
-   * Sets the pool size
-   *
-   * @return
-   */
-  public int getPoolSize()
-  {
-    return poolSize;
-  }
-
-  /**
-   * Returns the size of the pool
-   *
-   * @param poolSize
-   */
-  public void setPoolSize(int poolSize)
-  {
-    this.poolSize = poolSize;
-    if(pool != null) 
-      pool.setCorePoolSize(this.poolSize);
-  }
-
-  private class TaskExecutorPool extends ThreadPoolExecutor
-  {
-
-    private static final long KEEP_ALIVE = 50000L;
-
-    public TaskExecutorPool()
-    {
-      super(poolSize, poolSize, KEEP_ALIVE, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
-      this.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
-    }
+    protected static final Logger LOG = LoggerFactory.getLogger(MultiThreadedTaskMaster.class);
+    private static final long TICKLE_TIME = 1000L;
+
+    /**
+     * The execution state
+     */
+    protected volatile ExecutionState state = ExecutionState.STOPPED;
+    /**
+     * The delay timer
+     */
+    protected DelayTimer delayTimer;
+    /**
+     * The start time
+     */
+    protected Date startTime;
+    /**
+     * The end time
+     */
+    protected Date endTime;
+    /**
+     * The last completed task
+     */
+    protected T lastCompletedTask;
+    /**
+     * The completed task counter
+     */
+    protected AtomicLong completedTasks = new AtomicLong();
+    /**
+     * The monitor that that records the processing of tasks
+     */
+    protected WorkMonitor<T> monitor;
+    /**
+     * The task exception handler
+     */
+    protected TaskExceptionHandler exceptionHandler;
+
+    /*
+     * The pool size
+     */
+    private int poolSize = 1;
+    /**
+     * The pool
+     */
+    private TaskExecutorPool pool;
 
     @Override
-    protected void afterExecute(Runnable r, Throwable thrwbl)
-    {
-      super.afterExecute(r, thrwbl);
-
-      
-      
-      // try to reexecute the task runner while
-      // the task queue is not empty and while the pool
-      // is still completing the execution of tasks.
-      @SuppressWarnings("unchecked")
-      TaskExecutor taskExecutor = (TaskExecutor) r;
-      
-      while (taskExecutor.getQueue().size() > 0 || getQueue().size() > 0) {
-        if (taskExecutor.getQueue().size() > 0) {
-          execute(r);
-          return;
+    public void start(Queue<T> queue, Droid<T> droid) {
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Start the executor service.");
+        }
+
+        state = ExecutionState.RUNNING;
+
+        if (pool == null) {
+            this.pool = new TaskExecutorPool();
+            this.pool.setCorePoolSize(this.poolSize);
+        }
+
+        // Stagger startup
+        for (int i = 0; i < poolSize; i++) {
+            try {
+                Thread.sleep(TICKLE_TIME);
+            } catch (InterruptedException ignored) {
+                LOG.error("", ignored);
+            }
+            pool.execute(new TaskExecutor(queue, droid));
         }
+    }
+
+    /**
+     * Stops the TaskMaster
+     */
+    public void stop() {
+        // debug
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Stop the executor service.");
+        }
+
+        state = ExecutionState.STOPPED;
+
+        // Disable new tasks from being submitted
+        pool.shutdown();
+
+        // Wait a while for existing tasks to terminate
         try {
-          Thread.sleep(TICKLE_TIME);
-        } catch (InterruptedException e) {
-          LOG.error("", e);
+            if (!pool.awaitTermination(1, TimeUnit.SECONDS)) {
+
+                // Cancel currently executing tasks
+                pool.shutdownNow();
+
+                // Wait a while for to respond to being canceled
+                if (!pool.awaitTermination(1, TimeUnit.SECONDS)) {
+                    if (LOG.isInfoEnabled()) {
+                        LOG.info("Scheduler did not stop.");
+                    }
+                }
+            }
+        } catch (InterruptedException ex) {
+
+            if (LOG.isInfoEnabled()) {
+                LOG.info("Force scheduler to stop.");
+            }
+
+            // (Re-)Cancel if current thread also interrupted
+            pool.shutdownNow();
+
+            // Preserve interrupt status
+            Thread.currentThread().interrupt();
+        }
+
+        // debug
+        if (LOG.isInfoEnabled()) {
+            LOG.info("Scheduler stopped.");
         }
-      }
-      
-      state = ExecutionState.COMPLETED;
-      // If this point is reached, a count of one means this completed thread
-      if(this.getActiveCount() == 1) {
-    	  
-    	// finish droid just once  
-        taskExecutor.getDroid().finished();
-        shutdown();
-      }
 
     }
-  }
 
-  private class TaskExecutor implements Runnable
-  {
+    @Override
+    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+        return pool.awaitTermination(timeout, unit);
+    }
 
-    private final Droid<T> droid;
-    private final Queue<T> queue;
-    private final Worker<T> worker;
+    /**
+     * @inheritDoc
+     */
+    @Override
+    public ExecutionState getExecutionState() {
+        return state;
+    }
 
-    public TaskExecutor(Queue queue, Droid<T> droid)
-    {
-      this.droid = droid;
-      this.queue = queue;
-      this.worker = droid.getNewWorker();
+    /**
+     * @return
+     * @inheritDoc
+     */
+    public WorkMonitor<T> getMonitor() {
+        return monitor;
+    }
+
+    /**
+     * @param monitor
+     * @inheritDoc
+     */
+    public void setMonitor(WorkMonitor<T> monitor) {
+        if (state == ExecutionState.RUNNING) {
+            throw new IllegalStateException("The TaskMaster must be stopped to set a Monitor.");
+        }
+        this.monitor = monitor;
     }
 
-    public Droid<T> getDroid()
-    {
-      return droid;
+    @Override
+    public void setExceptionHandler(TaskExceptionHandler exceptionHandler) {
+        this.exceptionHandler = exceptionHandler;
     }
 
-    public Queue<T> getQueue()
-    {
-      return queue;
+    @Override
+    public void setDelayTimer(DelayTimer delayTimer) {
+        this.delayTimer = delayTimer;
     }
 
-    @SuppressWarnings("unused")
-    public Worker<? extends Task> getWorker()
-    {
-      return worker;
+    @Override
+    public Date getFinishedWorking() {
+        return endTime;
     }
 
     @Override
-    public void run()
-    {
-      // poll the last task
-      T task = queue.poll();
-      
-      if(task == null) {
-        try {
-          Thread.sleep(TICKLE_TIME);
-        } catch (InterruptedException e) {
-          LOG.error("", e);
+    public T getLastCompletedTask() {
+        return lastCompletedTask;
+    }
+
+    @Override
+    public long getCompletedTasks() {
+        return completedTasks.get();
+    }
+
+    @Override
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    /**
+     * Sets the pool size
+     *
+     * @return
+     */
+    public int getPoolSize() {
+        return poolSize;
+    }
+
+    /**
+     * Returns the size of the pool
+     *
+     * @param poolSize
+     */
+    public void setPoolSize(int poolSize) {
+        this.poolSize = poolSize;
+        if (pool != null)
+            pool.setCorePoolSize(this.poolSize);
+    }
+
+    private class TaskExecutorPool extends ThreadPoolExecutor {
+
+        private static final long KEEP_ALIVE = 50000L;
+
+        public TaskExecutorPool() {
+            super(poolSize, poolSize, KEEP_ALIVE, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
+            this.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
         }
-        task = queue.poll();
-      }
 
-      // execute the task
-      if (task != null) {
-        try {
-          // monitor the execution of the task
-          if (monitor != null) {
-            monitor.beforeExecute(task, worker);
-          }
-
-          // debug
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Worker [" + worker + "] execute task [" + task + "].");
-          }
-
-          // execute the task
-          if(!task.isAborted()) {
-            worker.execute(task);
-          }
-
-          // debug
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Worker [" + worker + "] executed task [" + task + "] with success.");
-          }
-
-          // monitor the execution of the task
-          if (monitor != null) {
-            monitor.afterExecute(task, worker, null);
-          }
-
-          // set the monitored variables
-          completedTasks.incrementAndGet();
-          lastCompletedTask = task;
-
-        } catch (Exception ex) {
-          // debug
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Worker [" + worker + "] executed task [" + task + "] without success.");
-          }
-
-          // debug
-          if (LOG.isErrorEnabled()) {
-            LOG.error("", ex);
-          }
-
-          // monitor the exception
-          if (monitor != null) {
-            monitor.afterExecute(task, worker, ex);
-          }
-
-          // handler the exception
-          if (ex != null) {
-            TaskExceptionResult result = exceptionHandler.handleException(ex);
-
-            // stop the execution in case of a fatal exception
-            if (TaskExceptionResult.FATAL.equals(result)) {
-              state = ExecutionState.STOPPED;
-              droid.finished();
-              pool.shutdownNow();
+        @Override
+        protected void afterExecute(Runnable r, Throwable thrwbl) {
+            super.afterExecute(r, thrwbl);
+
+
+            // try to reexecute the task runner while
+            // the task queue is not empty and while the pool
+            // is still completing the execution of tasks.
+            @SuppressWarnings("unchecked")
+            TaskExecutor taskExecutor = (TaskExecutor) r;
+
+            while (taskExecutor.getQueue().size() > 0 || getQueue().size() > 0) {
+                if (taskExecutor.getQueue().size() > 0) {
+                    execute(r);
+                    return;
+                }
+                try {
+                    Thread.sleep(TICKLE_TIME);
+                } catch (InterruptedException e) {
+                    LOG.error("", e);
+                }
+            }
+
+            state = ExecutionState.COMPLETED;
+            // If this point is reached, a count of one means this completed thread
+            if (this.getActiveCount() == 1) {
+
+                // finish droid just once
+                taskExecutor.getDroid().finished();
+                shutdown();
+            }
+
+        }
+    }
+
+    private class TaskExecutor implements Runnable {
+
+        private final Droid<T> droid;
+        private final Queue<T> queue;
+        private final Worker<T> worker;
+
+        public TaskExecutor(Queue queue, Droid<T> droid) {
+            this.droid = droid;
+            this.queue = queue;
+            this.worker = droid.getNewWorker();
+        }
+
+        public Droid<T> getDroid() {
+            return droid;
+        }
+
+        public Queue<T> getQueue() {
+            return queue;
+        }
+
+        @SuppressWarnings("unused")
+        public Worker<? extends Task> getWorker() {
+            return worker;
+        }
+
+        @Override
+        public void run() {
+            // poll the last task
+            T task = queue.poll();
+
+            if (task == null) {
+                try {
+                    Thread.sleep(TICKLE_TIME);
+                } catch (InterruptedException e) {
+                    LOG.error("", e);
+                }
+                task = queue.poll();
+            }
+
+            // execute the task
+            if (task != null) {
+                try {
+                    // monitor the execution of the task
+                    if (monitor != null) {
+                        monitor.beforeExecute(task, worker);
+                    }
+
+                    // debug
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Worker [" + worker + "] execute task [" + task + "].");
+                    }
+
+                    // execute the task
+                    if (!task.isAborted()) {
+                        worker.execute(task);
+                    }
+
+                    // debug
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Worker [" + worker + "] executed task [" + task + "] with success.");
+                    }
+
+                    // monitor the execution of the task
+                    if (monitor != null) {
+                        monitor.afterExecute(task, worker, null);
+                    }
+
+                    // set the monitored variables
+                    completedTasks.incrementAndGet();
+                    lastCompletedTask = task;
+
+                } catch (Exception ex) {
+                    // debug
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Worker [" + worker + "] executed task [" + task + "] without success.");
+                    }
+
+                    // debug
+                    if (LOG.isErrorEnabled()) {
+                        LOG.error("", ex);
+                    }
+
+                    // monitor the exception
+                    if (monitor != null) {
+                        monitor.afterExecute(task, worker, ex);
+                    }
+
+                    // handler the exception
+                    if (ex != null) {
+                        TaskExceptionResult result = exceptionHandler.handleException(ex);
+
+                        // stop the execution in case of a fatal exception
+                        if (TaskExceptionResult.FATAL.equals(result)) {
+                            state = ExecutionState.STOPPED;
+                            droid.finished();
+                            pool.shutdownNow();
+                        }
+                    }
+                }
             }
-          }
         }
-      }
     }
-  }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SequentialTaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SequentialTaskMaster.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SequentialTaskMaster.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SequentialTaskMaster.java Tue Dec 18 08:41:30 2012
@@ -26,145 +26,144 @@ import org.apache.droids.exception.TaskE
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SequentialTaskMaster<T extends Task> implements TaskMaster<T>
-{
+public class SequentialTaskMaster<T extends Task> implements TaskMaster<T> {
 
-  private static final Logger LOG = LoggerFactory.getLogger(SequentialTaskMaster.class);
-  private final Object mutex;
-  private volatile boolean completed;
-  private volatile Date startedWorking = null;
-  private volatile Date finishedWorking = null;
-  private volatile int completedTask = 0;
-  private volatile T lastCompletedTask = null;
-  private volatile ExecutionState state = ExecutionState.INITIALIZED;
-  private DelayTimer delayTimer = null;
-  private TaskExceptionHandler exHandler = null;
-
-  public SequentialTaskMaster() {
-    super();
-    this.mutex = new Object();
-  }
-
-  /**
-   * The queue has been initialized
-   */
-  @Override
-  public synchronized void start(final Queue<T> queue, final Droid<T> droid) {
-    this.completed = false;
-    this.startedWorking = new Date();
-    this.finishedWorking = null;
-    this.completedTask = 0;
-    this.state = ExecutionState.RUNNING;
-
-    boolean terminated = false;
-    while (!terminated) {
-      T task = queue.poll();
-      if (task == null) {
-        break;
-      }
-      if (delayTimer != null) {
-        long delay = delayTimer.getDelayMillis();
-        if (delay > 0) {
-          try {
-            Thread.sleep(delay);
-          } catch (InterruptedException e) {
-          }
+    private static final Logger LOG = LoggerFactory.getLogger(SequentialTaskMaster.class);
+    private final Object mutex;
+    private volatile boolean completed;
+    private volatile Date startedWorking = null;
+    private volatile Date finishedWorking = null;
+    private volatile int completedTask = 0;
+    private volatile T lastCompletedTask = null;
+    private volatile ExecutionState state = ExecutionState.INITIALIZED;
+    private DelayTimer delayTimer = null;
+    private TaskExceptionHandler exHandler = null;
+
+    public SequentialTaskMaster() {
+        super();
+        this.mutex = new Object();
+    }
+
+    /**
+     * The queue has been initialized
+     */
+    @Override
+    public synchronized void start(final Queue<T> queue, final Droid<T> droid) {
+        this.completed = false;
+        this.startedWorking = new Date();
+        this.finishedWorking = null;
+        this.completedTask = 0;
+        this.state = ExecutionState.RUNNING;
+
+        boolean terminated = false;
+        while (!terminated) {
+            T task = queue.poll();
+            if (task == null) {
+                break;
+            }
+            if (delayTimer != null) {
+                long delay = delayTimer.getDelayMillis();
+                if (delay > 0) {
+                    try {
+                        Thread.sleep(delay);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+            Worker<T> worker = droid.getNewWorker();
+            try {
+                if (!task.isAborted()) {
+                    worker.execute(task);
+                }
+                completedTask++;
+                lastCompletedTask = task;
+            } catch (Exception ex) {
+                TaskExceptionResult result = TaskExceptionResult.WARN;
+                if (exHandler != null) {
+                    result = exHandler.handleException(ex);
+                }
+                switch (result) {
+                    case WARN:
+                        LOG.warn(ex.toString() + " " + task.getURI());
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug(ex.toString(), ex);
+                        }
+                        break;
+                    case FATAL:
+                        LOG.error(ex.getMessage(), ex);
+                        terminated = true;
+                        break;
+                    default:
+                        break;
+                }
+            }
         }
-      }
-      Worker<T> worker = droid.getNewWorker();
-      try {
-        if (!task.isAborted()) {
-          worker.execute(task);
+        finishedWorking = new Date();
+        this.state = ExecutionState.STOPPED;
+        droid.finished();
+        synchronized (mutex) {
+            completed = true;
+            mutex.notifyAll();
         }
-        completedTask++;
-        lastCompletedTask = task;
-      } catch (Exception ex) {
-        TaskExceptionResult result = TaskExceptionResult.WARN;
-        if (exHandler != null) {
-          result = exHandler.handleException(ex);
+    }
+
+    @Override
+    public final void setExceptionHandler(TaskExceptionHandler exHandler) {
+        this.exHandler = exHandler;
+    }
+
+    @Override
+    public final void setDelayTimer(DelayTimer delayTimer) {
+        this.delayTimer = delayTimer;
+    }
+
+    public boolean isWorking() {
+        return startedWorking != null && finishedWorking == null;
+    }
+
+    @Override
+    public Date getStartTime() {
+        return startedWorking;
+    }
+
+    @Override
+    public Date getFinishedWorking() {
+        return finishedWorking;
+    }
+
+    @Override
+    public long getCompletedTasks() {
+        return completedTask;
+    }
+
+    @Override
+    public T getLastCompletedTask() {
+        return lastCompletedTask;
+    }
+
+    @Override
+    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+        if (timeout < 0) {
+            timeout = 0;
         }
-        switch (result) {
-          case WARN:
-        	LOG.warn(ex.toString() + " " + task.getURI());
-            if (LOG.isDebugEnabled()) {
-            	LOG.debug(ex.toString(), ex);
+        synchronized (this.mutex) {
+            long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
+            long remaining = timeout;
+            while (!completed) {
+                this.mutex.wait(remaining);
+                if (timeout >= 0) {
+                    remaining = deadline - System.currentTimeMillis();
+                    if (remaining <= 0) {
+                        return false; // Reach if timeout is over and no finish.
+                    }
+                }
             }
-            break;
-          case FATAL:
-            LOG.error(ex.getMessage(), ex);
-            terminated = true;
-            break;
-		default:
-			break;
         }
-      }
+        return true;
     }
-    finishedWorking = new Date();
-    this.state = ExecutionState.STOPPED;
-    droid.finished();
-    synchronized (mutex) {
-      completed = true;
-      mutex.notifyAll();
-    }
-  }
-
-  @Override
-  public final void setExceptionHandler(TaskExceptionHandler exHandler) {
-    this.exHandler = exHandler;
-  }
-
-  @Override
-  public final void setDelayTimer(DelayTimer delayTimer) {
-    this.delayTimer = delayTimer;
-  }
-
-  public boolean isWorking() {
-    return startedWorking != null && finishedWorking == null;
-  }
-
-  @Override
-  public Date getStartTime() {
-    return startedWorking;
-  }
-
-  @Override
-  public Date getFinishedWorking() {
-    return finishedWorking;
-  }
-
-  @Override
-  public long getCompletedTasks() {
-    return completedTask;
-  }
-
-  @Override
-  public T getLastCompletedTask() {
-    return lastCompletedTask;
-  }
-
-  @Override
-  public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
-    if (timeout < 0) {
-      timeout = 0;
-    }
-    synchronized (this.mutex) {
-      long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
-      long remaining = timeout;
-      while (!completed) {
-        this.mutex.wait(remaining);
-        if (timeout >= 0) {
-          remaining = deadline - System.currentTimeMillis();
-          if (remaining <= 0) {
-            return false; // Reach if timeout is over and no finish.
-          }
-        }
-      }
-    }
-    return true;
-  }
 
-  @Override
-  public ExecutionState getExecutionState() {
-    return state;
-  }
+    @Override
+    public ExecutionState getExecutionState() {
+        return state;
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/SimpleTaskQueueWithHistory.java Tue Dec 18 08:41:30 2012
@@ -29,43 +29,43 @@ import java.util.concurrent.LinkedBlocki
  */
 public class SimpleTaskQueueWithHistory<T extends Task> extends LinkedBlockingQueue<T> {
 
-	private static final long serialVersionUID = 2939042974779729702L;
-	private final Set<URI> previous;
+    private static final long serialVersionUID = 2939042974779729702L;
+    private final Set<URI> previous;
 
-	/**
-	 * Simple queue constructor.
-	 */
-	public SimpleTaskQueueWithHistory() {
-		super();
-		previous = Collections.synchronizedSet(new HashSet<URI>());
-	}
-
-	@Override
-	public boolean offer(T t) {
-		if (previous.add(t.getURI())) {
-			return super.offer(t);
-		} else {
-			return false;
-		}
-	}
-
-	@Override
-	public boolean add(T t) {
-		return this.offer(t);
-	}
-
-	@Override
-	public boolean addAll(Collection<? extends T> c) {
-		boolean hasChanged = false;
-		for (T e : c) {
-			// Must be in this order otherwise the short circuiting or
-			// will make it so that items aren't added.
-			hasChanged = this.offer(e) || hasChanged;
-		}
-		return hasChanged;
-	}
-
-	public void clearHistory() {
-		previous.clear();
-	}
+    /**
+     * Simple queue constructor.
+     */
+    public SimpleTaskQueueWithHistory() {
+        super();
+        previous = Collections.synchronizedSet(new HashSet<URI>());
+    }
+
+    @Override
+    public boolean offer(T t) {
+        if (previous.add(t.getURI())) {
+            return super.offer(t);
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public boolean add(T t) {
+        return this.offer(t);
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends T> c) {
+        boolean hasChanged = false;
+        for (T e : c) {
+            // Must be in this order otherwise the short circuiting or
+            // will make it so that items aren't added.
+            hasChanged = this.offer(e) || hasChanged;
+        }
+        return hasChanged;
+    }
+
+    public void clearHistory() {
+        previous.clear();
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/TaskMaster.java Tue Dec 18 08:41:30 2012
@@ -24,83 +24,81 @@ import org.apache.droids.delay.DelayTime
 import org.apache.droids.exception.TaskExceptionHandler;
 
 /**
- * 
  * A TaskMaster is responsible for running all the tasks.
- * 
  */
-public interface TaskMaster<T extends Task>
-{
-  /**
-   * Possible execution states for the TaskMaster.
-   */
-  public enum ExecutionState
-  {
-    INITIALIZED, RUNNING, STOPPED, COMPLETED
-  };
-
-  /**
-   * Start the process of running tasks.
-   * 
-   * @param droid
-   */
-  void start(final Queue<T> queue, final Droid<T> droid);
-
-  /**
-   * Blocks until all tasks have completed execution.
-   *
-   * @param timeout
-   * @param unit
-   * @return
-   * @throws InterruptedException
-   */
-  boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException;
-
-  /**
-   * Set the exception handler
-   * 
-   * @param taskExceptionHandler
-   */
-  void setExceptionHandler(TaskExceptionHandler taskExceptionHandler);
-
-  /**
-   * Set a delay timer.
-   * 
-   * @param simpleDelayTimer
-   */
-  void setDelayTimer(DelayTimer simpleDelayTimer);
-
-  /**
-   * Returns the current state.
-   *
-   * @return
-   */
-  ExecutionState getExecutionState();
-
-  /**
-   * Get the Date the TaskMaster started to work.
-   * 
-   * @return the start date
-   */
-  Date getStartTime();
-
-  /**
-   * Get the Date the TaskMaster finished.
-   * 
-   * @return the work-finished date
-   */
-  Date getFinishedWorking();
-
-  /**
-   * Get the number of completed tasks.
-   * 
-   * @return number of completed tasks
-   */
-  long getCompletedTasks();
-
-  /**
-   * Get the last completed task.
-   * 
-   * @return the last task
-   */
-  T getLastCompletedTask();
+public interface TaskMaster<T extends Task> {
+    /**
+     * Possible execution states for the TaskMaster.
+     */
+    public enum ExecutionState {
+        INITIALIZED, RUNNING, STOPPED, COMPLETED
+    }
+
+    ;
+
+    /**
+     * Start the process of running tasks.
+     *
+     * @param droid
+     */
+    void start(final Queue<T> queue, final Droid<T> droid);
+
+    /**
+     * Blocks until all tasks have completed execution.
+     *
+     * @param timeout
+     * @param unit
+     * @return
+     * @throws InterruptedException
+     */
+    boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException;
+
+    /**
+     * Set the exception handler
+     *
+     * @param taskExceptionHandler
+     */
+    void setExceptionHandler(TaskExceptionHandler taskExceptionHandler);
+
+    /**
+     * Set a delay timer.
+     *
+     * @param simpleDelayTimer
+     */
+    void setDelayTimer(DelayTimer simpleDelayTimer);
+
+    /**
+     * Returns the current state.
+     *
+     * @return
+     */
+    ExecutionState getExecutionState();
+
+    /**
+     * Get the Date the TaskMaster started to work.
+     *
+     * @return the start date
+     */
+    Date getStartTime();
+
+    /**
+     * Get the Date the TaskMaster finished.
+     *
+     * @return the work-finished date
+     */
+    Date getFinishedWorking();
+
+    /**
+     * Get the number of completed tasks.
+     *
+     * @return number of completed tasks
+     */
+    long getCompletedTasks();
+
+    /**
+     * Get the last completed task.
+     *
+     * @return the last task
+     */
+    T getLastCompletedTask();
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/DelayTimer.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/DelayTimer.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/DelayTimer.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/DelayTimer.java Tue Dec 18 08:41:30 2012
@@ -17,14 +17,14 @@
 package org.apache.droids.delay;
 
 /**
- * Define the timer delay interface. 
- *
+ * Define the timer delay interface.
  */
 public interface DelayTimer {
 
-  /**
-   * Returns the value of the delay between request.
-   * @return the configured value of the delay
-   */
-  long getDelayMillis();
+    /**
+     * Returns the value of the delay between request.
+     *
+     * @return the configured value of the delay
+     */
+    long getDelayMillis();
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/GaussianRandomDelayTimer.java Tue Dec 18 08:41:30 2012
@@ -21,37 +21,33 @@ package org.apache.droids.delay;
  * An instance of this class is used to generate Gaussian distributed
  * random delays.
  */
-public class GaussianRandomDelayTimer extends RandomDelayTimer implements DelayTimer
-{
+public class GaussianRandomDelayTimer extends RandomDelayTimer implements DelayTimer {
 
-  /**
-   * Creates a new Gaussian distributed random delay generator
-   */
-  public GaussianRandomDelayTimer()
-  {
-    super(0, 0);
-  }
+    /**
+     * Creates a new Gaussian distributed random delay generator
+     */
+    public GaussianRandomDelayTimer() {
+        super(0, 0);
+    }
 
-  /**
-   * Creates a new Gaussian distributed delay generator with minimum and 
-   * range constraints.
-   * 
-   * @param min
-   * @param range
-   */
-  public GaussianRandomDelayTimer(int min, int range)
-  {
-    super(min, range);
-  }
+    /**
+     * Creates a new Gaussian distributed delay generator with minimum and
+     * range constraints.
+     *
+     * @param min
+     * @param range
+     */
+    public GaussianRandomDelayTimer(int min, int range) {
+        super(min, range);
+    }
+
+    @Override
+    public long getDelayMillis() {
+        double delay;
+        do {
+            delay = (random.nextGaussian() + 1) / 2;
+        } while (delay < 0 || delay > 1);
+        return (long) (delay * delaySpread + minimumDelay);
+    }
 
-  @Override
-  public long getDelayMillis()
-  {
-    double delay;
-    do {
-      delay = (random.nextGaussian() + 1) / 2;
-    } while (delay < 0 || delay > 1);
-    return (long) (delay * delaySpread + minimumDelay);
-  }
-  
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/RandomDelayTimer.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/RandomDelayTimer.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/RandomDelayTimer.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/RandomDelayTimer.java Tue Dec 18 08:41:30 2012
@@ -22,81 +22,73 @@ import java.util.Random;
 /**
  * An instance of this class is used to generate random delays.
  */
-public class RandomDelayTimer implements DelayTimer
-{
+public class RandomDelayTimer implements DelayTimer {
 
-  protected final Random random;
-  protected int minimumDelay;
-  protected int delaySpread;
-
-  /**
-   * Creates a new random delay generator,
-   */
-  public RandomDelayTimer()
-  {
-    this(0, 0);
-  }
-
-  /**
-   * Creates a new random delay generator with minimum and range constraints.
-   *
-   * @param min
-   * @param range
-   */
-  public RandomDelayTimer(int min, int range)
-  {
-    random = new Random();
-    minimumDelay = min;
-    delaySpread = range;
-  }
-
-  @Override
-  public long getDelayMillis()
-  {
-    if (delaySpread > 0) {
-      return (long) this.random.nextInt(delaySpread) + minimumDelay;
-    }
-    return 0;
-  }
-
-  /**
-   * Returns the minimum delay
-   *
-   * @return the minimum delay
-   */
-  public int getMinimumDelay()
-  {
-    return minimumDelay;
-  }
-
-  /**
-   * Sets the minimum delay
-   *
-   * @param minimumDelay
-   */
-  public void setMinimumDelay(int minimumDelay)
-  {
-    this.minimumDelay = minimumDelay;
-  }
-
-  /**
-   * Returns the delay spread
-   *
-   * @return the delay spread
-   */
-  public int getDelaySpread()
-  {
-    return delaySpread;
-  }
-
-  /**
-   * Sets the delay spread
-   *
-   * @param delaySpread
-   */
-  public void setDelaySpread(int delaySpread)
-  {
-    this.delaySpread = delaySpread;
-  }
+    protected final Random random;
+    protected int minimumDelay;
+    protected int delaySpread;
+
+    /**
+     * Creates a new random delay generator,
+     */
+    public RandomDelayTimer() {
+        this(0, 0);
+    }
+
+    /**
+     * Creates a new random delay generator with minimum and range constraints.
+     *
+     * @param min
+     * @param range
+     */
+    public RandomDelayTimer(int min, int range) {
+        random = new Random();
+        minimumDelay = min;
+        delaySpread = range;
+    }
+
+    @Override
+    public long getDelayMillis() {
+        if (delaySpread > 0) {
+            return (long) this.random.nextInt(delaySpread) + minimumDelay;
+        }
+        return 0;
+    }
+
+    /**
+     * Returns the minimum delay
+     *
+     * @return the minimum delay
+     */
+    public int getMinimumDelay() {
+        return minimumDelay;
+    }
+
+    /**
+     * Sets the minimum delay
+     *
+     * @param minimumDelay
+     */
+    public void setMinimumDelay(int minimumDelay) {
+        this.minimumDelay = minimumDelay;
+    }
+
+    /**
+     * Returns the delay spread
+     *
+     * @return the delay spread
+     */
+    public int getDelaySpread() {
+        return delaySpread;
+    }
+
+    /**
+     * Sets the delay spread
+     *
+     * @param delaySpread
+     */
+    public void setDelaySpread(int delaySpread) {
+        this.delaySpread = delaySpread;
+    }
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/SimpleDelayTimer.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/SimpleDelayTimer.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/SimpleDelayTimer.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/delay/SimpleDelayTimer.java Tue Dec 18 08:41:30 2012
@@ -20,42 +20,40 @@ package org.apache.droids.delay;
 /**
  * An instance of this class is used to generate fixed delays.
  */
-public class SimpleDelayTimer implements DelayTimer
-{
-  /**
-   * The fixed value of the delay.
-   */
-  private long delayMillis = 0;
-  
-  /**
-   * Creates a new fixed delay generator.
-   */
-  public SimpleDelayTimer()
-  {
-    
-  }
-  
-  /**
-   * Creates a new fixed delay generator.
-   *
-   * @param delay
-   */
-  public SimpleDelayTimer( long delay )
-  {
-    this.delayMillis = delay;
-  }
-
-  @Override
-  public long getDelayMillis() {
-    return this.delayMillis;
-  }
-  
-  /**
-   * Sets the delay time.
-   * @param delay long
-   */
-  public void setDelayMillis(long delay) {
-    this.delayMillis = delay;
-  }
-  
+public class SimpleDelayTimer implements DelayTimer {
+    /**
+     * The fixed value of the delay.
+     */
+    private long delayMillis = 0;
+
+    /**
+     * Creates a new fixed delay generator.
+     */
+    public SimpleDelayTimer() {
+
+    }
+
+    /**
+     * Creates a new fixed delay generator.
+     *
+     * @param delay
+     */
+    public SimpleDelayTimer(long delay) {
+        this.delayMillis = delay;
+    }
+
+    @Override
+    public long getDelayMillis() {
+        return this.delayMillis;
+    }
+
+    /**
+     * Sets the delay time.
+     *
+     * @param delay long
+     */
+    public void setDelayMillis(long delay) {
+        this.delayMillis = delay;
+    }
+
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/DefaultTaskExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/DefaultTaskExceptionHandler.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/DefaultTaskExceptionHandler.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/DefaultTaskExceptionHandler.java Tue Dec 18 08:41:30 2012
@@ -23,15 +23,15 @@ import org.apache.droids.core.DroidsExce
 
 public class DefaultTaskExceptionHandler implements TaskExceptionHandler {
 
-  @Override
-  public TaskExceptionResult handleException(Exception ex) {
-    if (ex instanceof IOException) {
-      return TaskExceptionResult.WARN;
-    } else if (ex instanceof DroidsException) {
-      return TaskExceptionResult.WARN;
-    } else {
-      return TaskExceptionResult.FATAL;
+    @Override
+    public TaskExceptionResult handleException(Exception ex) {
+        if (ex instanceof IOException) {
+            return TaskExceptionResult.WARN;
+        } else if (ex instanceof DroidsException) {
+            return TaskExceptionResult.WARN;
+        } else {
+            return TaskExceptionResult.FATAL;
+        }
     }
-  }
-  
+
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidLinkException.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidLinkException.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidLinkException.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidLinkException.java Tue Dec 18 08:41:30 2012
@@ -20,20 +20,20 @@ import org.apache.droids.core.DroidsExce
 
 /**
  * Signals Link format violation.
- * 
+ *
  * @version 1.0
  */
 public class InvalidLinkException extends DroidsException {
 
-  private static final long serialVersionUID = 5608058374859478284L;
+    private static final long serialVersionUID = 5608058374859478284L;
+
+    public InvalidLinkException(String message) {
+        super(message);
+    }
+
+    public InvalidLinkException(String message, Throwable cause) {
+        super(message);
+        initCause(cause);
+    }
 
-  public InvalidLinkException(String message) {
-    super(message);
-  }
-  
-  public InvalidLinkException(String message, Throwable cause) {
-    super(message);
-    initCause(cause);
-  }
-  
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidTaskException.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidTaskException.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidTaskException.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/InvalidTaskException.java Tue Dec 18 08:41:30 2012
@@ -19,19 +19,15 @@ package org.apache.droids.exception;
 import org.apache.droids.core.DroidsException;
 
 /**
- * 
  * @version 1.0
- * 
  */
-public class InvalidTaskException extends DroidsException 
-{
-  private static final long serialVersionUID = -3786805476765424195L;
+public class InvalidTaskException extends DroidsException {
+    private static final long serialVersionUID = -3786805476765424195L;
 
-/**
-   * @param msg
-   *                error message
-   */
-  public InvalidTaskException( String msg ) {
-    super( msg );
-  }
+    /**
+     * @param msg error message
+     */
+    public InvalidTaskException(String msg) {
+        super(msg);
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/ProtocolNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/ProtocolNotFoundException.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/ProtocolNotFoundException.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/ProtocolNotFoundException.java Tue Dec 18 08:41:30 2012
@@ -22,43 +22,39 @@ import org.apache.droids.core.DroidsExce
 
 /**
  * If we do not have any instance of a protocol registered for the given url.
- * 
+ *
  * @version 1.0
- * 
  */
 public class ProtocolNotFoundException extends DroidsException {
-  private static final long serialVersionUID = 6980937469875896426L;
-  private URI uri = null;
+    private static final long serialVersionUID = 6980937469875896426L;
+    private URI uri = null;
 
-  /**
-   * Create an exception for the given url
-   * 
-   * @param url
-   *                url where we do not have a suitable protocol
-   */
-  public ProtocolNotFoundException(URI uri) {
-    this(uri, "protocol not found for uri=" + uri);
-  }
+    /**
+     * Create an exception for the given url
+     *
+     * @param url url where we do not have a suitable protocol
+     */
+    public ProtocolNotFoundException(URI uri) {
+        this(uri, "protocol not found for uri=" + uri);
+    }
 
-  /**
-   * Create an exception for the given url and detailed message
-   * 
-   * @param url
-   *                url where we do not have a suitable protocol
-   * @param message
-   *                detailed message to explain the underlying cause
-   */
-  public ProtocolNotFoundException(URI uri, String message) {
-    super(message);
-    this.uri = uri;
-  }
+    /**
+     * Create an exception for the given url and detailed message
+     *
+     * @param url     url where we do not have a suitable protocol
+     * @param message detailed message to explain the underlying cause
+     */
+    public ProtocolNotFoundException(URI uri, String message) {
+        super(message);
+        this.uri = uri;
+    }
 
-  /**
-   * Will return the url which has caused the problem
-   * 
-   * @return url which has caused the problem
-   */
-  public URI getUri() {
-    return uri;
-  }
+    /**
+     * Will return the url which has caused the problem
+     *
+     * @return url which has caused the problem
+     */
+    public URI getUri() {
+        return uri;
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionHandler.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionHandler.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionHandler.java Tue Dec 18 08:41:30 2012
@@ -17,19 +17,16 @@
 package org.apache.droids.exception;
 
 /**
- * 
  * Handler for task exceptions.
- *
  */
-public interface TaskExceptionHandler
-{
+public interface TaskExceptionHandler {
+
+    /**
+     * Handle an exception.
+     *
+     * @param ex
+     * @return the kind of exception
+     */
+    TaskExceptionResult handleException(Exception ex);
 
-  /**
-   * Handle an exception.
-   * 
-   * @param ex
-   * @return the kind of exception
-   */
-  TaskExceptionResult handleException(Exception ex);
-  
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionResult.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionResult.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionResult.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/exception/TaskExceptionResult.java Tue Dec 18 08:41:30 2012
@@ -17,13 +17,10 @@
 package org.apache.droids.exception;
 
 /**
- * 
  * Set of constants describing the kind of an exception.
- *
  */
-public enum TaskExceptionResult
-{
-  
-  IGNORE, WARN, FATAL
-  
+public enum TaskExceptionResult {
+
+    IGNORE, WARN, FATAL
+
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/AlreadyVisitedFilter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/AlreadyVisitedFilter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/AlreadyVisitedFilter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/AlreadyVisitedFilter.java Tue Dec 18 08:41:30 2012
@@ -24,35 +24,33 @@ import java.util.Set;
 import org.apache.droids.core.Task;
 
 /**
- * 
  * @version 1.0
  */
 public class AlreadyVisitedFilter<T extends Task> implements Filter<T> {
 
-  private Set<URI> visited;
+    private Set<URI> visited;
 
-  public AlreadyVisitedFilter() {
-    super();
-    this.visited = new HashSet<URI>();
-  }
+    public AlreadyVisitedFilter() {
+        super();
+        this.visited = new HashSet<URI>();
+    }
 
-  @Override
-  public T filter(final T task) {
-    try {
-      URI uri = task.getURI();
-      URI key = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), null, null);
-      synchronized (this.visited)
-      {
-        if (!this.visited.contains(key)) {
-          this.visited.add(key);
-          return task;
-        } else {
-          return null;
+    @Override
+    public T filter(final T task) {
+        try {
+            URI uri = task.getURI();
+            URI key = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), null, null);
+            synchronized (this.visited) {
+                if (!this.visited.contains(key)) {
+                    this.visited.add(key);
+                    return task;
+                } else {
+                    return null;
+                }
+            }
+        } catch (URISyntaxException ex) {
+            return null;
         }
-      }
-    } catch (URISyntaxException ex) {
-      return null;
     }
-  }
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/ChainTaskFilter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/ChainTaskFilter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/ChainTaskFilter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/ChainTaskFilter.java Tue Dec 18 08:41:30 2012
@@ -25,26 +25,26 @@ import org.apache.droids.core.Task;
  * A chain task validator executes a chain of unique validators
  */
 public final class ChainTaskFilter<T extends Task> implements Filter<T> {
-  private final Set<Filter<T>> filterChain;
+    private final Set<Filter<T>> filterChain;
 
-  public ChainTaskFilter() {
-    super();
+    public ChainTaskFilter() {
+        super();
 
-    this.filterChain = new LinkedHashSet<Filter<T>>();
-  }
+        this.filterChain = new LinkedHashSet<Filter<T>>();
+    }
 
-  @Override
-  public T filter(final T task) {
-    for (final Filter<T> filter : this.filterChain) {
-      if (filter.filter(task) == null) {
-        return null; 
-      }
+    @Override
+    public T filter(final T task) {
+        for (final Filter<T> filter : this.filterChain) {
+            if (filter.filter(task) == null) {
+                return null;
+            }
+        }
+        return task;
     }
-    return task;
-  }
 
-  public void addFilter(final Filter<T> filter) {
-    this.filterChain.add(filter);
-  }
+    public void addFilter(final Filter<T> filter) {
+        this.filterChain.add(filter);
+    }
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/Filter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/Filter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/Filter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/Filter.java Tue Dec 18 08:41:30 2012
@@ -20,22 +20,20 @@ import org.apache.droids.core.Task;
 
 /**
  * Filter to limit the urls that we want to allow in our queue.
- * <p>
+ * <p/>
  * Transforms the URL: can pass the original URL through or "delete" the URL by
  * returning null
- * 
+ *
  * @version 1.0
- * 
  */
 public interface Filter<T extends Task> {
 
-  /**
-   * Transforms the URL: can pass the original URL through or "delete" the URL
-   * by returning null
-   * 
-   * @param task the task to filter
-   *
-   * @return null if the filter excludes the url or the url again if allowed
-   */
-  public T filter(T task);
+    /**
+     * Transforms the URL: can pass the original URL through or "delete" the URL
+     * by returning null
+     *
+     * @param task the task to filter
+     * @return null if the filter excludes the url or the url again if allowed
+     */
+    public T filter(T task);
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/HostFilter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/HostFilter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/HostFilter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/HostFilter.java Tue Dec 18 08:41:30 2012
@@ -23,36 +23,36 @@ import org.apache.droids.core.Task;
 
 /**
  * Simple hostname based implementation of {@link Filter).
- * 
+ *
  * @version 1.0
  */
 public class HostFilter<T extends Task> implements Filter<T> {
 
-	private Set<String> allowedHosts;
+    private Set<String> allowedHosts;
 
-	public HostFilter(final Set<String> allowedHosts) {
-		super();
-		this.allowedHosts = new HashSet<String>();
-		if (allowedHosts != null) {
-			this.allowedHosts.addAll(allowedHosts);
-		}
-	}
-
-	public HostFilter(final String allowedHost) {
-		super();
-		this.allowedHosts = new HashSet<String>();
-		if (allowedHost != null) {
-			this.allowedHosts.add(allowedHost);
-		}
-	}
-
-	@Override
-	public T filter(final T task) {
-		if (this.allowedHosts.contains(task.getURI().getHost())) {
-			return task;
-		} else {
-			return null;
-		}
-	}
+    public HostFilter(final Set<String> allowedHosts) {
+        super();
+        this.allowedHosts = new HashSet<String>();
+        if (allowedHosts != null) {
+            this.allowedHosts.addAll(allowedHosts);
+        }
+    }
+
+    public HostFilter(final String allowedHost) {
+        super();
+        this.allowedHosts = new HashSet<String>();
+        if (allowedHost != null) {
+            this.allowedHosts.add(allowedHost);
+        }
+    }
+
+    @Override
+    public T filter(final T task) {
+        if (this.allowedHosts.contains(task.getURI().getHost())) {
+            return task;
+        } else {
+            return null;
+        }
+    }
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/MaxDepthTaskFilter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/MaxDepthTaskFilter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/MaxDepthTaskFilter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/MaxDepthTaskFilter.java Tue Dec 18 08:41:30 2012
@@ -22,29 +22,29 @@ import org.apache.droids.core.Task;
  * A simple task validator that honors task depth.
  */
 public class MaxDepthTaskFilter<T extends Task> implements Filter<T> {
-  private int maxDepth = -1;
+    private int maxDepth = -1;
 
-  public MaxDepthTaskFilter() {
-    super();
-  }
+    public MaxDepthTaskFilter() {
+        super();
+    }
 
-  public MaxDepthTaskFilter(int maxDepth) {
-    this.maxDepth = maxDepth;
-  }
+    public MaxDepthTaskFilter(int maxDepth) {
+        this.maxDepth = maxDepth;
+    }
 
-  @Override
-  public T filter(final T task) {
-    if (maxDepth > 0 && task.getDepth() > maxDepth) {
-      return null;
+    @Override
+    public T filter(final T task) {
+        if (maxDepth > 0 && task.getDepth() > maxDepth) {
+            return null;
+        }
+        return task;
     }
-    return task;
-  }
 
-  public int getMaxDepth() {
-    return maxDepth;
-  }
+    public int getMaxDepth() {
+        return maxDepth;
+    }
 
-  public void setMaxDepth(int maxDepth) {
-    this.maxDepth = maxDepth;
-  }
+    public void setMaxDepth(int maxDepth) {
+        this.maxDepth = maxDepth;
+    }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexRule.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexRule.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexRule.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexRule.java Tue Dec 18 08:41:30 2012
@@ -18,45 +18,42 @@ package org.apache.droids.filter;
 
 /**
  * A generic regular expression rule.
- * 
+ *
  * @version 1.0
- * 
  */
 public abstract class RegexRule {
 
-  private boolean sign = false;
+    private boolean sign = false;
 
-  /**
-   * Constructs a new regular expression rule.
-   * 
-   * @param sign
-   *                specifies if this rule must filter-in or filter-out. A
-   *                <code>true</code> value means that any url matching this
-   *                rule must be accepted, a <code>false</code> value means
-   *                that any url matching this rule must be rejected.
-   */
-  protected RegexRule(boolean sign) {
-    this.sign = sign;
-  }
-
-  /**
-   * Return if this rule is used for filtering-in or out.
-   * 
-   * @return <code>true</code> if any url matching this rule must be accepted,
-   *         otherwise <code>false</code>.
-   */
-  protected boolean accept() {
-    return sign;
-  }
-
-  /**
-   * Checks if a url matches this rule.
-   * 
-   * @param url
-   *                is the url to check.
-   * @return <code>true</code> if the specified url matches this rule,
-   *         otherwise <code>false</code>.
-   */
-  protected abstract boolean match(String url);
+    /**
+     * Constructs a new regular expression rule.
+     *
+     * @param sign specifies if this rule must filter-in or filter-out. A
+     *             <code>true</code> value means that any url matching this
+     *             rule must be accepted, a <code>false</code> value means
+     *             that any url matching this rule must be rejected.
+     */
+    protected RegexRule(boolean sign) {
+        this.sign = sign;
+    }
+
+    /**
+     * Return if this rule is used for filtering-in or out.
+     *
+     * @return <code>true</code> if any url matching this rule must be accepted,
+     *         otherwise <code>false</code>.
+     */
+    protected boolean accept() {
+        return sign;
+    }
+
+    /**
+     * Checks if a url matches this rule.
+     *
+     * @param url is the url to check.
+     * @return <code>true</code> if the specified url matches this rule,
+     *         otherwise <code>false</code>.
+     */
+    protected abstract boolean match(String url);
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexURLFilter.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexURLFilter.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexURLFilter.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/filter/RegexURLFilter.java Tue Dec 18 08:41:30 2012
@@ -32,125 +32,127 @@ import org.slf4j.LoggerFactory;
 /**
  * Regular expression implementation of an UrlFilter. Evaluates the url based on
  * regular expression.
- * 
+ *
  * @version 1.0
- * 
  */
 public class RegexURLFilter<T extends Task> implements Filter<T> {
 
-  private static final Logger LOG = LoggerFactory.getLogger(RegexURLFilter.class);
+    private static final Logger LOG = LoggerFactory.getLogger(RegexURLFilter.class);
 
-  /** An array of applicable rules */
-  private final List<RegexRule> rules;
-  
-  public RegexURLFilter(){
-    rules = new ArrayList< RegexRule >(16);
-  }
-  
-  /**
-   * Adds a new regex rule to this filter <br>
-   * @param sign
-   * @param regex 
-   */
-  public void addRule(final boolean sign, final String regex) {
-    if( regex == null ){
-      throw new IllegalArgumentException();
-    }
-
-    RegexRule rule = createRule(sign, regex);
-    rules.add(rule);
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.droids.api.URLFilter#filter(java.lang.String)
-   */
-  @Override
-  public T filter(T task) {
-    synchronized (rules) {
-      for (RegexRule rule : rules) {
-        if (rule.match(task.getURI().toString())) {
-          return rule.accept() ? task : null;
-        }
-      }
-    }
-    return null;
-  }
-  
-  /**
-   * @param file
-   * @throws IOException
-   */
-  public void setFile(String file) throws IOException {
-    URL url = null;
-    if (file.startsWith("classpath:/")) {
-      url = this.getClass().getResource(file.substring("classpath:/".length() - 1));
-    } else {
-      url = (file.contains(":/") ? new URL(file) : new URL("file://" + file));
-    }
-    LOG.debug("url " + url);
-    Reader reader = new InputStreamReader(url.openStream());
-    try {
-    	rules.addAll( readRulesFile(reader) );
-    } finally {
-    	reader.close();
-    }
-  }
-
-  private List<RegexRule> readRulesFile(Reader reader) throws IOException {
-    BufferedReader in = new BufferedReader(reader);
-    List<RegexRule> localRules = new ArrayList<RegexRule>(16);
-    String line = null;
-
-    while ((line = in.readLine()) != null) {
-      if (line.length() == 0) {
-        continue;
-      }
-      char first = line.charAt(0);
-      boolean sign = false;
-      switch (first) {
-      case '+':
-        sign = true;
-        break;
-      case '-':
-        sign = false;
-        break;
-      case ' ':
-      case '\n':
-      case '#': // skip blank & comment lines
-        continue;
-      default:
-        throw new IOException("Invalid first character: " + line);
-      }
-
-      String regex = line.substring(1);
-      if (LOG.isTraceEnabled()) {
-        LOG.trace("Adding rule [" + regex + "]");
-      }
-      final RegexRule rule = createRule(sign, regex);
-      localRules.add(rule);
-    }
-    return localRules;
-
-  }
-
-  private static RegexRule createRule(boolean sign, String regex) {
-    return new Rule(sign, regex);
-  }
-
-  private static class Rule extends RegexRule {
-
-    private Pattern pattern;
-
-    Rule(boolean sign, String regex) {
-      super(sign);
-      pattern = Pattern.compile(regex);
+    /**
+     * An array of applicable rules
+     */
+    private final List<RegexRule> rules;
+
+    public RegexURLFilter() {
+        rules = new ArrayList<RegexRule>(16);
+    }
+
+    /**
+     * Adds a new regex rule to this filter <br>
+     *
+     * @param sign
+     * @param regex
+     */
+    public void addRule(final boolean sign, final String regex) {
+        if (regex == null) {
+            throw new IllegalArgumentException();
+        }
+
+        RegexRule rule = createRule(sign, regex);
+        rules.add(rule);
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.droids.api.URLFilter#filter(java.lang.String)
+     */
     @Override
-    protected boolean match(String url) {
-      return pattern.matcher(url).find();
+    public T filter(T task) {
+        synchronized (rules) {
+            for (RegexRule rule : rules) {
+                if (rule.match(task.getURI().toString())) {
+                    return rule.accept() ? task : null;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @param file
+     * @throws IOException
+     */
+    public void setFile(String file) throws IOException {
+        URL url = null;
+        if (file.startsWith("classpath:/")) {
+            url = this.getClass().getResource(file.substring("classpath:/".length() - 1));
+        } else {
+            url = (file.contains(":/") ? new URL(file) : new URL("file://" + file));
+        }
+        LOG.debug("url " + url);
+        Reader reader = new InputStreamReader(url.openStream());
+        try {
+            rules.addAll(readRulesFile(reader));
+        } finally {
+            reader.close();
+        }
+    }
+
+    private List<RegexRule> readRulesFile(Reader reader) throws IOException {
+        BufferedReader in = new BufferedReader(reader);
+        List<RegexRule> localRules = new ArrayList<RegexRule>(16);
+        String line = null;
+
+        while ((line = in.readLine()) != null) {
+            if (line.length() == 0) {
+                continue;
+            }
+            char first = line.charAt(0);
+            boolean sign = false;
+            switch (first) {
+                case '+':
+                    sign = true;
+                    break;
+                case '-':
+                    sign = false;
+                    break;
+                case ' ':
+                case '\n':
+                case '#': // skip blank & comment lines
+                    continue;
+                default:
+                    throw new IOException("Invalid first character: " + line);
+            }
+
+            String regex = line.substring(1);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Adding rule [" + regex + "]");
+            }
+            final RegexRule rule = createRule(sign, regex);
+            localRules.add(rule);
+        }
+        return localRules;
+
+    }
+
+    private static RegexRule createRule(boolean sign, String regex) {
+        return new Rule(sign, regex);
+    }
+
+    private static class Rule extends RegexRule {
+
+        private Pattern pattern;
+
+        Rule(boolean sign, String regex) {
+            super(sign);
+            pattern = Pattern.compile(regex);
+        }
+
+        @Override
+        protected boolean match(String url) {
+            return pattern.matcher(url).find();
+        }
     }
-  }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/DefaultSaveContentHandlerStrategy.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/DefaultSaveContentHandlerStrategy.java?rev=1423322&r1=1423321&r2=1423322&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/DefaultSaveContentHandlerStrategy.java (original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/DefaultSaveContentHandlerStrategy.java Tue Dec 18 08:41:30 2012
@@ -27,7 +27,7 @@ import org.apache.droids.core.Task;
  * @version 1.0
  */
 public class DefaultSaveContentHandlerStrategy
-    implements SaveContentHandlerStrategy {
+        implements SaveContentHandlerStrategy {
 
     private String outputDir;
     private boolean includeHost;
@@ -39,9 +39,9 @@ public class DefaultSaveContentHandlerSt
     public String calculateFilePath(URI uri, Task task) {
         String filePath = outputDir;
         if (includeHost) {
-          filePath += uri.getHost() + uri.getPath();
+            filePath += uri.getHost() + uri.getPath();
         } else {
-          filePath += uri.getPath().substring(1);
+            filePath += uri.getPath().substring(1);
         }
         return filePath;
     }