Tuesday, March 22, 2011

10 signs you're doing OSGi wrong

Examples of bad ways of using OSGi, summed up as:
  • Ignoring dynamism - assuming services are always available.
  • Using OSGi as an "applications" level programming platform - using OSGi API in pojos rather than keeping them pure and separating out OSGi-dependant code.
  • Ineffective modularization - OSGi has a granularity at the package level which should be adhered to; package rather than jar cohesion should be sought.
  • Over/under use of services - not everything should be a service but properly used it can simplify code.
  • The myth of "pure" OSGi - plan for and regularly perform refactoring. Package code such that inevitable refactoring can move the package without breaking API. Be agile.
Lots of examples of what not to do but correct usage was at the architectural level with few code examples. For instance we were told to not use BundleContext or ServiceTracker to get a service, leaving me a little dumbfounded. They did state we should use Declarative Services so we're half right. Now I'm on a mission to find out how to get a service.

1 comment: