Package org.apache.wiki

# 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 Summary

Fields
Modifier and Type
Field
Description
`protected final Map<Class<?>,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_USE_2_X_ACL_LOGIC, PROP_WORKDIR`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`WikiEngine(jakarta.servlet.ServletContext context, 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.
``
`WikiEngine(Properties properties)`
Instantiate the WikiEngine using a given set of properties.

## Method Summary

Modifier and Type
Method
Description
`final void`
`addWikiEventListener(org.apache.wiki.event.WikiEventListener listener)`
`String`
`decodeName(String pagerequest)`
`String`
`encodeName(String pagename)`
`protected final void`
`fireEvent(int type)`
Fires a WikiEngineEvent to all registered listeners.
`protected final void`
`firePageEvent(int type, 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.
`Collection<String>`
`getAllInlinedImagePatterns()`
`Collection<String>`
`getAllInterWikiLinks()`
`String`
`getApplicationName()`
`AttachmentManager`
`getAttachmentManager()`
Deprecated.
use `getManager( AttachmentManager.class )` instead.
`<T> T`
`getAttribute(String key)`
`AuthenticationManager`
`getAuthenticationManager()`
Deprecated.
use `getManager( AuthenticationManager.class )` instead.
`AuthorizationManager`
`getAuthorizationManager()`
Deprecated.
use `getManager( AuthorizationManager.class )` instead.
`String`
`getBaseURL()`
`CommandResolver`
`getCommandResolver()`
Deprecated.
use `getManager( CommandResolver.class )` instead.
`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.
`String`
`getFinalPageName(String page)`
`String`
`getFrontPage()`
`String`
`getGlobalRSSURL()`
`GroupManager`
`getGroupManager()`
Deprecated.
use `getManager( GroupManager.class )` instead.
`static WikiEngine`
`getInstance(jakarta.servlet.ServletConfig config)`
Gets a WikiEngine related to this servlet.
`static WikiEngine`
`getInstance(jakarta.servlet.ServletConfig config, Properties props)`
Gets a WikiEngine related to the servlet.
`static WikiEngine`
`getInstance(jakarta.servlet.ServletContext context, Properties props)`
Gets a WikiEngine related to the servlet.
`InternationalizationManager`
`getInternationalizationManager()`
Deprecated.
use `getManager( InternationalizationManager.class )` instead.
`String`
`getInterWikiURL(String wikiName)`
`<T> T`
`getManager(Class<T> manager)`
`<T> List<T>`
`getManagers(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.
`String`
`getRootPath()`
`RSSGenerator`
`getRSSGenerator()`
Deprecated.
use `getManager( RSSGenerator.class )` instead.
`SearchManager`
`getSearchManager()`
Deprecated.
use `getManager( SearchManager.class )` instead.
`jakarta.servlet.ServletContext`
`getServletContext()`
`String`
`getSpecialPageReference(String original)`
`Date`
`getStartTime()`
`TasksManager`
`getTasksManager()`
Deprecated.
use `getManager( TaskManager.class )` instead.
`String`
`getTemplateDir()`
`TemplateManager`
`getTemplateManager()`
Deprecated.
use `getManager( TemplateManager.class )` instead.
`String`
`getURL(String context, String pageName, 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.
`Properties`
`getWikiProperties()`
`String`
`getWorkDir()`
`WorkflowManager`
`getWorkflowManager()`
Deprecated.
use `getManager( WorkflowManager.class )` instead.
`void`
`initialize(Properties props)`
Does all the real initialization.
`void`
`initReferenceManager()`
Initializes the reference manager.
`boolean`
`isConfigured()`
`<T> T`
`removeAttribute(String key)`
`final void`
`removeWikiEventListener(org.apache.wiki.event.WikiEventListener listener)`
`void`
`setAttribute(String key, 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 Details

### managers

protected final Map<Class<?>,Object> managers
Stores WikiEngine's associated managers.

## 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

public Properties 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

public String 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

public String 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

public Collection<String> getAllInterWikiLinks()

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

### getAllInlinedImagePatterns

public Collection<String> getAllInlinedImagePatterns()

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

### getSpecialPageReference

public String getSpecialPageReference(String original)

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

### getApplicationName

public String 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

public Charset 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 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 String getRootPath()

Specified by:
  `getRootPath` in interface `org.apache.wiki.api.core.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(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`