Class DefaultFilterManager

  • All Implemented Interfaces:
    FilterManager, ModuleManager

    public class DefaultFilterManager
    extends BaseModuleManager
    implements FilterManager
    Manages the page filters. Page filters are components that can be executed at certain places:
    • Before the page is translated into HTML.
    • After the page has been translated into HTML.
    • Before the page is saved.
    • After the page has been saved.
    Using page filters allows you to modify the page data on-the-fly, and do things like adding your own custom WikiMarkup.

    The initial page filter configuration is kept in a file called "filters.xml". The format is really very simple:

    The <filter> -sections define the filters. For more information, please see the PageFilterConfiguration page in the JSPWiki distribution.
    • Constructor Detail

      • DefaultFilterManager

        public DefaultFilterManager​(Engine engine,
                                    java.util.Properties props)
                             throws WikiException
        Constructs a new FilterManager object.
        engine - The Engine which owns the FilterManager
        props - Properties to initialize the FilterManager with
        WikiException - If something goes wrong.
    • Method Detail

      • addPageFilter

        public void addPageFilter​(PageFilter f,
                                  int priority)
                           throws java.lang.IllegalArgumentException
        Adds a page filter to the queue. The priority defines in which order the page filters are run, the highest priority filters go in the queue first.

        In case two filters have the same priority, their execution order is the insertion order.

        Specified by:
        addPageFilter in interface FilterManager
        f - PageFilter to add
        priority - The priority in which position to add it in.
        java.lang.IllegalArgumentException - If the PageFilter is null or invalid.
      • initialize

        protected void initialize​(java.util.Properties props)
                           throws WikiException
        Initializes the filters from an XML file.
        props - The list of properties. Typically
        WikiException - If something goes wrong.
      • getFilterList

        public java.util.List<PageFiltergetFilterList()
        Returns the list of filters currently installed. Note that this is not a copy, but the actual list. So be careful with it.
        Specified by:
        getFilterList in interface FilterManager
        A List of PageFilter objects
      • destroy

        public void destroy()
        Notifies PageFilters to clean up their ressources.
        Specified by:
        destroy in interface FilterManager
      • fireEvent

        public void fireEvent​(int type,
                              Context context)
        Fires a WikiPageEvent of the provided type and WikiContext. Invalid WikiPageEvent types are ignored.
        type - the WikiPageEvent type to be fired.
        context - the WikiContext of the event.
        See Also:
      • modules

        public java.util.Collection<WikiModuleInfomodules()
        Returns a collection of modules currently managed by this ModuleManager. Each entry is an instance of the WikiModuleInfo class. This method should return something which is safe to iterate over, even if the underlying collection changes.
        Specified by:
        modules in interface ModuleManager
        A Collection of WikiModuleInfo instances.
      • getModuleInfo

        public getModuleInfo​(java.lang.String moduleName)
        Returns the WikiModuleInfo information about the provided moduleName.
        Specified by:
        getModuleInfo in interface ModuleManager
        The wikiModuleInfo