1 package org.tigris.scarab.util.word; 2 3 48 49 import org.apache.fulcrum.TurbineServices; 50 import org.apache.turbine.services.yaaficomponent.YaafiComponentService; 51 import org.tigris.scarab.util.Log; 52 53 59 public class SearchFactory { 60 private static SearchIndex searchIndex; 61 62 public static SearchIndex getInstance() throws InstantiationException 63 { 64 SearchIndex result = searchIndex; 65 66 if (result == null) 67 { 68 try { 69 YaafiComponentService yaafi = (YaafiComponentService) TurbineServices.getInstance().getService( 70 YaafiComponentService.SERVICE_NAME); 71 result = (SearchIndex) yaafi.lookup(SearchIndex.class.getName()); 72 } catch (Exception e) { 73 String str = "Could not create new instance of SearchIndex. " 74 + "Could be a result of insufficient permission " 75 + "to write the Index to the disk. The default is to " 76 + "write the Index into the WEB-INF/index directory."; 77 Log.get().error(str, e); 78 throw new InstantiationException (str); } 80 } 81 return result; 82 } 83 84 88 public static void releaseInstance(SearchIndex searchIndex) 89 { 90 YaafiComponentService yaafi = (YaafiComponentService) TurbineServices.getInstance().getService( 91 YaafiComponentService.SERVICE_NAME); 92 searchIndex.clear(); 93 yaafi.release(searchIndex); 94 } 95 96 97 101 public static void setSearchIndex(SearchIndex searchIndex) 102 { 103 SearchFactory.searchIndex = searchIndex; 104 } 105 106 } 107 108 | Popular Tags |