|
From: <tr...@us...> - 2003-06-30 22:14:59
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/feeder
In directory sc8-pr-cvs1:/tmp/cvs-serv22133/src/com/babeldoc/core/pipeline/feeder
Modified Files:
AsynchronousFeeder.java IFeeder.java SynchronousFeeder.java
Log Message:
Added the feeder factory and the abstraction of access to the feeders.
Index: AsynchronousFeeder.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/feeder/AsynchronousFeeder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** AsynchronousFeeder.java 27 Jun 2003 02:19:59 -0000 1.6
--- AsynchronousFeeder.java 30 Jun 2003 22:14:56 -0000 1.7
***************
*** 67,76 ****
import com.babeldoc.core.LogService;
import com.babeldoc.core.journal.JournalException;
import com.babeldoc.core.pipeline.PipelineException;
import org.apache.commons.threadpool.DefaultThreadPool;
! import java.util.ArrayList;
--- 67,81 ----
import com.babeldoc.core.LogService;
+ import com.babeldoc.core.GeneralException;
import com.babeldoc.core.journal.JournalException;
import com.babeldoc.core.pipeline.PipelineException;
import org.apache.commons.threadpool.DefaultThreadPool;
+ import org.apache.commons.lang.NumberUtils;
! import java.util.Collection;
! import java.util.Map;
! import java.io.File;
! import java.io.IOException;
***************
*** 85,88 ****
--- 90,100 ----
*/
public class AsynchronousFeeder extends SynchronousFeeder implements Runnable {
+ public static final String Q_TYPE_DISK = "disk";
+ public static final String Q_TYPE_MEMORY = "memory";
+ public static final String Q_TYPE = "queue";
+ public static final String Q_DISK_DIR = "queueDir";
+ public static final String Q_DIR_NAME = "queueName";
+ public static final String POOLSIZE = "poolSize";
+
private DefaultThreadPool threadPool;
***************
*** 91,120 ****
private LogService log = LogService.getInstance(AsynchronousFeeder.class.getName());
private boolean stopRunning = false;
-
/**
! * Construct this object - this sets up the queue and the threadpool. This
* will also add this task (runnable) to the ThreadPool via the invokeLater
* method. This will exactly match the number of threads this thread pool
* object is dedicated to Asynchronous feeding.
*
- * @param queue DOCUMENT ME!
- */
- public AsynchronousFeeder(IFeederQueue queue) {
- this.queue = queue;
- threadPool = new DefaultThreadPool(1);
- threadPool.invokeLater(this);
- }
-
- /**
- * Construct this object - this sets up the queue and the threadpool. This
- * will also add this task (runnable) to the ThreadPool via the invokeLater
- * method. This will exactly match the number of threads this thread pool
- * object is dedicated to Asynchronous feeding.
*
! * @param queue DOCUMENT ME!
! * @param poolSize DOCUMENT ME!
*/
! public AsynchronousFeeder(IFeederQueue queue, int poolSize) {
! this.queue = queue;
threadPool = new DefaultThreadPool(poolSize);
--- 103,138 ----
private LogService log = LogService.getInstance(AsynchronousFeeder.class.getName());
private boolean stopRunning = false;
/**
! * initialize this object - this sets up the queue and the threadpool. This
* will also add this task (runnable) to the ThreadPool via the invokeLater
* method. This will exactly match the number of threads this thread pool
* object is dedicated to Asynchronous feeding.
*
*
! * @param map
*/
! public void initialize(Map map)
! throws GeneralException{
! if(map!=null) {
! String qtype = (String)map.get(Q_TYPE);
! if(Q_TYPE_DISK.equals(qtype)) {
! String qname = (String)map.get(Q_DIR_NAME);
! String qdir = (String)map.get(Q_DISK_DIR);
! if(qname==null) {
! throw new GeneralException("Disk queues must have a 'queueName'");
! }
! if(qdir==null||new File(qdir).exists()) {
! throw new GeneralException("Disk queues must have a 'queueDir'");
! }
! try {
! this.queue = new DiskQueue(qname, new File(qdir));
! } catch (IOException e) {
! throw new GeneralException("Trying to create a disk queue", e);
! }
! } else {
! this.queue = new MemoryQueue();
! }
! }
! int poolSize = NumberUtils.stringToInt((String)map.get(POOLSIZE), 1);
threadPool = new DefaultThreadPool(poolSize);
***************
*** 135,139 ****
* @throws PipelineException
*/
! public ArrayList process(FeedDocument docFeed)
throws JournalException, PipelineException {
try {
--- 153,157 ----
* @throws PipelineException
*/
! public Collection process(FeedDocument docFeed)
throws JournalException, PipelineException {
try {
Index: IFeeder.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/feeder/IFeeder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IFeeder.java 27 Jun 2003 02:19:59 -0000 1.2
--- IFeeder.java 30 Jun 2003 22:14:56 -0000 1.3
***************
*** 69,72 ****
--- 69,74 ----
import java.util.ArrayList;
+ import java.util.Collection;
+ import java.util.Map;
***************
*** 89,92 ****
* @throws GeneralException
*/
! public ArrayList process(FeedDocument docFeed) throws GeneralException;
}
--- 91,104 ----
* @throws GeneralException
*/
! public Collection process(FeedDocument docFeed)
! throws GeneralException;
!
! /**
! * Iniatialize this feeder object. This operation is guaranteeded to be called just
! * after the feeder has been constructed and before it is used to feed documents.
! *
! * @param configuration
! */
! public void initialize(Map configuration)
! throws GeneralException;
}
Index: SynchronousFeeder.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/feeder/SynchronousFeeder.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SynchronousFeeder.java 27 Jun 2003 02:19:59 -0000 1.4
--- SynchronousFeeder.java 30 Jun 2003 22:14:56 -0000 1.5
***************
*** 73,79 ****
--- 73,82 ----
import com.babeldoc.core.pipeline.PipelineException;
import com.babeldoc.core.pipeline.PipelineFactoryFactory;
+ import com.babeldoc.core.GeneralException;
import java.util.ArrayList;
import java.util.Iterator;
+ import java.util.Collection;
+ import java.util.Map;
***************
*** 86,89 ****
--- 89,93 ----
*/
public class SynchronousFeeder implements IFeeder {
+
/**
* Create a pipeline document from the string and the properties
***************
*** 121,125 ****
* @throws PipelineException
*/
! public ArrayList process(FeedDocument feedDoc)
throws JournalException, PipelineException {
IJournal journal = JournalFactory.getJournal();
--- 125,129 ----
* @throws PipelineException
*/
! public Collection process(FeedDocument feedDoc)
throws JournalException, PipelineException {
IJournal journal = JournalFactory.getJournal();
***************
*** 138,141 ****
--- 142,156 ----
return results;
+ }
+
+ /**
+ * Iniatialize this feeder object. This operation is guaranteeded to be called just
+ * after the feeder has been constructed and before it is used to feed documents. This
+ * does nothing for the synchronous feeder.
+ *
+ * @param configuration
+ */
+ public void initialize(Map configuration)
+ throws GeneralException {
}
}
|