Reference: developer.atlassian.com
An Atlassian plugin is an OSGi bundle.
This means that each plugin now has its own, isolated, class loader. Which means, to quote Atlassian:
You will follow the same process every time you decide to use another piece of code in your plugin:
"Where will I get the artifacts to compile my code against?" Answering this question will tell you what you need to add as <dependencies> in your pom.xml.
"Where will my code find these artifacts at runtime?" Answering this question will tell you which manifest instructions you need to specify in your pom.xml (inside the AMPS configuration section).
Example manifest instructions for importing certain Atlassian packages:
Package Bundling Naming
Specifying runtime dependencies is done through a custom declaration syntax called a bundling instruction. The SDK uses the Apache Felix Maven plugin (BND) behind the scenes to handle this, so the instructions explained here are passed to BND at package time and used to create the OSGi manifest.
Bundling instructions are specified by the format:
package-name(wildcard);version="<major>.<minor>.<maintenance>"
Multiple instructions are separated by commas.
Here's a real-world example:
com.atlassian.confluence.events.event.space;version="[3.4,4.0)"
com.atlassian.confluence.search.lucene.*;version="[3.4,4.0)"
com.atlassian.confluence.json*;version="[3.4,4.0)"
Package name specification
There are three different ways of specifying the package name:
com.atlassian.confluence.events.event.space: Imports every class in the com.atlassian.confluence.events.event.space package.
com.atlassian.confluence.search.lucene.*: Imports every class in subpackages of com.atlassian.confluence.search.lucene while not importing any classes com.atlassian.confluence.search.lucene itself
com.atlassian.confluence.json*: Imports every class in com.atlassian.confluence.json and all classes in all subpackages of com.atlassian.confluence.json
Tools
OSGi hidden tab
Use: http://localhost:8080/confluence/plugins/servlet/upm#osgi
Provides OSGi bundle states for all Plugins 2 plugins – can provide clues to which OSGi dependencies failed...
Example
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam fermentum vestibulum est. Sed quis tortor.
