org.apache.wiki.api.engine
Interface PluginManager

All Known Implementing Classes:
DefaultPluginManager

public interface PluginManager


Field Summary
static String DEFAULT_PACKAGE
          This is the default package to try in case the instantiation fails.
static String PARAM_BODY
          The name of the body content.
static String PARAM_BOUNDS
          The name of the parameter containing the start and end positions in the read stream of the plugin text (stored as a two-element int[], start and end resp.).
static String PARAM_CMDLINE
          The name of the command line content parameter.
static String PARAM_DEBUG
          A special name to be used in case you want to see debug output
static String PROP_EXTERNALJARS
          The property name defining which external jars will be added to the classpath when searching for plugin classes.
static String PROP_SEARCHPATH
          The property name defining which packages will be searched for plugin classes.
 
Method Summary
 void enablePlugins(boolean enabled)
          Enables or disables plugin execution.
 String execute(WikiContext context, String commandline)
          Parses a plugin.
 String execute(WikiContext context, String classname, Map<String,String> params)
          Executes a plugin class in the given context.
 org.apache.oro.text.regex.Pattern getPluginPattern()
          Returns plugin insert pattern.
 String getPluginSearchPath()
          Returns plugins' search path.
 Collection modules()
          Returns a collection of modules currently managed by this ModuleManager.
 WikiPlugin newWikiPlugin(String pluginName, ResourceBundle rb)
          Creates a WikiPlugin.
 Map<String,String> parseArgs(String argstring)
          Parses plugin arguments.
 boolean pluginsEnabled()
          Returns plugin execution status.
 

Field Detail

PROP_SEARCHPATH

static final String PROP_SEARCHPATH
The property name defining which packages will be searched for plugin classes.

See Also:
Constant Field Values

PROP_EXTERNALJARS

static final String PROP_EXTERNALJARS
The property name defining which external jars will be added to the classpath when searching for plugin classes.

See Also:
Constant Field Values

DEFAULT_PACKAGE

static final String DEFAULT_PACKAGE
This is the default package to try in case the instantiation fails.

See Also:
Constant Field Values

PARAM_BODY

static final String PARAM_BODY
The name of the body content. Current value is "_body".

See Also:
Constant Field Values

PARAM_CMDLINE

static final String PARAM_CMDLINE
The name of the command line content parameter. The value is "_cmdline".

See Also:
Constant Field Values

PARAM_BOUNDS

static final String PARAM_BOUNDS
The name of the parameter containing the start and end positions in the read stream of the plugin text (stored as a two-element int[], start and end resp.).

See Also:
Constant Field Values

PARAM_DEBUG

static final String PARAM_DEBUG
A special name to be used in case you want to see debug output

See Also:
Constant Field Values
Method Detail

enablePlugins

void enablePlugins(boolean enabled)
Enables or disables plugin execution.

Parameters:
enabled - True, if plugins should be globally enabled; false, if disabled.

pluginsEnabled

boolean pluginsEnabled()
Returns plugin execution status. If false, plugins are not executed when they are encountered on a WikiPage, and an empty string is returned in their place.

Returns:
True, if plugins are enabled; false otherwise.

getPluginPattern

org.apache.oro.text.regex.Pattern getPluginPattern()
Returns plugin insert pattern.

Returns:
plugin insert pattern.

getPluginSearchPath

String getPluginSearchPath()
Returns plugins' search path.

Returns:
plugins' search path.

execute

String execute(WikiContext context,
               String classname,
               Map<String,String> params)
               throws PluginException
Executes a plugin class in the given context.

Used to be private, but is public since 1.9.21.

Parameters:
context - The current WikiContext.
classname - The name of the class. Can also be a shortened version without the package name, since the class name is searched from the package search path.
params - A parsed map of key-value pairs.
Returns:
Whatever the plugin returns.
Throws:
PluginException - If the plugin execution failed for some reason.
Since:
2.0

parseArgs

Map<String,String> parseArgs(String argstring)
                             throws IOException
Parses plugin arguments. Handles quotes and all other kewl stuff.

Special parameters

The plugin body is put into a special parameter defined by PARAM_BODY; the plugin's command line into a parameter defined by PARAM_CMDLINE; and the bounds of the plugin within the wiki page text by a parameter defined by PARAM_BOUNDS, whose value is stored as a two-element int[] array, i.e., [start,end].

Parameters:
argstring - The argument string to the plugin. This is typically a list of key-value pairs, using "'" to escape spaces in strings, followed by an empty line and then the plugin body. In case the parameter is null, will return an empty parameter list.
Returns:
A parsed list of parameters.
Throws:
IOException - If the parsing fails.

execute

String execute(WikiContext context,
               String commandline)
               throws PluginException
Parses a plugin. Plugin commands are of the form: [{INSERT myplugin WHERE param1=value1, param2=value2}] myplugin may either be a class name or a plugin alias.

This is the main entry point that is used.

Parameters:
context - The current WikiContext.
commandline - The full command line, including plugin name, parameters and body.
Returns:
HTML as returned by the plugin, or possibly an error message.
Throws:
PluginException - From the plugin itself, it propagates, waah!

modules

Collection modules()
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.

Returns:
A Collection of WikiModuleInfo instances.

newWikiPlugin

WikiPlugin newWikiPlugin(String pluginName,
                         ResourceBundle rb)
                         throws PluginException
Creates a WikiPlugin.

Parameters:
pluginName - plugin's classname
rb - ResourceBundle with i18ned text for exceptions.
Returns:
a WikiPlugin.
Throws:
PluginException - if there is a problem building the WikiPlugin.


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