001: package ru.emdev.EmForge.wiki.beanwrapper;
002:
003: import java.io.IOException;
004: import java.util.Collection;
005: import java.util.Date;
006: import java.util.List;
007: import java.util.Properties;
008:
009: import org.springframework.context.ApplicationContext;
010:
011: import ru.emdev.EmForge.wiki.JspWikiEngineBean;
012:
013: import com.ecyrd.jspwiki.NoRequiredPropertyException;
014: import com.ecyrd.jspwiki.QueryItem;
015: import com.ecyrd.jspwiki.WikiEngine;
016: import com.ecyrd.jspwiki.WikiPage;
017: import com.ecyrd.jspwiki.providers.ProviderException;
018: import com.ecyrd.jspwiki.providers.VersioningProvider;
019: import com.ecyrd.jspwiki.providers.WikiPageProvider;
020:
021: /** Wrapper for WikiPageProvider allowed to use Spring-Beans in JspWiki
022: *
023: */
024: public class PageProviderWrapper implements WikiPageProvider,
025: VersioningProvider {
026: protected static final String BEAN_NAME_PROPERTY = "jspwiki.spring.pageProvider";
027: protected WikiPageProvider m_bean;
028:
029: public void initialize(WikiEngine arg0, Properties arg1)
030: throws NoRequiredPropertyException, IOException {
031: ApplicationContext appContext = (ApplicationContext) arg1
032: .get(JspWikiEngineBean.SPRING_CONTEXT_PROPERTY);
033:
034: m_bean = (WikiPageProvider) appContext.getBean(arg1
035: .getProperty(BEAN_NAME_PROPERTY));
036:
037: m_bean.initialize(arg0, arg1);
038: }
039:
040: public void deletePage(String arg0) throws ProviderException {
041: m_bean.deletePage(arg0);
042:
043: }
044:
045: public void deleteVersion(String arg0, int arg1)
046: throws ProviderException {
047: m_bean.deleteVersion(arg0, arg1);
048: }
049:
050: public Collection findPages(QueryItem[] arg0) {
051: return m_bean.findPages(arg0);
052: }
053:
054: public Collection getAllChangedSince(Date arg0) {
055: return m_bean.getAllChangedSince(arg0);
056: }
057:
058: public Collection getAllPages() throws ProviderException {
059: return m_bean.getAllPages();
060: }
061:
062: public int getPageCount() throws ProviderException {
063: return m_bean.getPageCount();
064: }
065:
066: public WikiPage getPageInfo(String arg0, int arg1)
067: throws ProviderException {
068: return m_bean.getPageInfo(arg0, arg1);
069: }
070:
071: public String getPageText(String arg0, int arg1)
072: throws ProviderException {
073: return m_bean.getPageText(arg0, arg1);
074: }
075:
076: public List getVersionHistory(String arg0) throws ProviderException {
077: return m_bean.getVersionHistory(arg0);
078: }
079:
080: public void movePage(String arg0, String arg1)
081: throws ProviderException {
082: m_bean.movePage(arg0, arg1);
083: }
084:
085: public boolean pageExists(String arg0) {
086: return m_bean.pageExists(arg0);
087: }
088:
089: public void putPageText(WikiPage arg0, String arg1)
090: throws ProviderException {
091: m_bean.putPageText(arg0, arg1);
092: }
093:
094: public String getProviderInfo() {
095: return m_bean.getProviderInfo();
096: }
097:
098: public boolean pageExists(String arg0, int arg1) {
099: VersioningProvider versioningBean = (VersioningProvider) m_bean;
100: return versioningBean.pageExists(arg0, arg1);
101: }
102:
103: }
|