Class WikiEngine

java.lang.Object
org.apache.wiki.WikiEngine
All Implemented Interfaces:
org.apache.wiki.api.core.Engine

public class WikiEngine extends Object implements org.apache.wiki.api.core.Engine
Main implementation for Engine.

Using this class: Always get yourself an instance from JSP page by using the WikiEngine.getInstance(..) method. Never create a new WikiEngine() from scratch, unless you're writing tests.

  • Field Details

  • Constructor Details

    • WikiEngine

      public WikiEngine(Properties properties) throws org.apache.wiki.api.exceptions.WikiException
      Instantiate the WikiEngine using a given set of properties. Use this constructor for testing purposes only.
      Parameters:
      properties - A set of properties to use to initialize this WikiEngine.
      Throws:
      org.apache.wiki.api.exceptions.WikiException - If the initialization fails.
    • WikiEngine

      protected WikiEngine(jakarta.servlet.ServletContext context, String appid) throws org.apache.wiki.api.exceptions.WikiException
      Instantiate using this method when you're running as a servlet and WikiEngine will figure out where to look for the property file. Do not use this method - use WikiEngine.getInstance() instead.
      Parameters:
      context - A ServletContext.
      appid - An Application ID. This application is a unique random string which is used to recognize this WikiEngine.
      Throws:
      org.apache.wiki.api.exceptions.WikiException - If the WikiEngine construction fails.
  • Method Details

    • getInstance

      public static WikiEngine getInstance(jakarta.servlet.ServletConfig config) throws InternalWikiException
      Gets a WikiEngine related to this servlet. Since this method is only called from JSP pages (and JspInit()) to be specific, we throw a RuntimeException if things don't work.
      Parameters:
      config - The ServletConfig object for this servlet.
      Returns:
      A WikiEngine instance.
      Throws:
      InternalWikiException - in case something fails. This is a RuntimeException, so be prepared for it.
    • getInstance

      public static WikiEngine getInstance(jakarta.servlet.ServletConfig config, Properties props)
      Gets a WikiEngine related to the servlet. Works like getInstance(ServletConfig), but does not force the Properties object. This method is just an optional way of initializing a WikiEngine for embedded JSPWiki applications; normally, you should use getInstance(ServletConfig).
      Parameters:
      config - The ServletConfig of the webapp servlet/JSP calling this method.
      props - A set of properties, or null, if we are to load JSPWiki's default jspwiki.properties (this is the usual case).
      Returns:
      One well-behaving WikiEngine instance.
    • getInstance

      public static WikiEngine getInstance(jakarta.servlet.ServletContext context, Properties props) throws InternalWikiException
      Gets a WikiEngine related to the servlet. Works just like getInstance( ServletConfig )
      Parameters:
      context - The ServletContext of the webapp servlet/JSP calling this method.
      props - A set of properties, or null, if we are to load JSPWiki's default jspwiki.properties (this is the usual case).
      Returns:
      One fully functional, properly behaving WikiEngine.
      Throws:
      InternalWikiException - If the WikiEngine instantiation fails.
    • initialize

      public void initialize(Properties props) throws org.apache.wiki.api.exceptions.WikiException
      Does all the real initialization.
      Specified by:
      initialize in interface org.apache.wiki.api.core.Engine
      Throws:
      org.apache.wiki.api.exceptions.WikiException
    • getManager

      public <T> T getManager(Class<T> manager)
      Specified by:
      getManager in interface org.apache.wiki.api.core.Engine
    • getManagers

      public <T> List<T> getManagers(Class<T> manager)
      Specified by:
      getManagers in interface org.apache.wiki.api.core.Engine
    • isConfigured

      public boolean isConfigured()
      Specified by:
      isConfigured in interface org.apache.wiki.api.core.Engine
    • initReferenceManager

      public void initReferenceManager() throws org.apache.wiki.api.exceptions.WikiException
      Initializes the reference manager. Scans all existing WikiPages for internal links and adds them to the ReferenceManager object.
      Throws:
      org.apache.wiki.api.exceptions.WikiException - If the reference manager initialization fails.
    • getWikiProperties

      Specified by:
      getWikiProperties in interface org.apache.wiki.api.core.Engine
    • getWorkDir

      public String getWorkDir()
      Specified by:
      getWorkDir in interface org.apache.wiki.api.core.Engine
    • getTemplateDir

      Specified by:
      getTemplateDir in interface org.apache.wiki.api.core.Engine
    • getStartTime

      public Date getStartTime()
      Specified by:
      getStartTime in interface org.apache.wiki.api.core.Engine
    • getBaseURL

      public String getBaseURL()
      Specified by:
      getBaseURL in interface org.apache.wiki.api.core.Engine
    • getGlobalRSSURL

      Specified by:
      getGlobalRSSURL in interface org.apache.wiki.api.core.Engine
    • getInterWikiURL

      public String getInterWikiURL(String wikiName)
      Specified by:
      getInterWikiURL in interface org.apache.wiki.api.core.Engine
    • getURL

      public String getURL(String context, String pageName, String params)
      Specified by:
      getURL in interface org.apache.wiki.api.core.Engine
    • getFrontPage

      public String getFrontPage()
      Specified by:
      getFrontPage in interface org.apache.wiki.api.core.Engine
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      Specified by:
      getServletContext in interface org.apache.wiki.api.core.Engine
    • getAllInterWikiLinks

      Specified by:
      getAllInterWikiLinks in interface org.apache.wiki.api.core.Engine
    • getAllInlinedImagePatterns

      Specified by:
      getAllInlinedImagePatterns in interface org.apache.wiki.api.core.Engine
    • getSpecialPageReference

      Specified by:
      getSpecialPageReference in interface org.apache.wiki.api.core.Engine
    • getApplicationName

      Specified by:
      getApplicationName in interface org.apache.wiki.api.core.Engine
    • getFinalPageName

      public String getFinalPageName(String page) throws org.apache.wiki.api.exceptions.ProviderException
      Specified by:
      getFinalPageName in interface org.apache.wiki.api.core.Engine
      Throws:
      org.apache.wiki.api.exceptions.ProviderException
    • encodeName

      public String encodeName(String pagename)
      Specified by:
      encodeName in interface org.apache.wiki.api.core.Engine
    • decodeName

      public String decodeName(String pagerequest)
      Specified by:
      decodeName in interface org.apache.wiki.api.core.Engine
    • getContentEncoding

      Specified by:
      getContentEncoding in interface org.apache.wiki.api.core.Engine
    • shutdown

      public void shutdown()

      It is called by WikiServlet.destroy(). When this method is called, it fires a "shutdown" WikiEngineEvent to all registered listeners.

      Specified by:
      shutdown in interface org.apache.wiki.api.core.Engine
    • getTemplateManager

      Deprecated.
      use getManager( TemplateManager.class ) instead.
      Returns the current TemplateManager.
      Returns:
      A TemplateManager instance.
    • getWorkflowManager

      Deprecated.
      use getManager( WorkflowManager.class ) instead.
      Returns the WorkflowManager associated with this WikiEngine. If the WikiEngine has not been initialized, this method will return null.
      Returns:
      the task queue
    • getReferenceManager

      Deprecated.
      use getManager( ReferenceManager.class ) instead.
      Returns this object's ReferenceManager.
      Returns:
      The current ReferenceManager instance.
      Since:
      1.6.1
    • getRenderingManager

      Deprecated.
      use getManager( RenderingManager.class ) instead.
      Returns the current rendering manager for this wiki application.
      Returns:
      A RenderingManager object.
      Since:
      2.3.27
    • getPluginManager

      Deprecated.
      use getManager( PluginManager.class ) instead.
      Returns the current plugin manager.
      Returns:
      The current PluginManager instance
      Since:
      1.6.1
    • getVariableManager

      Deprecated.
      use getManager( VariableManager.class ) instead.
      Returns the current variable manager.
      Returns:
      The current VariableManager.
    • getPageManager

      Deprecated.
      use getManager( PageManager.class ) instead.
      Returns the current PageManager which is responsible for storing and managing WikiPages.
      Returns:
      The current PageManager instance.
    • getCommandResolver

      Deprecated.
      use getManager( CommandResolver.class ) instead.
      Returns the CommandResolver for this wiki engine.
      Returns:
      the resolver
    • getAttachmentManager

      Deprecated.
      use getManager( AttachmentManager.class ) instead.
      Returns the current AttachmentManager, which is responsible for storing and managing attachments.
      Returns:
      The current AttachmentManager instance
      Since:
      1.9.31.
    • getAuthorizationManager

      Deprecated.
      use getManager( AuthorizationManager.class ) instead.
      Returns the currently used authorization manager.
      Returns:
      The current AuthorizationManager instance.
    • getAuthenticationManager

      Deprecated.
      use getManager( AuthenticationManager.class ) instead.
      Returns the currently used authentication manager.
      Returns:
      The current AuthenticationManager instance.
    • getFilterManager

      Deprecated.
      use getManager( FilterManager.class ) instead.
      Returns the manager responsible for the filters.
      Returns:
      The current FilterManager instance.
      Since:
      2.1.88
    • getSearchManager

      Deprecated.
      use getManager( SearchManager.class ) instead.
      Returns the manager responsible for searching the Wiki.
      Returns:
      The current SearchManager instance.
      Since:
      2.2.21
    • getProgressManager

      Deprecated.
      use getManager( ProgressManager.class ) instead.
      Returns the progress manager we're using
      Returns:
      A ProgressManager.
      Since:
      2.6
    • getRootPath

      public String getRootPath()
      Specified by:
      getRootPath in interface org.apache.wiki.api.core.Engine
    • getURLConstructor

      Deprecated.
      use getManager( URLConstructor.class ) instead.
      Returns:
      the URL constructor.
      Since:
      2.2.6
    • getRSSGenerator

      Deprecated.
      use getManager( RSSGenerator.class ) instead.
      Returns the RSSGenerator. If the property jspwiki.rss.generate has not been set to true, this method will return null, and callers should check for this value.
      Returns:
      the RSS generator
      Since:
      2.1.165
    • getPageRenamer

      Deprecated.
      use getManager( PageRenamer.class ) instead.
      Returns the PageRenamer employed by this WikiEngine.
      Returns:
      The current PageRenamer instance.
      Since:
      2.5.141
    • getUserManager

      Deprecated.
      use getManager( UserManager.class ) instead.
      Returns the UserManager employed by this WikiEngine.
      Returns:
      The current UserManager instance.
      Since:
      2.3
    • getTasksManager

      Deprecated.
      use getManager( TaskManager.class ) instead.
      Returns the TasksManager employed by this WikiEngine.
      Returns:
      The current TasksManager instance.
    • getGroupManager

      Deprecated.
      use getManager( GroupManager.class ) instead.
      Returns the GroupManager employed by this WikiEngine.
      Returns:
      The current GroupManager instance.
      Since:
      2.3
    • getAdminBeanManager

      Deprecated.
      use getManager( AdminBeanManager.class ) instead.
      Returns the current AdminBeanManager.
      Returns:
      The current AdminBeanManager.
      Since:
      2.6
    • getAclManager

      Deprecated.
      use getManager( AclManager.class ) instead.
      Returns the AclManager employed by this WikiEngine. The AclManager is lazily initialized.

      The AclManager implementing class may be set by the System property Engine.PROP_ACL_MANAGER_IMPL.

      Returns:
      The current AclManager.
      Since:
      2.3
    • getDifferenceManager

      Deprecated.
      use getManager( DifferenceManager.class ) instead.
      Returns the DifferenceManager so that texts can be compared.
      Returns:
      the difference manager.
    • getEditorManager

      Deprecated.
      use getManager( EditorManager.class ) instead.
      Returns the current EditorManager instance.
      Returns:
      The current EditorManager.
    • getInternationalizationManager

      Deprecated.
      use getManager( InternationalizationManager.class ) instead.
      Returns the current i18n manager.
      Returns:
      The current Intertan... Interante... Internatatializ... Whatever.
    • addWikiEventListener

      public final void addWikiEventListener(org.apache.wiki.event.WikiEventListener listener)
      Specified by:
      addWikiEventListener in interface org.apache.wiki.api.core.Engine
    • removeWikiEventListener

      public final void removeWikiEventListener(org.apache.wiki.event.WikiEventListener listener)
      Specified by:
      removeWikiEventListener in interface org.apache.wiki.api.core.Engine
    • fireEvent

      protected final void fireEvent(int type)
      Fires a WikiEngineEvent to all registered listeners.
      Parameters:
      type - the event type
    • firePageEvent

      protected final void firePageEvent(int type, String pageName)
      Fires a WikiPageEvent to all registered listeners.
      Parameters:
      type - the event type
    • setAttribute

      public void setAttribute(String key, Object value)
      Specified by:
      setAttribute in interface org.apache.wiki.api.core.Engine
    • getAttribute

      public <T> T getAttribute(String key)
      Specified by:
      getAttribute in interface org.apache.wiki.api.core.Engine
    • removeAttribute

      public <T> T removeAttribute(String key)
      Specified by:
      removeAttribute in interface org.apache.wiki.api.core.Engine