use of org.apache.wiki.WikiBackgroundThread in project jspwiki by apache.
the class SearchManagerBean method reload.
/**
* Starts a background thread which goes through all the pages and adds them
* to the reindex queue.
* <p>
* This method prevents itself from being called twice.
*/
public synchronized void reload() {
if (m_updater == null) {
m_updater = new WikiBackgroundThread(m_engine, 0) {
int m_count;
int m_max;
public void startupTask() throws Exception {
super.startupTask();
setName("Reindexer started");
}
@SuppressWarnings("unchecked")
public void backgroundTask() throws Exception {
Collection<WikiPage> allPages = m_engine.getPageManager().getAllPages();
SearchManager mgr = m_engine.getSearchManager();
m_max = allPages.size();
ProgressItem pi = new ProgressItem() {
public int getProgress() {
return 100 * m_count / m_max;
}
};
m_engine.getProgressManager().startProgress(pi, PROGRESS_ID);
for (WikiPage page : allPages) {
mgr.reindexPage(page);
m_count++;
}
m_engine.getProgressManager().stopProgress(PROGRESS_ID);
shutdown();
m_updater = null;
}
};
m_updater.start();
}
}
Aggregations