Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
©2014 IBM Corporation
Building a right-sized,
do-anything runtime
using OSGi technologies
a case study 

(sort of)
Erin Sc...
©2014 IBM Corporation
<background>
©2014 IBM Corporation
Some notes on motivation
The full profile of WebSphere application server is awesome in
its capabilit...
©2014 IBM Corporation
History
WebSphere Application Server (the full profile) has been around
forever.
Big codebase
Big cus...
©2014 IBM Corporation
History
WebSphere Application Server (the full profile) has been around
forever.
Big codebase
Big cus...
©2014 IBM Corporation
History
WebSphere Application Server (the full profile) has been around
forever.
Big codebase
Big cus...
©2014 IBM Corporation
Code that has been around
forever…
Doesn’t matter how good you are, 

or how smart you are









...
©2014 IBM Corporation
Code that has been around
forever…
Doesn’t matter how good you are, 

or how smart you are
If your c...
©2014 IBM Corporation
Code that has been around
forever…
No matter how good you are, 

or how smart you are
If your code l...
©2014 IBM Corporation
Code that has been around
forever…
No matter how good you are, 

or how smart you are
If your code l...
©2014 IBM Corporation
OSGi and WAS:
The first pass…
OSGi was included in WAS v6.1, in 2006
Went from lots of arbitrary jars...
©2014 IBM Corporation
</background>
©2014 IBM Corporation
<cleanSlate>
This is the version of the story you won’t have
heard before…
©2014 IBM Corporation
What if…
If we could start over, what would we want?
Developer-friendly
Simple
Dynamic
Light-weight
...
©2014 IBM Corporation
What if…
If we could start over, what would we want?
Developer-friendly
Simple
Dynamic
Light-weight
...
©2014 IBM Corporation
runtime

only
some combination of

technologies

!
app-centered
everything
What if…
grokable
config
p...
©2014 IBM Corporation
What if…
grokable
config
provisioning
runtime

only
some combination of

technologies

!
app-centered...
©2014 IBM Corporation
What if…
runtime

only
some combination of

technologies

!
app-centeredeverything
And yet allow thi...
©2014 IBM Corporation
What if…
And for crying out loud,
can we prevent THIS?!
runtime3rd party

bundle

B
system

bundle

...
©2014 IBM Corporation
Building a kernel from scratch
OSGi-based for all the reasons
First-class use of OSGi services
Must ...
©2014 IBM Corporation
Configuration
Settled on XML for configuration format
Ubiquitous
Expressive
BUT, for simplicity:
singl...
©2014 IBM Corporation
Configuration
Composable system requires composable configuration:
Individual components own their con...
©2014 IBM Corporation
Configuration
Composable system requires composable configuration:
Individual components own their con...
©2014 IBM Corporation
Configuration Admin
We rolled our own (sorry)
Parse and merge user configuration and bundle-provided
d...
©2014 IBM Corporation
Metatype
Equinox impl + extensions
http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/co...
©2014 IBM Corporation
Uniform validation of user input
Define configuration and constraints in one place, it gets used every...
©2014 IBM Corporation
Uniform validation of user input
Define configuration and constraints in one place, it gets used every...
©2014 IBM Corporation
Uniform validation of user input
Define configuration and constraints in one place, it gets used every...
©2014 IBM Corporation
Provisioning
Two phases of provisioning:
Bootstrap the kernel to get configuration
Add or remove feat...
©2014 IBM Corporation
Provisioning
Two phases of provisioning:
Bootstrap the kernel to get configuration
Add or remove feat...
©2014 IBM Corporation
Using OSGi Services…
But who in their right mind wants to manage OSGi
services themselves??
©2014 IBM Corporation
Using OSGi Services…
But who in their right mind wants to manage OSGi
services themselves??
Exactly....
©2014 IBM Corporation
Using OSGi Services…
But who in their right mind wants to manage OSGi
services themselves??
Exactly....
©2014 IBM Corporation
Declarative Services
We chose DS for two main reasons:
Timing: Blueprint and Aries were just getting...
©2014 IBM Corporation
DS is AWESOME!
DS is a central part of the Liberty runtime
CA + M + DS = “magic”

We do insane thing...
©2014 IBM Corporation
Service dynamics can hurt!
Service dynamics are a huge hurdle for “new” developers
DI and IoC can tu...
©2014 IBM Corporation
Let DS do it. Really.
DS is excellent at managing service dynamics.
DS is excellent at managing non-...
©2014 IBM Corporation
Isolation
We mean this in a good way.
Liberty runtime serves two masters:
Typical Application Server...
©2014 IBM Corporation
Subsystems, Resolver Hooks, and
Regions… (oh my!)
Features must explicitly declare API and SPI packa...
©2014 IBM Corporation
</cleanSlate>
Of course, we didn’t really get a clean slate.

Application compatibility had to be pr...
©2014 IBM Corporation
Dealing with our legacy
We did start over with our kernel
Used the new base to re-group…
Lots of cod...
©2014 IBM Corporation
Thank you!
Questions?
Upcoming SlideShare
Loading in …5
×

Building a right sized, do-anything runtime using OSGi technologies: a case study - E Schnabel

892 views

Published on

The WebSphere Application Server Liberty profile uses several OSGi technologies in addition to the Equinox OSGi framework: Configuration Admin, Metatype, and Declarative Services being first and foremost among them.

In this talk, I'll go over how Liberty uses these technologies to create a dynamic flexible runtime that can be right-sized based on the server's configuration. I'll share the lessons we've learned, and what we consider to be best practice for interacting with these three services.

Bio:
Erin Schnabel is the Development lead for the WebSphere Application Server Liberty profile. She has over 12 years of experience in the WebSphere Application Server development organization in various technical roles. Erin has over 15 years of experience working with Java and application middleware across various hardware platforms, including IBM z/OS®. She specializes in composable runtimes, including the application of OSGi, object-oriented and service-oriented technologies and design patterns to decompose existing software systems into flexible, composable units.

Published in: Technology, Business
  • Be the first to comment

Building a right sized, do-anything runtime using OSGi technologies: a case study - E Schnabel

  1. 1. ©2014 IBM Corporation Building a right-sized, do-anything runtime using OSGi technologies a case study 
 (sort of) Erin Schnabel schnabel@us.ibm.com @ebullientworks
  2. 2. ©2014 IBM Corporation <background>
  3. 3. ©2014 IBM Corporation Some notes on motivation The full profile of WebSphere application server is awesome in its capabilities It is also well-known that the full profile is not well-suited for development We did and do listen… and were presented with a challenge: 
 “Create a light-weight profile of WebSphere that starts in under 2 seconds… [but] Don’t break any eggs” — Ian Robinson
  4. 4. ©2014 IBM Corporation History WebSphere Application Server (the full profile) has been around forever. Big codebase Big customer base Big workloads … Big inhibitors to massive change

  5. 5. ©2014 IBM Corporation History WebSphere Application Server (the full profile) has been around forever. Big codebase Big customer base Big workloads … Big inhibitors to massive change
 This is not a complaint. This is a problem we are
 happy to have.
  6. 6. ©2014 IBM Corporation History WebSphere Application Server (the full profile) has been around forever. Big codebase Big customer base Big workloads … Big inhibitors to massive change
 This is not a complaint. This is a problem we are
 happy to have. But it is still a problem.
  7. 7. ©2014 IBM Corporation Code that has been around forever… Doesn’t matter how good you are, 
 or how smart you are
 
 
 
 
 
 

  8. 8. ©2014 IBM Corporation Code that has been around forever… Doesn’t matter how good you are, 
 or how smart you are If your code lives long enough, 
 and is used enough, 
 it ends up looking like… 
 
 

  9. 9. ©2014 IBM Corporation Code that has been around forever… No matter how good you are, 
 or how smart you are If your code lives long enough, 
 and is used enough, 
 it ends up looking like… 
 
 
 dragons ?!
  10. 10. ©2014 IBM Corporation Code that has been around forever… No matter how good you are, 
 or how smart you are If your code lives long enough, 
 and is used enough, 
 it ends up looking like… 
 
 
 dragons ?! Especially code that has roots 
 going back to late ‘90s…
  11. 11. ©2014 IBM Corporation OSGi and WAS: The first pass… OSGi was included in WAS v6.1, in 2006 Went from lots of arbitrary jars to a few bundles Achieved some modularity enforced by OSGi We did not use or expose OSGi services Compatibility constraints: WAS is the bottom of the stack Assumptions about resource initialization and availability Entrenched dependencies between some core elements
  12. 12. ©2014 IBM Corporation </background>
  13. 13. ©2014 IBM Corporation <cleanSlate> This is the version of the story you won’t have heard before…
  14. 14. ©2014 IBM Corporation What if… If we could start over, what would we want? Developer-friendly Simple Dynamic Light-weight Composable / Flexible Extensible
  15. 15. ©2014 IBM Corporation What if… If we could start over, what would we want? Developer-friendly Simple Dynamic Light-weight Composable / Flexible Extensible selectable content clear API/SPI runtime/app isolation human usable configuration
  16. 16. ©2014 IBM Corporation runtime
 only some combination of
 technologies
 ! app-centered everything What if… grokable config provisioning
  17. 17. ©2014 IBM Corporation What if… grokable config provisioning runtime
 only some combination of
 technologies
 ! app-centered everything How do we do this?
  18. 18. ©2014 IBM Corporation What if… runtime
 only some combination of
 technologies
 ! app-centeredeverything And yet allow this? no restarts
  19. 19. ©2014 IBM Corporation What if… And for crying out loud, can we prevent THIS?! runtime3rd party
 bundle
 B system
 bundle
 A Application X
  20. 20. ©2014 IBM Corporation Building a kernel from scratch OSGi-based for all the reasons First-class use of OSGi services Must react to configuration changes Runtime composition on-the-fly
 
 

  21. 21. ©2014 IBM Corporation Configuration Settled on XML for configuration format Ubiquitous Expressive BUT, for simplicity: single file usable defaults <server description=“simple”> <featureManager> <feature>jsp-2.2</feature> </featureManager> ! <httpEndpoint id=“defaultHttpEndpoint” 
 httpPort=“9080” httpsPort=“9443” /> </server>
  22. 22. ©2014 IBM Corporation Configuration Composable system requires composable configuration: Individual components own their config
 No centralized repository No externally defined global config model
  23. 23. ©2014 IBM Corporation Configuration Composable system requires composable configuration: Individual components own their config
 No centralized repository No externally defined global config model Configuration Admin and Metatype #FTW!
  24. 24. ©2014 IBM Corporation Configuration Admin We rolled our own (sorry) Parse and merge user configuration and bundle-provided defaults Resolve variables Provide configuration to consumers as required by the spec (mostly)
 
 
 
 
 

  25. 25. ©2014 IBM Corporation Metatype Equinox impl + extensions http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/ rwlp_extensions_osgi_metatype.html Uniform validation of user input Define configuration and constraints in one place, it gets used everywhere else. We favor metatype.xml for this reason Custom namespace for additional types and validators ibm:type — duration, location, password pid/reference unique, final, variable, etc.
  26. 26. ©2014 IBM Corporation Uniform validation of user input Define configuration and constraints in one place, it gets used everywhere else. We favor metatype.xml for this reason Custom namespace for additional types and validators ibm:type — duration, location, password pid/reference unique, final, variable, etc. Metatype Equinox impl + extensions http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/ rwlp_extensions_osgi_metatype.html human readable:
 1h30m converted to unit of choice used by developer tools to help prompt for the right kind of path: file vs. url
  27. 27. ©2014 IBM Corporation Uniform validation of user input Define configuration and constraints in one place, it gets used everywhere else. We favor metatype.xml for this reason Custom namespace for additional types and validators ibm:type — duration, location, password pid/reference unique, final, variable, etc. Metatype Equinox impl + extensions http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/ rwlp_extensions_osgi_metatype.html type=“String”
 ibm:type=“password”
 
 The value is a “SerializedProtectedString”, 
 which is not a String. 
 Developer tools display encoding options: xor or aes, etc.
  28. 28. ©2014 IBM Corporation Uniform validation of user input Define configuration and constraints in one place, it gets used everywhere else. We favor metatype.xml for this reason Custom namespace for additional types and validators ibm:type — duration, location, password pid/reference unique, final, variable, etc. Metatype Equinox impl + extensions http://www-01.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/ rwlp_extensions_osgi_metatype.html This is some crazy stuff.
 
 ibm:type=“pid”
 ibm:reference=“specific.service.pid” 
 
 Allows nested configuration elements 
 to define service relationships
 
 #awesome
  29. 29. ©2014 IBM Corporation Provisioning Two phases of provisioning: Bootstrap the kernel to get configuration Add or remove features based on configuration update Features as in Subsystem features 
 (*.esa files, metadata, etc.) Adding or removing features 
 installs or uninstalls bundles, which 
 adds or removes configurations, which
 triggers the creation or removal of services!
  30. 30. ©2014 IBM Corporation Provisioning Two phases of provisioning: Bootstrap the kernel to get configuration Add or remove features based on configuration update Features as in Subsystem features 
 (*.esa files, metadata, etc.) Adding or removing features 
 installs or uninstalls bundles, which 
 adds or removes configurations, which
 triggers the creation or removal of services! Dynamically respond to configuration changes at any time without requiring a restart. ! #really
  31. 31. ©2014 IBM Corporation Using OSGi Services… But who in their right mind wants to manage OSGi services themselves??
  32. 32. ©2014 IBM Corporation Using OSGi Services… But who in their right mind wants to manage OSGi services themselves?? Exactly. NOBODY.
  33. 33. ©2014 IBM Corporation Using OSGi Services… But who in their right mind wants to manage OSGi services themselves?? Exactly. NOBODY. ? BlueprintDeclarative Services yes, there are others. 
 We focused on these two.
  34. 34. ©2014 IBM Corporation Declarative Services We chose DS for two main reasons: Timing: Blueprint and Aries were just getting started Integration with Configuration Admin and Metatype! Config injected as one unit activate/modified/updated methods Service instance creation based on metatype-declared factory pid DS target filters can be set via configuration
  35. 35. ©2014 IBM Corporation DS is AWESOME! DS is a central part of the Liberty runtime CA + M + DS = “magic”
 We do insane things with config-derived target filters Our runtime would not be what it is without DS in the middle of it BUT..
  36. 36. ©2014 IBM Corporation Service dynamics can hurt! Service dynamics are a huge hurdle for “new” developers DI and IoC can turn even experienced brains inside out if they aren’t prepared.
 Thankfully, they do seem to recover. Utilities created to “help” can have unintended consequences. 
 Especially if cut and paste are involved. There is definitely a “better way” to do things with DS..
  37. 37. ©2014 IBM Corporation Let DS do it. Really. DS is excellent at managing service dynamics. DS is excellent at managing non-trivial service dependencies It is very unlikely that you will be able to do better— just let DS do it. That means: Don’t register services inside a component Don’t manage references inside a component
  38. 38. ©2014 IBM Corporation Isolation We mean this in a good way. Liberty runtime serves two masters: Typical Application Server paradigm
 (apps strictly separated from runtime) — API Platform extender paradigm
 (the “app” is the runtime) — SPI Persistent problem:
 how to allow apps or extensions to use their own versions of libraries that don't conflict with the runtime!?
  39. 39. ©2014 IBM Corporation Subsystems, Resolver Hooks, and Regions… (oh my!) Features must explicitly declare API and SPI packages 
 (IBM-* metadata in the feature manifest) Isolation between API/SPI, apps/extensions/runtime is enforced in a few ways: Subsystems (the Aries impl) for OSGi Applications (API) Resolver hooks and/or Eclipse Regions for isolation between runtime, extensions (SPI), and containers (API).
  40. 40. ©2014 IBM Corporation </cleanSlate> Of course, we didn’t really get a clean slate.
 Application compatibility had to be preserved. ! But that still gave us a LOT of room…
  41. 41. ©2014 IBM Corporation Dealing with our legacy We did start over with our kernel Used the new base to re-group… Lots of code still common with full profile Wrap/Shim: New face on old code Patch: tweak and replace bits where necessary
  42. 42. ©2014 IBM Corporation Thank you! Questions?

×