First, some brief overview of the two technologies. OSGi is a framework aims to create an component/plug-in software. I’ve already mention OSGi in a previous post.
SCA stand for Service Component Architecture. Oracle, IBM and others came up with the conclusion than SOA is just a buzz word and without a plain framework, everyone can say they do SOA development but actually doing something else … They have created several specifications to help to produce a SOA software. Key features are separation of concern, component oriented, dynamic binding, aggregation/composition of services/components.
SCA target high level / business services whereas OSGi is more targeting modularity at lower level.
Micro-kernel is becoming more and more popular (jboss, glassfish,…). OSGi coming from mobile has standardize a lot of “kernel services” (logging, configuration, provisioning), and now start to enter the enterprise, it’s helps a lot. Whereas JEE focus was on middle-ware infrastructure, OSGi gives a lot to manage what was left to developers. Dynamic loading in it’s hearth, OSGi make the perfect micro-kernel for those we want “always on” servers.
Obviously you will be able to leverage enterprises technology using Spring as it integrate OSGI very nicely using Spring-OSGi-Extender (Spring DM). It manage at startup to wire automatically OSGi services and components (bundles). This could become your first layer, this would be called the OSGi-Extender layer.
Core services might be our own business modules with your domain, repository and value objects or 3rdparty library/services like JPA implementation. Fortunately, OSGi enterprise 4.2 being just released, it’s where you will see this modules. SCA is even mentioned in this specification.
This composition of services/composant will be done and expose as a business service with multiple endpoint. It’s where we can see that the couple OSGi/SCA brings a lot and helps you focus on your business. OSGi modules to manage technical component for keeping DRY principles and SCA to expose business endpoint with automatic wiring and security enabled.
This schema taken from Apache Tuscany page express how SCA does the wiring between business services. As a typical SOA, you will expose your “contract”. Within SCA, you will configure additionally how you want to expose it (using RMI, WS or any kind of protocol supported by the SCA implementation you choose).
By doing so, you let decide protocol at deployment stage, not at development stage. It make your software very flexible and let you focus on your business code.
Managing modules/components and there dependencies require to use an automatized tools (maven, nexus) but it’s a different subject.
For reference, Apache Tuscany is an SCA implementation, in there next release (2.0) they will provide an Distributed OSGi using SCA). Apache aegis is an incubator projects providing most of jee “cores services” (jpa,jta,jmx,…).
