Confluence Docs 3.0 : Component Import Plugins This page last changed on Sep 07, 2009 by ggaskell. On this page: Purpose of this Module Type Configuration Attributes Elements Example Notes ## Purpose of this Module Type Component Import plugin modules allow you to access Java components shared by other plugins, even the component is upgraded at runtime. ## Configuration The root element for the Component Import plugin module is `component-import`. It allows the following attributes and child elements for configuration: #### Attributes
Name | Required | Description | Default
--- | --- | --- | ---
class |  | The class which implements this plugin module. The class you need to provide depends on the module type. For example, Confluence theme, layout and colour-scheme modules can use classes already provided in Confluence. So you can write a theme-plugin without any Java code. But for macro and listener modules you need to write your own implementing class and include it in your plugin. |
disabled |  | Indicate whether the plugin module should be disabled by default (value='true') or enabled by default (value='false'). | false
i18n-name-key |  | The localisation key for the human-readable name of the plugin module. |
interface |  | The Java interface of the component to import. This attribute is only required if the `interface` elements are not used. | N/A
key |  | The identifier of the plugin module. This key must be unique within the plugin where it is defined. Sometimes you will need to uniquely identify a module. Do this with the module complete key. A module with key `fred` in a plugin with key `com.example.modules` will have a complete key of `com.example.modules:fred`. I.e. The identifier of the component to import. | N/A
name |  | The human-readable name of the plugin module. I.e. the human-readable name of the component to import. | The plugin key.
system |  | Indicates whether this plugin module is a system plugin module (value='true') or not (value='false'). Only available for non-OSGi plugins. | false
#### Elements
Name | Required | Description | Default
--- | --- | --- | ---
description |  | The description of the plugin module. The 'key' attribute can be specified to declare a localisation key for the value instead of text in the element body. I.e. the description of the component to import. |
interface |  | The Java interface under which the component to retrieve is registered. This element can appear zero or more times, but is required if the `interface` attribute is not used. | N/A
## Example Here is an example `atlassian-plugin.xml` file containing a single component import:
    <atlassian-plugin name="Hello World" key="example.plugin.helloworld" plugins-version="2">
        <plugin-info>
            <description>A basic component import module test</description>
            <vendor name="Atlassian Software Systems" url="http://www.atlassian.com"/>
            <version>1.0</version>
        </plugin-info>

        <component-import key="helloWorldService">
            <description>Consumes the hello world service.</description>
            <interface>com.myapp.HelloWorldService</interface>
        </component-import>
    </atlassian-plugin>
It consumes a component made available via a different plugin:
    <atlassian-plugin name="Hello World Provider" key="example.plugin.helloworld.provider" plugins-version="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.internal.MyHelloWorldService" public="true">
            <interface>com.myapp.HelloWorldService</interface>
        </component>
    </atlassian-plugin>
## Notes Some information to be aware of when developing or configuring a Component Import plugin module: Component imports, at installation time, are used to generate the `atlassian-plugins-spring.xml` Spring Framework configuration file, transforming Component Import plugin modules into OSGi service references using Spring Dynamic Modules. The imported component will have its bean name set to the component import key, which may be important if using 'by name' dependency injection. If you wish to have more control over how imported services are discovered and made available to your plugin, you can create your own Spring configuration file containing Spring Dynamic Modules elements, stored in `META-INF/spring` in your plugin jar. This is recommended if you are needing to import multiple services that implement an interface, for example. You can use component imports to customise the bean name of host components, particularly useful if you plan to use 'by name' dependency injection. ##### RELATED TOPICS Writing Confluence Plugins Installing and Configuring Plugins Manually Information sourced from Plugin Framework documentation

Document generated by Confluence on Nov 05, 2009 23:34