Java Doc for PluginManager.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » plugin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.plugin 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.ecyrd.jspwiki.modules.ModuleManager
      com.ecyrd.jspwiki.plugin.PluginManager

PluginManager
public class PluginManager extends ModuleManager (Code)
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:

  1. The plugin class
  2. The plugin parameters
  3. The plugin body
For example, in the following line of code:
 [{INSERT com.ecyrd.jspwiki.plugin.FunnyPlugin  foo='bar'
 blob='goo'
 abcdefghijklmnopqrstuvw
 01234567890}]
 
The plugin class is "com.ecyrd.jspwiki.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 "com.ecyrd.jspwiki.plugin.FunnyPlugin" automatically. It is also possible to defined 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 com.ecyrd.jspwiki.plugin.Counter WHERE name='foo'}]
 
is the same as
 [{Counter name='foo'}]
 

Plugin property files

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 lifecycle

Plugin can implement multiple interfaces to let JSPWiki know at which stages they should be invoked:

  • InitializablePlugin: If your plugin implements this interface, the initialize()-method is called once for this class before any actual execute() methods are called. You should use the initialize() for e.g. precalculating things. But notice that this method is really called only once during the entire WikiEngine lifetime. The InitializablePlugin is available from 2.5.30 onwards.
  • ParserStagePlugin: If you implement this interface, the executeParse() method is called when JSPWiki is forming the DOM tree. You will receive an incomplete DOM tree, as well as the regular parameters. However, since JSPWiki caches the DOM tree to speed up later places, which means that whatever this method returns would be irrelevant. You can do some DOM tree manipulation, though. The ParserStagePlugin is available from 2.5.30 onwards.
  • WikiPlugin: The regular kind of plugin which is executed at every rendering stage. Each new page load is guaranteed to invoke the plugin, unlike with the ParserStagePlugins.

author:
   Janne Jalkanen
since:
   1.6.1

Inner Class :final public static class WikiPluginInfo extends WikiModuleInfo

Field Summary
final public static  StringDEFAULT_FORMS_PACKAGE
    
final public static  StringDEFAULT_PACKAGE
     This is the default package to try in case the instantiation fails.
final public static  StringPARAM_BODY
     The name of the body content.
final public static  StringPARAM_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.).
final public static  StringPARAM_CMDLINE
     The name of the command line content parameter.
final public static  StringPARAM_DEBUG
    
final public static  StringPROP_SEARCHPATH
     The property name defining which packages will be searched for properties.

Constructor Summary
public  PluginManager(WikiEngine engine, Properties props)
     Create a new PluginManager.

Method Summary
public  voidenablePlugins(boolean enabled)
     Enables or disables plugin execution.
public  Stringexecute(WikiContext context, String classname, Map params)
     Executes a plugin class in the given context.

Used to be private, but is public since 1.9.21.
Parameters:
  context - The current WikiContext.
Parameters:
  classname - The name of the class.

public  Stringexecute(WikiContext context, String commandline)
     Parses a plugin.
public  voidexecuteParse(PluginContent content, WikiContext context)
    
public static  booleanisPluginLink(String link)
     Returns true if the link is really command to insert a plugin.

Currently we just check if the link starts with "{INSERT", or just plain "{" but not "{$".
Parameters:
  link - Link text, i.e.

public  Collectionmodules()
    
public  MapparseArgs(String argstring)
     Parses plugin arguments.
public  PluginContentparsePluginLine(WikiContext context, String commandline, int pos)
    
public  booleanpluginsEnabled()
     Returns plugin execution status.

Field Detail
DEFAULT_FORMS_PACKAGE
final public static String DEFAULT_FORMS_PACKAGE(Code)



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



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



PARAM_BOUNDS
final public static String PARAM_BOUNDS(Code)
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.).



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



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



PROP_SEARCHPATH
final public static String PROP_SEARCHPATH(Code)
The property name defining which packages will be searched for properties.




Constructor Detail
PluginManager
public PluginManager(WikiEngine engine, Properties props)(Code)
Create a new PluginManager.
Parameters:
  props - Contents of a "jspwiki.properties" file.




Method Detail
enablePlugins
public void enablePlugins(boolean enabled)(Code)
Enables or disables plugin execution.



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

Used to be private, but is public since 1.9.21.
Parameters:
  context - The current WikiContext.
Parameters:
  classname - The name of the class. Can also be ashortened version without the package name, since the class name is searched from thepackage search path.
Parameters:
  params - A parsed map of key-value pairs. Whatever the plugin returns.
throws:
  PluginException - If the plugin execution failed forsome reason.
since:
   2.0




execute
public String execute(WikiContext context, String commandline) throws PluginException(Code)
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.
Parameters:
  commandline - The full command line, including pluginname, parameters and body. HTML as returned by the plugin, or possibly an errormessage.




executeParse
public void executeParse(PluginContent content, WikiContext context) throws PluginException(Code)



isPluginLink
public static boolean isPluginLink(String link)(Code)
Returns true if the link is really command to insert a plugin.

Currently we just check if the link starts with "{INSERT", or just plain "{" but not "{$".
Parameters:
  link - Link text, i.e. the contents of text between []. True, if this link seems to be a command to insert a plugin here.




modules
public Collection modules()(Code)



parseArgs
public Map parseArgs(String argstring) throws IOException(Code)
Parses plugin arguments. Handles quotes and all other kewl stuff.

Special parameters

The plugin body is put into a special parameter defined by 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].
Parameters:
  argstring - The argument string to the plugin. This istypically a list of key-value pairs, using "'" to escapespaces in strings, followed by an empty line and then theplugin body. In case the parameter is null, will return anempty parameter list. A parsed list of parameters.
throws:
  IOException - If the parsing fails.



parsePluginLine
public PluginContent parsePluginLine(WikiContext context, String commandline, int pos) throws PluginException(Code)



pluginsEnabled
public boolean pluginsEnabled()(Code)
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.



Fields inherited from com.ecyrd.jspwiki.modules.ModuleManager
final public static String LOAD_INCOMPATIBLE_MODULES(Code)(Java Doc)
final public static String PLUGIN_RESOURCE_LOCATION(Code)(Java Doc)
protected WikiEngine m_engine(Code)(Java Doc)

Methods inherited from com.ecyrd.jspwiki.modules.ModuleManager
public boolean checkCompatibility(WikiModuleInfo info)(Code)(Java Doc)
abstract public Collection modules()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.