com.ecyrd.jspwiki.render
Class RenderingManager

java.lang.Object
  extended by com.ecyrd.jspwiki.render.RenderingManager
All Implemented Interfaces:
PageFilter

public class RenderingManager
extends Object
implements PageFilter

This class provides a facade towards the differing rendering routines. You should use the routines in this manager instead of the ones in WikiEngine, if you don't want the different side effects to occur - such as WikiFilters.

This class also manages a rendering cache, i.e. documents are stored between calls. You may control the size of the cache by using the "jspwiki.renderingManager.cacheSize" parameter in jspwiki.properties. The property value is the number of items that are stored in the cache. By default, the value of this parameter is taken from the "jspwiki.cachingProvider.cacheSize" parameter (i.e. the rendering cache is the same size as the page cache), but you may control them separately.

You can turn caching completely off by stating a cacheSize of zero.

Since:
2.4
Author:
jalkanen

Field Summary
static String PROP_CACHESIZE
           
 
Constructor Summary
RenderingManager()
           
 
Method Summary
 String getHTML(WikiContext context, String pagedata)
          Convinience method for rendering, using the default parser and renderer.
 String getHTML(WikiContext context, WikiDocument doc)
          Simply renders a WikiDocument to a String.
 MarkupParser getParser(WikiContext context, String pagedata)
          Returns the default Parser for this context.
protected  WikiDocument getRenderedDocument(WikiContext context, String pagedata)
          Returns a cached document, if one is found.
 void initialize(Properties properties)
          Is called whenever the a new PageFilter is instantiated and reset.
 void initialize(WikiEngine engine, Properties properties)
          Initializes the RenderinManager.
 void postSave(WikiContext wikiContext, String content)
          Flushes the cache objects that refer to this page.
 String postTranslate(WikiContext wikiContext, String htmlContent)
          This method is called after a page has been fed through the TranslatorReader, so anything you are seeing here is translated content.
 String preSave(WikiContext wikiContext, String content)
          This method is called before the page has been saved to the PageProvider.
 String preTranslate(WikiContext wikiContext, String content)
          This method is called whenever a page has been loaded from the provider, but not yet been sent through the TranslatorReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_CACHESIZE

public static final String PROP_CACHESIZE
See Also:
Constant Field Values
Constructor Detail

RenderingManager

public RenderingManager()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
Initializes the RenderinManager.

Parameters:
engine - A WikiEngine instance.
properties - A list of properties to get parameters from.

getParser

public MarkupParser getParser(WikiContext context,
                              String pagedata)
Returns the default Parser for this context.

Parameters:
context - the wiki context
pagedata - the page data
Returns:
A MarkupParser instance.

getRenderedDocument

protected WikiDocument getRenderedDocument(WikiContext context,
                                           String pagedata)
                                    throws IOException
Returns a cached document, if one is found.

Parameters:
context - the wiki context
pagedata - the page data
Returns:
the rendered wiki document
Throws:
IOException

getHTML

public String getHTML(WikiContext context,
                      WikiDocument doc)
               throws IOException
Simply renders a WikiDocument to a String. This version does not get the document from the cache - in fact, it does not cache the document at all. This is very useful, if you have something that you want to render outside the caching routines. Because the cache is based on full pages, and the cache keys are based on names, use this routine if you're rendering anything for yourself.

Parameters:
context - The WikiContext to render in
doc - A proper WikiDocument
Returns:
Rendered HTML.
Throws:
IOException - If the WikiDocument is poorly formed.

getHTML

public String getHTML(WikiContext context,
                      String pagedata)
Convinience method for rendering, using the default parser and renderer. Note that you can't use this method to do any arbitrary rendering, as the pagedata MUST be the data from the that the WikiContext refers to - this method caches the HTML internally, and will return the cached version. If the pagedata is different from what was cached, will re-render and store the pagedata into the internal cache.

Parameters:
context - the wiki context
pagedata - the page data
Returns:
XHTML data.

initialize

public void initialize(Properties properties)
                throws FilterException
Description copied from interface: PageFilter
Is called whenever the a new PageFilter is instantiated and reset.

Specified by:
initialize in interface PageFilter
Throws:
FilterException

postSave

public void postSave(WikiContext wikiContext,
                     String content)
              throws FilterException
Flushes the cache objects that refer to this page.

Specified by:
postSave in interface PageFilter
Throws:
FilterException

postTranslate

public String postTranslate(WikiContext wikiContext,
                            String htmlContent)
                     throws FilterException
Description copied from interface: PageFilter
This method is called after a page has been fed through the TranslatorReader, so anything you are seeing here is translated content. If you want to do any of your own WikiMarkup2HTML translation, do it here.

Specified by:
postTranslate in interface PageFilter
Throws:
FilterException

preSave

public String preSave(WikiContext wikiContext,
                      String content)
               throws FilterException
Description copied from interface: PageFilter
This method is called before the page has been saved to the PageProvider.

Specified by:
preSave in interface PageFilter
Throws:
FilterException

preTranslate

public String preTranslate(WikiContext wikiContext,
                           String content)
                    throws FilterException
Description copied from interface: PageFilter
This method is called whenever a page has been loaded from the provider, but not yet been sent through the TranslatorReader. Note that you cannot do HTML translation here, because TranslatorReader is likely to escape it.

Specified by:
preTranslate in interface PageFilter
Parameters:
wikiContext - The current wikicontext.
content - WikiMarkup.
Throws:
FilterException