30
1

Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Embed Size (px)

DESCRIPTION

Plugins 2.0 & OSGi Gotchas John Kodumal, Atlassian

Citation preview

Page 1: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1

John KodumalAtlassian Developer

Or How I learned to stop worrying and love Apache Felix

Plugins 2 and OSGi Gotchas

22

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

33

OSGi from 10000 feet

Services

Lifecycle

Modules

Execution Environment

Bundles

44

OSGi Benefits

55

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 2: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

John KodumalAtlassian Developer

Or How I learned to stop worrying and love Apache Felix

Plugins 2 and OSGi Gotchas

22

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

33

OSGi from 10000 feet

Services

Lifecycle

Modules

Execution Environment

Bundles

44

OSGi Benefits

55

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 3: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

33

OSGi from 10000 feet

Services

Lifecycle

Modules

Execution Environment

Bundles

44

OSGi Benefits

55

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 4: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

OSGi from 10000 feet

Services

Lifecycle

Modules

Execution Environment

Bundles

44

OSGi Benefits

55

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 5: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

OSGi Benefits

55

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 6: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Migrate to Plugins 20

bull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

66

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 7: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

OSGi as a black box

The Atlassian Plugin Framework 2 tries to hide the complexity of OSGi as much as possibleIf you are familiar with OSGi and want to provide an OSGi bundle directly in order to leverage all its features you are free to do so

httpconfluenceatlassiancomxDIBiCg

77

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 8: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

OSGi as a black box

PluginComplexity

OSGiKnowledge

sweet spot

simple plugins(gadgets)

crazy plugins(dashboards)

88

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 9: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Agendabull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

99

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 10: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

OSGi Concepts

1010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 11: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Anatomy of an OSGi Bundle

Package Exports

Package Imports

OSGi BundleManifestActivatorServices

Private ClassloaderPrivate Packages

1111

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 12: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

How Bundles Interact

comgooglecollect v10

Wire

google collections 10your plugin

1212

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 13: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Agendabull Background

bull Overview of OSGi

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

1313

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 14: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian Refapp

1414

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 15: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Bundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jar

1515

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 16: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Import-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000

1616

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 17: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1 Be the master of your manifest

Manifest-Version 10Created-By 150_19 (Apple Inc)Bundle-Name gdata-service-pluginBundle-SymbolicName comatlassianagmpgdata-service-pluginBundle-Description This is the comatlassianagmpgdata-service-plugin plugin for Atlassian RefappBundle-ClassPath META-INFlibcommons-lang-24jarMETA-INFlibjoda-time-16jarImport-Package comatlassianagmpintegrationcommonversion=000 comatlassiantemplaterendererannotationsversion=000comatlassiantemplaterenderervelocityonesixversion=000comgooglecommonbaseversion=000comgooglegdataclientversion=1401comgooglegdataclientauthnoauthversion=1401comgooglegdataclientcalendarversion=1401comgooglegdataclientdocsversion=1401comgooglegdataclientmediaversion=1401comgooglegdatadataversion=1401comgooglegdatadatacalendarversion=1401comgooglegdatadatadocsversion=1401comgooglegdatadatamediaversion=1401comgooglegdatautilversion=1401comgooglegdatautilcommonbaseversion=1401comgooglegdatautilcommonxmlversion=1401javaxservletversion=000javaxservlethttpversion=000orgapachecommonsioversion=13orgapachelog4jversion=000orgspringframeworkbeansfactoryannotationversion=000Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOTBundle-Version 114SNAPSHOTBundle-DocURL httpwwwatlassiancomBundle-Vendor AtlassianBundle-ManifestVersion 2Tool Bnd-00311

Export-Package comatlassianagmpgdatauses=comgooglegdatautilversion=114SNAPSHOT

1717

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 18: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

1 Be the master of your manifest

ltbuildgtltpluginsgt

ltplugingt ltgroupIdgtcomatlassianmavenpluginsltgroupIdgt ltartifactIdgtmaven-refapp-pluginltartifactIdgt ltversiongt302ltversiongt ltextensionsgttrueltextensionsgt ltconfigurationgt ltproductVersiongt$refappversionltproductVersiongt ltinstructionsgt ltImport-Packagegt javaxservletversion=000 orgapachecommonsioversion=13 comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000 ltImport-Packagegt ltExport-Packagegt comatlassianagmpgdata ltExport-Packagegt ltinstructionsgt

ltplugingthellip

ltbuildgt

ltinstructionsgtltImport-Packagegt

javaxservletversion=000orgapachecommonsioversion=13

comatlassianagmpintegrationcommonversion=000 comgooglegdataversion=1401 comgooglecommonversion=000 orgspringframeworkbeansversion=000 comatlassiantemplaterendererversion=000 orgapachelog4jversion=000

ltImport-Packagegt ltExport-Packagegt

comatlassianagmpgdataltExport-Packagegt

ltinstructionsgt

1818

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 19: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

2 Manage your dependenciesbull Prefer Import-Package dependencies over Require-Bundle

vs

Import-Package Require-Bundle

1919

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 20: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

2 Manage your dependenciesbull Prefer Import-Package dependencies over Bundle-Classpath

vs

Import-Package Bundle-Classpath

2020

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 21: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

2 Manage your dependenciesbull Always specify package versions for imports and exportsbull Versions are specified in ltmajorgtltminorgtltmicrogtltqualifiergt formbull Bundle constraints use interval range notation

bull eg ldquo[100 200 )rdquo

bull A missing upper bound denotes infinitybull So version=ldquo100rdquo really means version gt= ldquo100rdquobull version=ldquo000rdquo means ldquoany versionrdquobull Thatʼs right OSGi has redefined equals to mean greater than Top notch

bull Put version constraints in quotes

2121

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 22: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

2 Manage your dependenciesbull Run mvndependency-tree and scan your dependencies manuallybull Use the maven dependency tracker plugin if youʼre paranoid

bull httpslabsatlassiancombrowseMAP

bull

2222

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 23: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

3 Earn a brown belt in OSGi classloading

Start

boot

package-import

java

bundle classpath

Delegate to parent classloader

Delegate to parent classloader

Delegate to wire exporter

found

found

found

found

2323

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 24: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

3 Earn a brown belt in OSGi classloading

bull Boot delegated packages cannot be overriddenbull Even with packages in your bundle classpath

bull Plugins 2x boot delegates several packagesbull Packages for profiling tools (eg comyourkit)bull And xerces

2424

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 25: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

4 Buddy up with the Felix web console

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

2525

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 26: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

4 Or try the OSGi Explorer plugin

26

httpspluginsatlassiancomplugindetails23455

26

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 27: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

5 Know what the applications provide

http$baseURLadminpluginexportsaction

2727

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 28: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

5 Know what the applications provide

28

bullhttp$baseURLpluginsservletsystemconsole

bullusername adminbullpassword admin

28

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 29: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Recapbull Background

bull OSGi Primer

bull Protips1 Be the master of your manifest2 Manage your dependencies3 Earn a brown belt in OSGi classloading4 Buddy up with the Felix web console5 Know what the applications provide

2929

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030

Page 30: Plugins 2.0 & OSGi Gotchas - Atlassian Summit 2010

Resourcesbull Convert plugin to plugins 2bull httpconfluenceatlassiancomxbwLvCw

bull Convert plugin project to SDKbull httpconfluenceatlassiancomxwRyyCg

bull Felix web consolebull http$baseURLpluginsservletsystemconsole

bull Confluence exported beansbull http$baseURLadminpluginexportsaction

3030