Interface PluginManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_PACKAGE
      This is the default package to try in case the instantiation fails.
      static java.lang.String PARAM_BODY
      The name of the body content.
      static java.lang.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 java.lang.String PARAM_CMDLINE
      The name of the command line content parameter.
      static java.lang.String PARAM_DEBUG
      A special name to be used in case you want to see debug output
      static java.lang.String PROP_EXTERNALJARS
      The property name defining which external jars will be added to the classpath when searching for plugin classes.
    • Field Detail

      • PROP_EXTERNALJARS

        static final java.lang.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
      • PARAM_BOUNDS

        static final java.lang.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
    • 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.
      • execute

        java.lang.String execute​(Context context,
                                 java.lang.String classname,
                                 java.util.Map<java.lang.String,​java.lang.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

        java.util.Map<java.lang.String,​java.lang.String> parseArgs​(java.lang.String argstring)
                                                                  throws java.io.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:
        java.io.IOException - If the parsing fails.
      • execute

        java.lang.String execute​(Context context,
                                 java.lang.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!