Working with micro-services is arguably the best part of OSGi development. However, everyone agrees that tracking service dependencies with the bare-bones OSGi API is not ideal. So, you pick one of the available dependency managers: either Declarative Services, Felix Dependency manager, Blueprint or iPojo.
But how do you pick the right one? Easy! After this shoot-out you’ll know all about the performance, usability and other aspects of the existing dependency managers. We show the strengths and weaknesses of the implementations side-by-side. How usable is the API? What about performance, does it scale beyond trivial amounts of services? Does it matter which OSGi framework you run the dependency manager in?
Make up your mind with the facts presented in this session.
20. @uiterlix
@sander_mak
Since R4 (2005)
DS 1.1 with R4.2, DS 1.2 with R5
XML based
True POJOs
Or: DS annotations to generate XML
!
Additional abstractions:
ComponentContext for each component
ComponentFactory: client initiates instantiation
Bundle 1
Component!
Instance
Component!
Description
Bundle 2
Component!
Instance
Component!
Description
Service
reference
provide
Declarative Services
22. @uiterlix
@sander_mak
Eclipse Gemini Blueprint
DM Server Gemini Blueprint
Spec since R4.2 (2009)
Familiar for Spring devs
Declarative: XML based
Annotations in Aries, but not in spec (or Gemini)
Components proxied: ‘Dampens’ service dynamics
2009
23. @uiterlix
@sander_mak
Eclipse Gemini Blueprint
DM Server Gemini Blueprint
Spec since R4.2 (2009)
Familiar for Spring devs
Declarative: XML based
Annotations in Aries, but not in spec (or Gemini)
Components proxied: ‘Dampens’ service dynamics
2009
Bundle 1
Application
Context
Bundle 2
Service
reference
export
Bean
Bean
Bean
Application
Context
Bean
Bean
28. @uiterlix
@sander_mak
Felix Dependency Manager
DSL for component definition in Activator
Programmatic
Annotation based (bnd plugin)
Embraces service dynamics
Bundle 1
Component!
Instance
Bundle 2
Component!
Instance
Component!
Instance
Service
reference
adapt
Service’
publish
Service
aspect
Additional abstractions:
Aspect: intercept and republish service
Adapter: publish service with adapted interface
47. @uiterlix
@sander_mak
Declarative Services
No direct field injection
Defaults:
Delayed component (activate on use)
Static policy -> many reactivations
!
!
!
Static Dynamic
Reluctant Do nothing Rebind optionals
Greedy Reactivate Rebind
What if
‘better’
service
arrives?
59. @uiterlix
@sander_mak
BluePrint!
Strong focus on intra-bundle composition
Hides dynamicity (until TimeOutException…)
If dependency goes away, component is not
stopped. If service is exposed, unregisters it.
No lazy activation like DS
Whole ‘applicationContext’ started or not
(Custom) TypeConverters
Constructor/setter injection, no field injection
Namespace hell :(
!
73. @uiterlix
@sander_mak
Felix Dependency Manager
It’s code: dynamically create and depend
on services
Annotations available (+ bnd plugin)
Field injection, NullObject pattern
Manual mgmt. of list of dependencies :(
Services registered eagerly from Activator
Features: aspects, adapters
!
DM 4 coming up…
88. @uiterlix
@sander_mak
Felix iPojo
Both ‚static’ configuration and configuration using code
Dependency manager with the most advanced
features:
External handlers
Service binding interceptors
Stereotypes
Annotations limited to declaring components and
‚simple’ instances. XML recommended for declaring
instances.
Shell commands for component inspection
!
90. @uiterlix
@sander_mak
Benchmarks
Don’t be afraid of too many services ?
Promises…
!
„Each bundle may register zero or more
services. Each bundle may also use zero or
more services. There exists no limit on the
number of services, more than the ones given
by memory limits or java security permissions.”
(Knoplerfish tutorial)
101. @uiterlix
@sander_mak
iPojo and # of services
Timeinmillis
0
15000
30000
45000
60000
# services in service registry
50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600
iPojo
Injecting a single service into a single consumer on Equinox
102. @uiterlix
@sander_mak
Performance considerations
Use of LDAP filters
Filter complexity, service registry scans
Felix DM provides optimization though
indexing service properties
!
!
Bundle starting order
Service tracker obtain initial versus service
listener events
0
75000
150000
225000
300000
197 2878
Default With index
104. @uiterlix
@sander_mak
Conclusion
Features ranging from simple to advanced
(DS, Blueprint < DM < iPojo)
Annotation/XML-only frameworks are easy to
use but provide less dynamics
Consider the expected size of your application
(services, dependencies) and run some test
before choosing one!
You can mix & match
… but don’t do that