1 43 package net.jforum.util.search; 44 45 import net.jforum.entities.Post; 46 import net.jforum.exceptions.SearchInstantiationException; 47 import net.jforum.util.preferences.ConfigKeys; 48 import net.jforum.util.preferences.SystemGlobals; 49 50 import org.apache.log4j.Logger; 51 52 56 public class SearchFacade 57 { 58 private static SearchManager searchManager; 59 private static Logger logger = Logger.getLogger(SearchFacade.class); 60 61 public static void init() 62 { 63 if (!SystemGlobals.getBoolValue(ConfigKeys.SEARCH_INDEXING_ENABLED)) { 64 logger.info("Search indexation is disabled. 'Will try to create a SearchManager " 65 + "instance for runtime configuration changes"); 66 } 67 68 String clazz = SystemGlobals.getValue(ConfigKeys.SEARCH_INDEXER_IMPLEMENTATION); 69 70 if (clazz != null && !"".equals(clazz)) { 71 try { 72 searchManager = (SearchManager)Class.forName(clazz).newInstance(); 73 } 74 catch (Exception e) { 75 e.printStackTrace(); 76 throw new SearchInstantiationException("Error while tring to start the search manager: " + e); 77 } 78 79 searchManager.init(); 80 } 81 else { 82 logger.info(ConfigKeys.SEARCH_INDEXER_IMPLEMENTATION + " is not defined. Skipping."); 83 } 84 } 85 86 public static void index(Post post) 87 { 88 if (SystemGlobals.getBoolValue(ConfigKeys.SEARCH_INDEXING_ENABLED)) { 89 searchManager.index(post); 90 } 91 } 92 } 93 | Popular Tags |