|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wiki.modules.ModuleManager org.apache.wiki.plugin.DefaultPluginManager
public class DefaultPluginManager
Manages plugin classes. There exists a single instance of PluginManager per each instance of WikiEngine, that is, each JSPWiki instance.
A plugin is defined to have three parts:
[{INSERT org.apache.wiki.plugin.FunnyPlugin foo='bar' blob='goo' abcdefghijklmnopqrstuvw 01234567890}]The plugin class is "org.apache.wiki.plugin.FunnyPlugin", the parameters are "foo" and "blob" (having values "bar" and "goo", respectively), and the plugin body is then "abcdefghijklmnopqrstuvw\n01234567890". The plugin body is accessible via a special parameter called "_body".
If the parameter "debug" is set to "true" for the plugin, JSPWiki will output debugging information directly to the page if there is an exception.
The class name can be shortened, and marked without the package. For example, "FunnyPlugin" would be expanded to "org.apache.wiki.plugin.FunnyPlugin" automatically. It is also possible to define other packages, by setting the "jspwiki.plugin.searchPath" property. See the included jspwiki.properties file for examples.
Even though the nominal way of writing the plugin is
[{INSERT pluginclass WHERE param1=value1...}],it is possible to shorten this quite a lot, by skipping the INSERT, and WHERE words, and dropping the package name. For example:
[{INSERT org.apache.wiki.plugin.Counter WHERE name='foo'}]is the same as
[{Counter name='foo'}]
Since 2.3.25 you can also define a generic plugin XML properties file per each JAR file.
Janne Jalkanen foo.css code Janne Jalkanen
Plugin can implement multiple interfaces to let JSPWiki know at which stages they should be invoked:
Nested Class Summary | |
---|---|
static class |
DefaultPluginManager.WikiPluginInfo
Contains information about a bunch of plugins. |
Field Summary |
---|
Fields inherited from class org.apache.wiki.modules.ModuleManager |
---|
m_engine, PLUGIN_RESOURCE_LOCATION |
Fields inherited from interface org.apache.wiki.api.engine.PluginManager |
---|
DEFAULT_PACKAGE, PARAM_BODY, PARAM_BOUNDS, PARAM_CMDLINE, PARAM_DEBUG, PROP_EXTERNALJARS, PROP_SEARCHPATH |
Constructor Summary | |
---|---|
DefaultPluginManager(WikiEngine engine,
Properties props)
Create a new PluginManager. |
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<WikiModuleInfo> |
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. |
Methods inherited from class org.apache.wiki.modules.ModuleManager |
---|
checkCompatibility |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultPluginManager(WikiEngine engine, Properties props)
engine
- WikiEngine which owns this manager.props
- Contents of a "jspwiki.properties" file.Method Detail |
---|
public void enablePlugins(boolean enabled)
enablePlugins
in interface PluginManager
enabled
- True, if plugins should be globally enabled; false, if disabled.public boolean pluginsEnabled()
pluginsEnabled
in interface PluginManager
public org.apache.oro.text.regex.Pattern getPluginPattern()
getPluginPattern
in interface PluginManager
public String getPluginSearchPath()
getPluginSearchPath
in interface PluginManager
public String execute(WikiContext context, String classname, Map<String,String> params) throws PluginException
Used to be private, but is public since 1.9.21.
execute
in interface PluginManager
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.
PluginException
- If the plugin execution failed for
some reason.public Map<String,String> parseArgs(String argstring) throws IOException
PluginManager.PARAM_BODY
;
the plugin's command line into a parameter defined by PluginManager.PARAM_CMDLINE
;
and the bounds of the plugin within the wiki page text by a parameter defined
by PluginManager.PARAM_BOUNDS
, whose value is stored as a two-element int[] array,
i.e., [start,end].
parseArgs
in interface PluginManager
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.
IOException
- If the parsing fails.public String execute(WikiContext context, String commandline) throws PluginException
This is the main entry point that is used.
execute
in interface PluginManager
context
- The current WikiContext.commandline
- The full command line, including plugin name, parameters and body.
PluginException
- From the plugin itself, it propagates, waah!public Collection<WikiModuleInfo> modules()
modules
in interface PluginManager
modules
in class ModuleManager
public WikiPlugin newWikiPlugin(String pluginName, ResourceBundle rb) throws PluginException
WikiPlugin
.
newWikiPlugin
in interface PluginManager
pluginName
- plugin's classnamerb
- ResourceBundle
with i18ned text for exceptions.
WikiPlugin
.
PluginException
- if there is a problem building the WikiPlugin
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |