labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r658185 - in /labs/droids/trunk/src/core/java/org/apache/droids: DefaultCrawler.java DefaultWorker.java api/Droid.java api/Worker.java
Date Tue, 20 May 2008 10:02:18 GMT
Author: thorsten
Date: Tue May 20 03:02:17 2008
New Revision: 658185

URL: http://svn.apache.org/viewvc?rev=658185&view=rev
Log:
Allowing droids to throw exceptions but only DroidsExceptions. Any other has to be wrapped
in this exception.

Modified:
    labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java
    labs/droids/trunk/src/core/java/org/apache/droids/DefaultWorker.java
    labs/droids/trunk/src/core/java/org/apache/droids/api/Droid.java
    labs/droids/trunk/src/core/java/org/apache/droids/api/Worker.java

Modified: labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java?rev=658185&r1=658184&r2=658185&view=diff
==============================================================================
--- labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java (original)
+++ labs/droids/trunk/src/core/java/org/apache/droids/DefaultCrawler.java Tue May 20 03:02:17
2008
@@ -27,6 +27,7 @@
 import org.apache.droids.api.Queue;
 import org.apache.droids.api.Task;
 import org.apache.droids.api.Worker;
+import org.apache.droids.exception.DroidsException;
 import org.apache.droids.queue.QueueLink;
 /**
  * Default implementation of a crawler.
@@ -59,7 +60,11 @@
     setPool( new ThreadPoolExecutor(freeSlots, freeSlots, 50000L,
         TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()));
     setRunningWorker(new ConcurrentHashMap<Long, Worker>());
-    initQueue();
+    try {
+      initQueue();
+    } catch (DroidsException e) {
+      Core.threadMessage(e.getMessage());
+    }
     startWorkers();
     Core.threadMessage("Finshed invocation, waiting for workers to finish.");
   }
@@ -82,7 +87,7 @@
   /**
    * Start the queue.
    */
-  public synchronized void initQueue() {
+  public synchronized void initQueue() throws DroidsException{
     QueueLink initialLink = new QueueLink(url, taskDate, 0);
     getQueue().init((Task[]) new Task[] { initialLink });
   }
@@ -91,7 +96,7 @@
    * Get the default worker for the class.
    * @return
    */
-  public synchronized Worker getWorker() {
+  public synchronized Worker getWorker() throws DroidsException {
     DefaultWorker worker = new DefaultWorker();
     worker.setQueue(getQueue());
     worker.setDroid(this);
@@ -179,7 +184,7 @@
     this.url = url;
   }
 
-  public synchronized void finishedWorker(long id) {
+  public synchronized void finishedWorker(long id) throws DroidsException {
     Worker worker = getRunningWorker().get(id);
     if (null != worker) {
       int y = worker.getDepth() + 1;

Modified: labs/droids/trunk/src/core/java/org/apache/droids/DefaultWorker.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/core/java/org/apache/droids/DefaultWorker.java?rev=658185&r1=658184&r2=658185&view=diff
==============================================================================
--- labs/droids/trunk/src/core/java/org/apache/droids/DefaultWorker.java (original)
+++ labs/droids/trunk/src/core/java/org/apache/droids/DefaultWorker.java Tue May 20 03:02:17
2008
@@ -14,6 +14,7 @@
 import org.apache.droids.api.Queue;
 import org.apache.droids.api.Task;
 import org.apache.droids.api.Worker;
+import org.apache.droids.exception.DroidsException;
 import org.apache.droids.helper.factories.HandlerFactory;
 import org.apache.droids.helper.factories.ParserFactory;
 import org.apache.droids.helper.factories.ProtocolFactory;
@@ -123,7 +124,7 @@
       depth = link.getDepth();
   }
 
-  public void setDroid(Droid droid) {
+  public void setDroid(Droid droid) throws DroidsException {
     this.droid = droid;
     protocolFactory = droid.getCore().getProtocolFactory();
     parserFactory = droid.getCore().getParserFactory();

Modified: labs/droids/trunk/src/core/java/org/apache/droids/api/Droid.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/core/java/org/apache/droids/api/Droid.java?rev=658185&r1=658184&r2=658185&view=diff
==============================================================================
--- labs/droids/trunk/src/core/java/org/apache/droids/api/Droid.java (original)
+++ labs/droids/trunk/src/core/java/org/apache/droids/api/Droid.java Tue May 20 03:02:17 2008
@@ -1,11 +1,12 @@
 package org.apache.droids.api;
 
 import org.apache.droids.Core;
+import org.apache.droids.exception.DroidsException;
 
 public interface Droid extends Runnable {
   public abstract void run();
-  public abstract void initQueue();
-  public abstract void setQueue(Queue queue);
-  public abstract void finishedWorker(long id);
-  public abstract Core getCore();
+  public abstract void initQueue() throws DroidsException;
+  public abstract void setQueue(Queue queue) throws DroidsException;
+  public abstract void finishedWorker(long id) throws DroidsException;
+  public abstract Core getCore() throws DroidsException;
 }

Modified: labs/droids/trunk/src/core/java/org/apache/droids/api/Worker.java
URL: http://svn.apache.org/viewvc/labs/droids/trunk/src/core/java/org/apache/droids/api/Worker.java?rev=658185&r1=658184&r2=658185&view=diff
==============================================================================
--- labs/droids/trunk/src/core/java/org/apache/droids/api/Worker.java (original)
+++ labs/droids/trunk/src/core/java/org/apache/droids/api/Worker.java Tue May 20 03:02:17
2008
@@ -1,10 +1,12 @@
 package org.apache.droids.api;
 
+import org.apache.droids.exception.DroidsException;
+
 public interface Worker extends Runnable {
   public abstract void run();
-  public abstract void setQueue(Queue queue);
-  public abstract void setDroid(Droid droid);
-  public abstract void setDepth(int x);
-  public abstract int getDepth();
-  public long getId() ;
+  public abstract void setQueue(Queue queue) throws DroidsException;
+  public abstract void setDroid(Droid droid) throws DroidsException;
+  public abstract void setDepth(int x) throws DroidsException;
+  public abstract int getDepth() throws DroidsException;
+  public long getId() throws DroidsException;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message