Package org.apache.wiki

## Class WikiEngine

- java.lang.Object
- - org.apache.wiki.WikiEngine

All Implemented Interfaces:
  `Engine`

    public class WikiEngine
    extends java.lang.Object
    implements 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 Summary

Fields
`protected java.util.Map<java.lang.Class<?>,​java.lang.Object>` `managers` Stores WikiEngine's associated managers.

### Fields inherited from interface org.apache.wiki.api.core.Engine

`DEFAULT_INLINEPATTERN, DEFAULT_TEMPLATE_NAME, PREFS_COOKIE_NAME, PROP_ACL_MANAGER_IMPL, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, PROP_APPNAME, PROP_ENCODING, PROP_FRONTPAGE, PROP_INLINEIMAGEPTRN, PROP_INTERWIKIREF, PROP_MATCHPLURALS, PROP_NO_FILTER_ENCODING, PROP_REF_MANAGER_IMPL, PROP_SEARCHPATH, PROP_STOREUSERNAME, PROP_TEMPLATEDIR, PROP_URLCONSTRUCTOR, PROP_WORKDIR`

### Constructor Summary

Constructors
`` `WikiEngine​(java.util.Properties properties)` Instantiate the WikiEngine using a given set of properties.
`protected` `WikiEngine​(javax.servlet.ServletContext context, java.lang.String appid)` Instantiate using this method when you're running as a servlet and WikiEngine will figure out where to look for the property file.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`void` `addWikiEventListener​(WikiEventListener listener)`
`java.lang.String` `decodeName​(java.lang.String pagerequest)`
`java.lang.String` `encodeName​(java.lang.String pagename)`
`protected void` `fireEvent​(int type)` Fires a WikiEngineEvent to all registered listeners.
`protected void` `firePageEvent​(int type, java.lang.String pageName)` Fires a WikiPageEvent to all registered listeners.
`AclManager` `getAclManager()` Deprecated. use `getManager( AclManager.class )` instead.
`AdminBeanManager` `getAdminBeanManager()` Deprecated. use `getManager( AdminBeanManager.class )` instead.
`java.util.Collection<java.lang.String>` `getAllInlinedImagePatterns()`
`java.util.Collection<java.lang.String>` `getAllInterWikiLinks()`
`java.lang.String` `getApplicationName()`
`AttachmentManager` `getAttachmentManager()` Deprecated. use `getManager( AttachmentManager.class )` instead.
`<T> T` `getAttribute​(java.lang.String key)`
`AuthenticationManager` `getAuthenticationManager()` Deprecated. use `getManager( AuthenticationManager.class )` instead.
`AuthorizationManager` `getAuthorizationManager()` Deprecated. use `getManager( AuthorizationManager.class )` instead.
`java.lang.String` `getBaseURL()`
`CommandResolver` `getCommandResolver()` Deprecated. use `getManager( CommandResolver.class )` instead.
`java.nio.charset.Charset` `getContentEncoding()`
`DifferenceManager` `getDifferenceManager()` Deprecated. use `getManager( DifferenceManager.class )` instead.
`EditorManager` `getEditorManager()` Deprecated. use `getManager( EditorManager.class )` instead.
`FilterManager` `getFilterManager()` Deprecated. use `getManager( FilterManager.class )` instead.
`java.lang.String` `getFinalPageName​(java.lang.String page)`
`java.lang.String` `getFrontPage()`
`java.lang.String` `getGlobalRSSURL()`
`GroupManager` `getGroupManager()` Deprecated. use `getManager( GroupManager.class )` instead.
`static WikiEngine` `getInstance​(javax.servlet.ServletConfig config)` Gets a WikiEngine related to this servlet.
`static WikiEngine` `getInstance​(javax.servlet.ServletConfig config, java.util.Properties props)` Gets a WikiEngine related to the servlet.
`static WikiEngine` `getInstance​(javax.servlet.ServletContext context, java.util.Properties props)` Gets a WikiEngine related to the servlet.
`InternationalizationManager` `getInternationalizationManager()` Deprecated. use `getManager( InternationalizationManager.class )` instead.
`java.lang.String` `getInterWikiURL​(java.lang.String wikiName)`
`<T> T` `getManager​(java.lang.Class<T> manager)`
`<T> java.util.List<T>` `getManagers​(java.lang.Class<T> manager)`
`PageManager` `getPageManager()` Deprecated. use `getManager( PageManager.class )` instead.
`PageRenamer` `getPageRenamer()` Deprecated. use `getManager( PageRenamer.class )` instead.
`PluginManager` `getPluginManager()` Deprecated. use `getManager( PluginManager.class )` instead.
`ProgressManager` `getProgressManager()` Deprecated. use `getManager( ProgressManager.class )` instead.
`ReferenceManager` `getReferenceManager()` Deprecated. use `getManager( ReferenceManager.class )` instead.
`RenderingManager` `getRenderingManager()` Deprecated. use `getManager( RenderingManager.class )` instead.
`java.lang.String` `getRootPath()`
`RSSGenerator` `getRSSGenerator()` Deprecated. use `getManager( RSSGenerator.class )` instead.
`SearchManager` `getSearchManager()` Deprecated. use `getManager( SearchManager.class )` instead.
`javax.servlet.ServletContext` `getServletContext()`
`java.lang.String` `getSpecialPageReference​(java.lang.String original)`
`java.util.Date` `getStartTime()`
`TasksManager` `getTasksManager()` Deprecated. use `getManager( TaskManager.class )` instead.
`java.lang.String` `getTemplateDir()`
`TemplateManager` `getTemplateManager()` Deprecated. use `getManager( TemplateManager.class )` instead.
`java.lang.String` `getURL​(java.lang.String context, java.lang.String pageName, java.lang.String params)`
`URLConstructor` `getURLConstructor()` Deprecated. use `getManager( URLConstructor.class )` instead.
`UserManager` `getUserManager()` Deprecated. use `getManager( UserManager.class )` instead.
`VariableManager` `getVariableManager()` Deprecated. use `getManager( VariableManager.class )` instead.
`java.util.Properties` `getWikiProperties()`
`java.lang.String` `getWorkDir()`
`WorkflowManager` `getWorkflowManager()` Deprecated. use `getManager( WorkflowManager.class )` instead.
`void` `initialize​(java.util.Properties props)` Does all the real initialization.
`void` `initReferenceManager()` Initializes the reference manager.
`boolean` `isConfigured()`
`<T> T` `removeAttribute​(java.lang.String key)`
`void` `removeWikiEventListener​(WikiEventListener listener)`
`void` `setAttribute​(java.lang.String key, java.lang.Object value)`
`void` `shutdown()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.wiki.api.core.Engine

`adapt, findConfigFile, getPluginSearchPath, start, stop`

### Field Detail

#### managers

    protected final java.util.Map<java.lang.Class<?>,​java.lang.Object> managers

Stores WikiEngine's associated managers.

### Constructor Detail

#### WikiEngine

    public WikiEngine​(java.util.Properties properties)
               throws 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:
  `WikiException` - If the initialization fails.

#### WikiEngine

    protected WikiEngine​(javax.servlet.ServletContext context,
                         java.lang.String appid)
                  throws 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:
  `WikiException` - If the WikiEngine construction fails.

### Method Detail

#### getInstance

    public static WikiEngine getInstance​(javax.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​(javax.servlet.ServletConfig config,
                                         java.util.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​(javax.servlet.ServletContext context,
                                         java.util.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​(java.util.Properties props)
                    throws WikiException

Does all the real initialization.

Specified by:
  `initialize` in interface `Engine`
Throws:
  `WikiException`

#### getManager

    public <T> T getManager​(java.lang.Class<T> manager)

Specified by:
  `getManager` in interface `Engine`

#### getManagers

    public <T> java.util.List<T> getManagers​(java.lang.Class<T> manager)

Specified by:
  `getManagers` in interface `Engine`

#### isConfigured

    public boolean isConfigured()

Specified by:
  `isConfigured` in interface `Engine`

#### initReferenceManager

    public void initReferenceManager()
                              throws WikiException

Initializes the reference manager. Scans all existing WikiPages for internal links and adds them to the ReferenceManager object.

Throws:
  `WikiException` - If the reference manager initialization fails.

#### getWikiProperties

    public java.util.Properties getWikiProperties()

Specified by:
  `getWikiProperties` in interface `Engine`

#### getWorkDir

    public java.lang.String getWorkDir()

Specified by:
  `getWorkDir` in interface `Engine`

#### getTemplateDir

    public java.lang.String getTemplateDir()

Specified by:
  `getTemplateDir` in interface `Engine`

#### getStartTime

    public java.util.Date getStartTime()

Specified by:
  `getStartTime` in interface `Engine`

#### getBaseURL

    public java.lang.String getBaseURL()

Specified by:
  `getBaseURL` in interface `Engine`

#### getGlobalRSSURL

    public java.lang.String getGlobalRSSURL()

Specified by:
  `getGlobalRSSURL` in interface `Engine`

#### getInterWikiURL

    public java.lang.String getInterWikiURL​(java.lang.String wikiName)

Specified by:
  `getInterWikiURL` in interface `Engine`

#### getURL

    public java.lang.String getURL​(java.lang.String context,
                                   java.lang.String pageName,
                                   java.lang.String params)

Specified by:
  `getURL` in interface `Engine`

#### getFrontPage

    public java.lang.String getFrontPage()

Specified by:
  `getFrontPage` in interface `Engine`

#### getServletContext

    public javax.servlet.ServletContext getServletContext()

Specified by:
  `getServletContext` in interface `Engine`

#### getAllInterWikiLinks

    public java.util.Collection<java.lang.String> getAllInterWikiLinks()

Specified by:
  `getAllInterWikiLinks` in interface `Engine`

#### getAllInlinedImagePatterns

    public java.util.Collection<java.lang.String> getAllInlinedImagePatterns()

Specified by:
  `getAllInlinedImagePatterns` in interface `Engine`

#### getSpecialPageReference

    public java.lang.String getSpecialPageReference​(java.lang.String original)

Specified by:
  `getSpecialPageReference` in interface `Engine`

#### getApplicationName

    public java.lang.String getApplicationName()

Specified by:
  `getApplicationName` in interface `Engine`

#### getFinalPageName

    public java.lang.String getFinalPageName​(java.lang.String page)
                                      throws ProviderException

Specified by:
  `getFinalPageName` in interface `Engine`
Throws:
  `ProviderException`

#### encodeName

    public java.lang.String encodeName​(java.lang.String pagename)

Specified by:
  `encodeName` in interface `Engine`

#### decodeName

    public java.lang.String decodeName​(java.lang.String pagerequest)

Specified by:
  `decodeName` in interface `Engine`

#### getContentEncoding

    public java.nio.charset.Charset getContentEncoding()

Specified by:
  `getContentEncoding` in interface `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 `Engine`

#### getTemplateManager

    @Deprecated
    public TemplateManager getTemplateManager()

Deprecated.
use `getManager( TemplateManager.class )` instead.
Returns the current TemplateManager.

Returns:
  A TemplateManager instance.

#### getWorkflowManager

    @Deprecated
    public WorkflowManager 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
    public ReferenceManager getReferenceManager()

Deprecated.
use `getManager( ReferenceManager.class )` instead.
Returns this object's ReferenceManager.

Returns:
  The current ReferenceManager instance.
Since:
  1.6.1

#### getRenderingManager

    @Deprecated
    public RenderingManager 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
    public PluginManager getPluginManager()

Deprecated.
use `getManager( PluginManager.class )` instead.
Returns the current plugin manager.

Returns:
  The current PluginManager instance
Since:
  1.6.1

#### getVariableManager

    @Deprecated
    public VariableManager getVariableManager()

Deprecated.
use `getManager( VariableManager.class )` instead.
Returns the current variable manager.

Returns:
  The current VariableManager.

#### getPageManager

    @Deprecated
    public PageManager 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
    public CommandResolver getCommandResolver()

Deprecated.
use `getManager( CommandResolver.class )` instead.
Returns the CommandResolver for this wiki engine.

Returns:
  the resolver

#### getAttachmentManager

    @Deprecated
    public AttachmentManager 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
    public AuthorizationManager getAuthorizationManager()

Deprecated.
use `getManager( AuthorizationManager.class )` instead.
Returns the currently used authorization manager.

Returns:
  The current AuthorizationManager instance.

#### getAuthenticationManager

    @Deprecated
    public AuthenticationManager getAuthenticationManager()

Deprecated.
use `getManager( AuthenticationManager.class )` instead.
Returns the currently used authentication manager.

Returns:
  The current AuthenticationManager instance.

#### getFilterManager

    @Deprecated
    public FilterManager 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
    public SearchManager 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
    public ProgressManager getProgressManager()

Deprecated.
use `getManager( ProgressManager.class )` instead.
Returns the progress manager we're using

Returns:
  A ProgressManager.
Since:
  2.6

#### getRootPath

    public java.lang.String getRootPath()

Specified by:
  `getRootPath` in interface `Engine`

#### getURLConstructor

    @Deprecated
    public URLConstructor getURLConstructor()

Deprecated.
use `getManager( URLConstructor.class )` instead.

Returns:
  the URL constructor.
Since:
  2.2.6

#### getRSSGenerator

    @Deprecated
    public RSSGenerator 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
    public PageRenamer 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
    public UserManager getUserManager()

Deprecated.
use `getManager( UserManager.class )` instead.
Returns the UserManager employed by this WikiEngine.

Returns:
  The current UserManager instance.
Since:
  2.3

#### getTasksManager

    @Deprecated
    public TasksManager getTasksManager()

Deprecated.
use `getManager( TaskManager.class )` instead.
Returns the TasksManager employed by this WikiEngine.

Returns:
  The current TasksManager instance.

#### getGroupManager

    @Deprecated
    public GroupManager getGroupManager()

Deprecated.
use `getManager( GroupManager.class )` instead.
Returns the GroupManager employed by this WikiEngine.

Returns:
  The current GroupManager instance.
Since:
  2.3

#### getAdminBeanManager

    @Deprecated
    public AdminBeanManager getAdminBeanManager()

Deprecated.
use `getManager( AdminBeanManager.class )` instead.
Returns the current `AdminBeanManager`.

Returns:
  The current `AdminBeanManager`.
Since:
  2.6

#### getAclManager

    @Deprecated
    public AclManager 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
    public DifferenceManager getDifferenceManager()

Deprecated.
use `getManager( DifferenceManager.class )` instead.
Returns the DifferenceManager so that texts can be compared.

Returns:
  the difference manager.

#### getEditorManager

    @Deprecated
    public EditorManager getEditorManager()

Deprecated.
use `getManager( EditorManager.class )` instead.
Returns the current EditorManager instance.

Returns:
  The current EditorManager.

#### getInternationalizationManager

    @Deprecated
    public InternationalizationManager getInternationalizationManager()

Deprecated.
use `getManager( InternationalizationManager.class )` instead.
Returns the current i18n manager.

Returns:
  The current Intertan... Interante... Internatatializ... Whatever.

#### addWikiEventListener

    public final void addWikiEventListener​(WikiEventListener listener)

Specified by:
  `addWikiEventListener` in interface `Engine`

#### removeWikiEventListener

    public final void removeWikiEventListener​(WikiEventListener listener)

Specified by:
  `removeWikiEventListener` in interface `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,
                                       java.lang.String pageName)

Fires a WikiPageEvent to all registered listeners.

Parameters:
  `type` - the event type

#### setAttribute

    public void setAttribute​(java.lang.String key,
                             java.lang.Object value)

Specified by:
  `setAttribute` in interface `Engine`

#### getAttribute

    public <T> T getAttribute​(java.lang.String key)

Specified by:
  `getAttribute` in interface `Engine`

#### removeAttribute

    public <T> T removeAttribute​(java.lang.String key)

Specified by:
  `removeAttribute` in interface `Engine`