Confluence Docs 2.10 : Component Plugins
This page last changed on Dec 02, 2008 by smaddox.
On this page: Error formatting macro: toc: java.lang.NullPointerException
Recommended Plugin Module TypeThe Component plugin module described below is available to OSGi-based plugins using version 2.x of the Atlassian Plugin Framework, supported in Confluence 2.10 and later. We recommend that you use the new plugin module type described below, rather than the old-style Component and Spring Component module types. Confluence still supports the earlier module types, but the new OSGi-based plugin framework fixes a number of bugs and limitations experienced by the old-style plugin modules. Purpose of this Module TypeComponent plugin modules enable you to share Java components between other modules in your plugin and with other plugins in the application. ConfigurationThe root element for the Component plugin module is component. It allows the following attributes and child elements for configuration: Attributes
Elements
ExampleHere is an example atlassian-plugin.xml file containing a single public component: <atlassian-plugin name="Hello World" key="example.plugin.helloworld" pluginsVersion="2"> <plugin-info> <description>A basic component module test</description> <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/> <version>1.0</version> </plugin-info> <component key="helloWorldService" class="com.myapp.DefaultHelloWorldService"> <description>Provides hello world services.</description> <interface>com.myapp.HelloWorldService</interface> </component> </atlassian-plugin> NotesSome information to be aware of when developing or configuring a Component plugin module:
Accessing Your ComponentsAccessing your components from within other plugin modules is extremely simple. All plugin modules in OSGi plugins are autowired. So to access a component, you need to add a Java setter method to your plugin module class. For example, if you wanted to use the above helloWorldService component in an event listener module, you would add a field for the component and a setter method to the listener class as follows: public class MyEventListener implements EventListener { private HelloWorldService helloWorldService; // ... public void setHelloWorldService(HelloWorldService helloWorldService) { this.helloWorldService = helloWorldService; } } Note that to access components in other plugins, the module needs to be marked as 'public' (as covered above) and imported into your plugin using a component-import. RELATED TOPICSWriting Confluence Plugins |
![]() |
Document generated by Confluence on Dec 03, 2008 15:14 |