org.apache.wiki.render
Class RenderingManager

java.lang.Object
  extended by org.apache.wiki.render.RenderingManager
All Implemented Interfaces:
EventListener, WikiEventListener, InternalModule

public class RenderingManager
extends Object
implements WikiEventListener, InternalModule

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 cache by tweaking the ehcache.xml file.

Since:
2.4

Field Summary
static String DEFAULT_RENDERER
          The name of the default renderer.
static String DOCUMENTCACHE_NAME
          Name of the regular page cache.
static String VAR_EXECUTE_PLUGINS
          Variable name which tells whether plugins should be executed or not.
static String WYSIWYG_EDITOR_MODE
          Name of the WikiContext variable which is set to Boolean.TRUE or Boolean.FALSE depending on whether WYSIWYG is currently in effect.
 
Constructor Summary
RenderingManager()
           
 
Method Summary
 void actionPerformed(WikiEvent event)
          Flushes the document cache in response to a POST_SAVE_BEGIN event.
 String getHTML(WikiContext context, String pagedata)
          Convenience 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.
 WikiRenderer getRenderer(WikiContext context, WikiDocument doc)
          Returns a WikiRenderer instance, initialized with the given context and doc.
 void initialize(WikiEngine engine, Properties properties)
          Initializes the RenderingManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RENDERER

public static final String DEFAULT_RENDERER
The name of the default renderer.


DOCUMENTCACHE_NAME

public static final String DOCUMENTCACHE_NAME
Name of the regular page cache.

See Also:
Constant Field Values

WYSIWYG_EDITOR_MODE

public static final String WYSIWYG_EDITOR_MODE
Name of the WikiContext variable which is set to Boolean.TRUE or Boolean.FALSE depending on whether WYSIWYG is currently in effect.

See Also:
Constant Field Values

VAR_EXECUTE_PLUGINS

public static final String VAR_EXECUTE_PLUGINS
Variable name which tells whether plugins should be executed or not. Value can be either Boolean.TRUE or Boolean.FALSE.

See Also:
Constant Field Values
Constructor Detail

RenderingManager

public RenderingManager()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
                throws WikiException
Initializes the RenderingManager. Checks for cache size settings, initializes the document cache. Looks for alternative WikiRenderers, initializes one, or the default XHTMLRenderer, for use.

Parameters:
engine - A WikiEngine instance.
properties - A list of properties to get parameters from.
Throws:
WikiException - If the manager could not be initialized.

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 - If rendering cannot be accomplished

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.

getRenderer

public WikiRenderer getRenderer(WikiContext context,
                                WikiDocument doc)
Returns a WikiRenderer instance, initialized with the given context and doc. The object is an XHTMLRenderer, unless overridden in jspwiki.properties with PROP_RENDERER.

Parameters:
context - The WikiContext
doc - The document to render
Returns:
A WikiRenderer for this document, or null, if no such renderer could be instantiated.

getHTML

public String getHTML(WikiContext context,
                      String pagedata)
Convenience 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.

actionPerformed

public void actionPerformed(WikiEvent event)
Flushes the document cache in response to a POST_SAVE_BEGIN event.

Specified by:
actionPerformed in interface WikiEventListener
Parameters:
event - a WikiEvent object
See Also:
WikiEventListener.actionPerformed(org.apache.wiki.event.WikiEvent)


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.