001    /**
002     * 
003     */
004    package org.wdssii.core;
005    
006    import java.util.List;
007    
008    import org.apache.commons.logging.Log;
009    import org.apache.commons.logging.LogFactory;
010    
011    /**
012     * Abstract class of algorithms
013     * 
014     * @author lakshman
015     * 
016     */
017    public abstract class Algorithm extends WDSSIIProgram implements IndexRecordListener {
018            private static Log log = LogFactory.getLog(Algorithm.class);
019    
020            private String inputURLs = "xml:/tmp/test.xml xml:/tmp/test2.xml";
021    
022            public String getInputURLs() {
023                    return inputURLs;
024            }
025    
026            public void setInputURLs(String inputURLs) {
027                    this.inputURLs = inputURLs;
028            }
029    
030            /**
031             * Connect to indexes and handle records.
032             */
033            @Override
034            public void execute() {
035                    // connect to all the indexes
036                    List<String> inputs = StringUtil.split(inputURLs);
037                    log.info("Processing " + inputs.size() + " urls");
038                    for (String input : inputs) {
039                            if (isRealTime()) {
040                                    Index inputIndex = IndexFactory.createIndex(input);
041                                    inputIndex.addRecordListener(this);
042                            } else {
043                                    IndexFactory.createIndex(input, this);
044                            }
045                    }
046            }
047    
048            /** initializes wdssii */
049            protected Algorithm(){
050                    super();
051            }
052    }