001: /*
002:
003: * LIUS - Lucene Index Update and Search
004: * http://sourceforge.net/projects/lius/
005: *
006: * Copyright (c) 2005, Laval University Library. All rights reserved.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
021: */
022:
023: package ca.ulaval.bibl.lius.ThreadAction;
024:
025: import java.io.IOException;
026:
027: import org.apache.log4j.Logger;
028:
029: import ca.ulaval.bibl.lius.Exception.LiusException;
030: import ca.ulaval.bibl.lius.Lucene.LuceneActions;
031:
032: /**
033: *
034: * Classe utilisant des Threads pour indexer des documents.
035: *
036: * <br/><br/>
037: *
038: * Class using threads for indexing documents.
039: *
040: *
041: *
042: * @author Rida Benjelloun (rida.benjelloun@bibl.ulaval.ca)
043: *
044: */
045:
046: public class ThreadIndexing
047:
048: extends Thread {
049:
050: static Logger logger = Logger.getRootLogger();
051:
052: private String toIndex = null;
053:
054: private String indexDir = "";
055:
056: private String fichierXMLConfig = "";
057:
058: public ThreadIndexing(String toIndex,
059:
060: String indexDir,
061:
062: String fichierXMLConfig) {
063:
064: this .toIndex = toIndex;
065:
066: this .indexDir = indexDir;
067:
068: this .fichierXMLConfig = fichierXMLConfig;
069:
070: }
071:
072: public ThreadIndexing(String toIndex,
073:
074: String indexDir,
075:
076: String fichierXMLConfig,
077:
078: String type) {
079:
080: this .toIndex = toIndex;
081:
082: this .indexDir = indexDir;
083:
084: this .fichierXMLConfig = fichierXMLConfig;
085:
086: }
087:
088: public void run() {
089:
090: try {
091:
092: LuceneActions.getSingletonInstance().index(toIndex,
093: indexDir,
094:
095: fichierXMLConfig);
096:
097: try {
098:
099: Thread.sleep(1000);
100:
101: }
102:
103: catch (InterruptedException ex) {
104:
105: logger.error(ex.getMessage());
106:
107: }
108:
109: }
110:
111: catch (LiusException e) {
112:
113: logger.error(e.getMessage());
114:
115: }
116:
117: catch (IOException e) {
118:
119: logger.error(e.getMessage());
120:
121: }
122:
123: }
124:
125: }
|