01: package ru.emdev.EmForge.wiki.beanwrapper;
02:
03: import java.io.IOException;
04: import java.util.Collection;
05: import java.util.Properties;
06:
07: import org.springframework.context.ApplicationContext;
08:
09: import ru.emdev.EmForge.wiki.JspWikiEngineBean;
10:
11: import com.ecyrd.jspwiki.NoRequiredPropertyException;
12: import com.ecyrd.jspwiki.WikiEngine;
13: import com.ecyrd.jspwiki.WikiPage;
14: import com.ecyrd.jspwiki.providers.ProviderException;
15: import com.ecyrd.jspwiki.search.SearchProvider;
16:
17: /** Wrapper for SearchProvider allowed to use Spring-Beans in JspWiki;
18: *
19: * @author spopov
20: * @since 0.20
21: */
22: public class SearchProviderWrapper implements SearchProvider {
23: protected static final String BEAN_NAME_PROPERTY = "jspwiki.spring.searchProvider";
24: protected SearchProvider m_bean;
25:
26: public void initialize(WikiEngine engine, Properties properties)
27: throws NoRequiredPropertyException, IOException {
28:
29: ApplicationContext appContext = (ApplicationContext) properties
30: .get(JspWikiEngineBean.SPRING_CONTEXT_PROPERTY);
31:
32: m_bean = (SearchProvider) appContext.getBean(properties
33: .getProperty(BEAN_NAME_PROPERTY));
34:
35: m_bean.initialize(engine, properties);
36: }
37:
38: public Collection findPages(String query) throws ProviderException,
39: IOException {
40: return m_bean.findPages(query);
41: }
42:
43: public void pageRemoved(WikiPage page) {
44: m_bean.pageRemoved(page);
45: }
46:
47: public void reindexPage(WikiPage page) {
48: m_bean.reindexPage(page);
49: }
50:
51: public String getProviderInfo() {
52: return m_bean.getProviderInfo();
53: }
54:
55: }
|