Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sugget: change to act as spring's way #58

Open
GoogleCodeExporter opened this issue Mar 23, 2015 · 0 comments
Open

Sugget: change to act as spring's way #58

GoogleCodeExporter opened this issue Mar 23, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant