I am integrating wikimodel to my system, and using wikimodel to parse wiki
syntax. I need to do some customization to WikiReferenceParser, so how to
insert my customized WikiReferenceParser into wikimodel?
I change some wikimodel source code as following:
public class ProjectMediaWikiParser implements IWikiParser{
private IWikiReferenceParser wikiReferenceParser;
public void setWikiReferenceParser(IWikiReferenceParser referenceParser) {
this.wikiReferenceParser = referenceParser;
}
public void parse(Reader reader, IWemListener listener)
throws WikiParserException {
try {
MediawikiScanner scanner = new MediawikiScanner(reader);
scanner.setReferenceParser(wikiReferenceParser);
WikiScannerContext context = new WikiScannerContext(listener);
scanner.parse(context);
} catch (ParseException e) {
throw new WikiParserException(e);
}
}
}
The key point is that now WikiParser can accept injection of my customized
WikiReferenceParser through spring config.
You can see:
MediawikiScanner scanner = new MediawikiScanner(reader);
scanner.setReferenceParser(wikiReferenceParser);
I inject the referenceParser into javacc WikiScanner. For doing this, I
have to change javacc template, and recompile. The change like this:
private IWikiReferenceParser fReferenceParser;
public void setReferenceParser(IWikiReferenceParser referenceParser) {
this.fReferenceParser = referenceParser;
}
This phrase original code is:
private IWikiReferenceParser fReferenceParser = new
MediawikiReferenceParser
===============
I hope wikimodel author can do some refactor like spring's way.
Thanks a lot!
Original issue reported on code.google.com by fajaven on 2 Sep 2008 at 3:51
Original issue reported on code.google.com by
fajaven
on 2 Sep 2008 at 3:51