0
Taming Beastly Web
 Applications with
 Server-Side OSGi
    Don Brown, Atlassian
It starts so simple. . .
Then this happens. . .

         SOAP interface     REST interface

IRC interface               Slooow deployment
     Mic...
Solution: Plugins
                       Application



                    Plugin Framework


Excel             REST     ...
Anatomy of a Plugin
            Plugin JAR


      Java
                  Utility JARs
     Classes


    Resources
      ...
ls myplugin.jar

./com/myplugin/HelloWorld.class
./resources/logo.png
./META-INF/lib/util.jar
./plugin.xml
plugin.xml
<plugin key=”my.plugin”>
  <plugin-info>
     <version>1.0</version>
  </plugin-info>
  <servlet key=”helloWorl...
Not just any plugin
 framework . . .




        . . . Now Open Source (BSD)
Right, but what does this have
       to do with OSGi?
What if your plugins
  need plugins?
                       Application



                    Plugin Framework


Excel   ...
Want: inter-plugin
communication
              Report Plugin


   Report       Report        Built-in
   Services       UI...
Want: dynamic
 deployment



       plugins

    WEB-INF/lib
Want: application and
  plugin isolation
                       Application

          Internal         External        In...
Want: application and
  plugin isolation
                       Application

          Internal         External        In...
OSGi Basics
            Dynamic module system for Java


Features:

  • Service registry
  • Lifecycle model
  • Bundle de...
OSGi Terms
Bundle - Jar file with special OSGi entries in its
 manifest and containing classes, resources, and
 other jars
...
Bundle Manifest
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.foo.Example
Bundle-Version: 1.0
I...
Bundle Lifecycle
OSGi Services



Key: “com.foo.MyInterface”
Instance: com.foo.MyService
Properties:
   name => foo
   someProperty => some...
What does that mean?

• Upgrade bundles (think super jars) at runtime
• Bundles can depend on other bundles at a
  service...
So how does OSGi
     help us?
1. Ability for plugins to
   depend on each other
Plugins can generate their own OSGi headers or:
   <plugin-info>
    <bu...
2. Ability for plugins to
   define extension points

1. Plugin A exposes its implementation:
   <component key=“foo” publi...
3. Better insulate plugins
 from product changes
• Host applications can decide which versioned
  packages to expose to pl...
Plugins 2
Why should you care?
Built for integration

Shipped today with Atlassian applications
with different:
• Dependency injection libraries
• Web fr...
On to the code . . .
Takeaway: Use plugins
and OSGi to tame your
     beastly apps
Questions?

http://studio.atlassian.com/wiki/display/PLUG
             http://felix.apache.org
Taming Beastly Web Applications with Server-Side OSGi
Upcoming SlideShare
Loading in...5
×

Taming Beastly Web Applications with Server-Side OSGi

4,976

Published on

Presentation given at OSDC Sydney 2008

Published in: Technology, Art & Photos
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,976
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
62
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "Taming Beastly Web Applications with Server-Side OSGi"

  1. 1. Taming Beastly Web Applications with Server-Side OSGi Don Brown, Atlassian
  2. 2. It starts so simple. . .
  3. 3. Then this happens. . . SOAP interface REST interface IRC interface Slooow deployment Microsoft Excel export and import Report builder 50+ third-party libraries and frameworks PKI card authentication Thousands of classes
  4. 4. Solution: Plugins Application Plugin Framework Excel REST IRC SOAP Plugin Plugin Plugin Plugin Report PKI Auth Plugin Plugin
  5. 5. Anatomy of a Plugin Plugin JAR Java Utility JARs Classes Resources XML (images, Descriptor css, etc)
  6. 6. ls myplugin.jar ./com/myplugin/HelloWorld.class ./resources/logo.png ./META-INF/lib/util.jar ./plugin.xml
  7. 7. plugin.xml <plugin key=”my.plugin”> <plugin-info> <version>1.0</version> </plugin-info> <servlet key=”helloWorld” class=“com.myplugin.HelloWorld”> <url-pattern>/helloWorld</url-pattern> </servlet> </plugin>
  8. 8. Not just any plugin framework . . . . . . Now Open Source (BSD)
  9. 9. Right, but what does this have to do with OSGi?
  10. 10. What if your plugins need plugins? Application Plugin Framework Excel REST IRC SOAP Plugin Plugin Plugin Plugin Report PKI Auth Plugin Plugin
  11. 11. Want: inter-plugin communication Report Plugin Report Report Built-in Services UI Reports Users Sales Usage Reports Reports Reports Plugin Plugin Plugin
  12. 12. Want: dynamic deployment plugins WEB-INF/lib
  13. 13. Want: application and plugin isolation Application Internal External Internal Services Services Resources Excel REST IRC SOAP Plugin Plugin Plugin Plugin Report PKI Auth Plugin Plugin
  14. 14. Want: application and plugin isolation Application Internal External Internal Services Services Resources Excel REST IRC SOAP Plugin Plugin Plugin Plugin Report PKI Auth Plugin Plugin
  15. 15. OSGi Basics Dynamic module system for Java Features: • Service registry • Lifecycle model • Bundle dependency system • Optional security layer
  16. 16. OSGi Terms Bundle - Jar file with special OSGi entries in its manifest and containing classes, resources, and other jars Lifecycle - States a bundle goes through: uninstalled, installed, resolved, starting, stopping, active Service - An object instance exposed under the one or more interfaces it implements and a map of properties
  17. 17. Bundle Manifest Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.foo.Example Bundle-Version: 1.0 Import-Package: org.bar;version=quot;1.3.0” Export-Package: org.foo.api Bundle-ClassPath: .,META-INF/lib/foo.jar
  18. 18. Bundle Lifecycle
  19. 19. OSGi Services Key: “com.foo.MyInterface” Instance: com.foo.MyService Properties: name => foo someProperty => someValue
  20. 20. What does that mean? • Upgrade bundles (think super jars) at runtime • Bundles can depend on other bundles at a service, package, or jar level • Bundles can hide packages from other bundles and version exposed packages
  21. 21. So how does OSGi help us?
  22. 22. 1. Ability for plugins to depend on each other Plugins can generate their own OSGi headers or: <plugin-info> <bundle-instructions> <Require-Bundle> org.otherPlugin;bundle- version=quot;[3.2.0,4.0.0)</Require-Bundle> <Import-Package> *,org.otherPlugin.api;version=”[3.2.0,4.0.0)” </ Import-Package> </bundle-instructions> </plugin-info>
  23. 23. 2. Ability for plugins to define extension points 1. Plugin A exposes its implementation: <component key=“foo” public=“true” class=“org.bar.FooImpl” interface=“org.foo.Foo” /> 2. Plugin B imports the service: <component-import key=“foo” interface=“foo.Foo” />
  24. 24. 3. Better insulate plugins from product changes • Host applications can decide which versioned packages to expose to plugins scanner.addPackageIncludes(Arrays.asList( “com.atlassian.*”, “org.apache.commons.*”)); • Host applications expose specific host components: <bean name=quot;fooquot; class=quot;com.atlassian. FooableBeanquot; plugin:available=quot;truequot; /> Or @AvailableToPlugins public class MyManager implements Manager {...}
  25. 25. Plugins 2
  26. 26. Why should you care?
  27. 27. Built for integration Shipped today with Atlassian applications with different: • Dependency injection libraries • Web frameworks • Persistence frameworks
  28. 28. On to the code . . .
  29. 29. Takeaway: Use plugins and OSGi to tame your beastly apps
  30. 30. Questions? http://studio.atlassian.com/wiki/display/PLUG http://felix.apache.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×