WikiPlugin is the Java interface for a JSPWiki plugin. As noted in the Javadocs:
The WikiPlugin interface contains a single method:
HTML, ready to be included into the rendered page.
PluginException - In case anything goes wrong.
Following is an example of a simple "Hello World" plugin. This returns an HTML <div> element containing the content of the text parameter, or "Hello World!" if it is absent.
public class HelloWorld implements WikiPlugin { public String execute( WikiContext context, Map<String,String> params ) throws PluginException { StringBuilder out = new StringBuilder(); try { out.append( "<div class=\"helloworld\">\n" ); String text = (String)params.get("text"); if ( text == null ) { out.append("Hello, World!"); } else { out.append( text ); } out.append( "</div>" ); } catch ( Exception e ) { out.append( "<div class=\"error\">\n" ); out.append( e.getClass().getName() + " thrown by HelloWorld plugin: " + e.getMessage() ); out.append( "</div>\n" ); } return out.toString(); } }
Once installed, this plugin would be invoked via the following WikiMarkup:
[{HelloWorld text='Good morning.'}]