Building Server Platform with OSGi and...
Transcript of Building Server Platform with OSGi and...
![Page 2: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/2.jpg)
Who am I?
Lead Engineer of SpringSource dm Server
Author of Pro Spring
JMX Expert Group member
![Page 3: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/3.jpg)
Agenda
Benefits of OSGi
System Partitioning
Managing Dependencies
Extending Equinox
Handling Concurrency
Q&A
![Page 4: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/4.jpg)
Benefits of OSGi
![Page 5: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/5.jpg)
System Partitioning
Manage complexity
Handle large teams
Mitigate risk
Deal with change
Deal with large codebase
![Page 6: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/6.jpg)
Dependency Management
Handle third-party dependencies
Embody dependencies in design and code
Manage different dependency versions
![Page 7: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/7.jpg)
Dynamism
Support evolving runtime environment
Handle failure gracefully
Hot-deployment built-in
![Page 8: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/8.jpg)
System Partitioning
![Page 9: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/9.jpg)
Start Simple – Logical Model
![Page 10: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/10.jpg)
Extract Modules as Needed
![Page 11: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/11.jpg)
Reasons for Extraction
Area of risk
Area of change
Area of complexity
Area of work assignment
Unit of maintenance
Code explosion
![Page 12: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/12.jpg)
Fold Modules Together as Needed
![Page 13: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/13.jpg)
Reasons for Folding
Risk removal
Code shrinking
Team changes
Complexity addressed
Incorrect boundaries
![Page 14: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/14.jpg)
DEMO: Tooling
![Page 15: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/15.jpg)
Managing Dependencies
![Page 16: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/16.jpg)
Package Dependencies
![Page 17: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/17.jpg)
Bundle Dependencies
![Page 18: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/18.jpg)
Versioning Dependencies
![Page 19: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/19.jpg)
Service Dependencies
![Page 20: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/20.jpg)
EXAMPLE: GreenPages
![Page 21: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/21.jpg)
Build-time vs. run-time dependencies
Artifact-first• Build tooling defines classpath
• Manifest is generated
Manifest-first• Manifest is hand-written
• Classpath is derived from Manifest
![Page 22: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/22.jpg)
DEMO: Tooling
![Page 23: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/23.jpg)
Extending Equinox
![Page 24: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/24.jpg)
Extension Hook Architecture
![Page 25: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/25.jpg)
Hook Options
AdaptorHook
BundleWatcher
ClassloadingHook
ClassloadingStatsHook
ClassloadingDelegateHook
StorageHook
BundleFileFactoryHook
BundleFileWrapperFactoryHookk
![Page 26: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/26.jpg)
Hooks in dm Server
ClassloadingHook:• Replace ClassLoader
BundleFileWrapperFactoryHook• Manifest transformation
• URL fixup
![Page 27: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/27.jpg)
DEMO: Hooks
![Page 28: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/28.jpg)
Handling Concurrency
![Page 29: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/29.jpg)
OSGi Concurrency Basics
Bundle state changes are thread-safe
Service register/unregister/lookup are thread-safe
No ordering guarantees
No managed thread-safety for user code
![Page 30: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/30.jpg)
Interacting with OSGi state changes
Listener infrastructure• FrameworkListener
• BundleListener
• ServiceListener
BundleActivator callback
![Page 31: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/31.jpg)
Concurrent Application Design
Define consistency model• Prefer weak consistency
Use OSGi events to drive your system• Guarantees interaction with all state changes (refresh etc)
![Page 32: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/32.jpg)
DEMO: Concurrency
![Page 33: Building Server Platform with OSGi and Equinoxjavasymposium.techtarget.com/.../RHarrop_osgi_equinox.pdf · 2009-03-12 · Building Server Platform with OSGi and Equinox Rob Harrop](https://reader034.fdocuments.us/reader034/viewer/2022042023/5e7b9dab7f4bad7da61fe9b3/html5/thumbnails/33.jpg)
Q&A