1 43 package net.jforum.util.search.simple; 44 45 import java.sql.Connection ; 46 47 import net.jforum.DBConnection; 48 import net.jforum.dao.DataAccessDriver; 49 import net.jforum.dao.SearchIndexerDAO; 50 import net.jforum.entities.Post; 51 import net.jforum.util.concurrent.Task; 52 53 import org.apache.log4j.Logger; 54 55 59 public class MessageIndexerTask implements Task 60 { 61 private static Logger logger = Logger.getLogger(MessageIndexerTask.class); 62 private Connection conn; 63 private Post post; 64 65 public MessageIndexerTask(Post post) throws Exception 66 { 67 this.post = post; 68 this.conn = DBConnection.getImplementation().getConnection(); 69 } 70 71 74 public Object execute() throws Exception 75 { 76 try { 77 SearchIndexerDAO indexer = DataAccessDriver.getInstance().newSearchIndexerDAO(); 78 indexer.setConnection(this.conn); 79 indexer.insertSearchWords(this.post); 80 } 81 catch (Exception e) { 82 logger.warn("Error while indexing a post: " + e); 83 e.printStackTrace(); 84 } 85 finally { 86 if (this.conn != null) { 87 try { 88 DBConnection.getImplementation().releaseConnection(this.conn); 89 } 90 catch (Exception e) {} 91 } 92 } 93 94 return null; 95 } 96 } 97 | Popular Tags |