Package org.apache.wiki.plugin
Interface PluginManager
- All Superinterfaces:
ModuleManager
- All Known Implementing Classes:
DefaultPluginManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
This is the default package to try in case the instantiation fails.static final String
The name of the body content.static final String
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 final String
The name of the command line content parameter.static final String
A special name to be used in case you want to see debug outputstatic final String
The property name defining which external jars will be added to the classpath when searching for plugin classes.Fields inherited from interface org.apache.wiki.modules.ModuleManager
PLUGIN_RESOURCE_LOCATION
-
Method Summary
Modifier and TypeMethodDescriptionvoid
enablePlugins
(boolean enabled) Enables or disables plugin execution.Parses a plugin.Executes a plugin class in the given context.org.apache.oro.text.regex.Pattern
Returns plugin insert pattern.newWikiPlugin
(String pluginName, ResourceBundle rb) Creates aPlugin
.Parses plugin arguments.boolean
Returns plugin execution status.Methods inherited from interface org.apache.wiki.modules.ModuleManager
checkCompatibility, getModuleInfo, modules
-
Field Details
-
PROP_EXTERNALJARS
The property name defining which external jars will be added to the classpath when searching for plugin classes.- See Also:
-
DEFAULT_PACKAGE
This is the default package to try in case the instantiation fails.- See Also:
-
PARAM_BODY
The name of the body content. Current value is "_body".- See Also:
-
PARAM_CMDLINE
The name of the command line content parameter. The value is "_cmdline".- See Also:
-
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:
-
PARAM_DEBUG
A special name to be used in case you want to see debug output- See Also:
-
-
Method Details
-
enablePlugins
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.
-
execute
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
Parses plugin arguments. Handles quotes and all other kewl stuff.Special parameters
The plugin body is put into a special parameter defined byPARAM_BODY
; the plugin's command line into a parameter defined byPARAM_CMDLINE
; and the bounds of the plugin within the wiki page text by a parameter defined byPARAM_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
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!
-
newWikiPlugin
Creates aPlugin
.- Parameters:
pluginName
- plugin's classnamerb
-ResourceBundle
with i18ned text for exceptions.- Returns:
- a
Plugin
. - Throws:
PluginException
- if there is a problem building thePlugin
.
-