Awhile back on TSS, I complained about OSGi possibly bleeding too much into applications. That OSGi did not belong within application code. This IBM article is a prime example of my point. Here we have standard Spring code and XML. Nowhere in there do you have OSGi APIs. Yet, you get OSGi classloading and lifecycle. I bet, that if you can’t already right now, Spring will eventually be able to register IoC references as direct dependencies within an OSGi kernel. There’s really no reason or advantage to have OSGi APIs bleed into application code.
Another example is JBoss 5. While not running on top of an OSGi kernel (instead its running on JBoss’s own special kernel) it can manage dependency and lifecycle for a variety of different component models like: Spring, JBoss MC, EJBs, JCA adapters, Queues, Topics, Servlets, etc. This can work because JBoss’s kernel provides a deployment abstraction and framework to publish and manage inter-component dependencies. The end goal here is that all these different component models can take advantage of all this dependency management without writing to specific APIs and to stay within the confines of their own component model’s specification. The metadata is there. The dependency information is there. There’s no reason to write to a specific deployment API to leverage these types of services.
This is what I had hoped OSGi would become. A standard kernel where classloading, deployment, and dependency management would be provided as low level services so that existing and new component models would have a standard way to mix and match themselves and to deploy themselves. In theory, such a kernel would allow JBoss’s Transaction Manager to run within a Web Logic server. JBoss’s EJB container to run within Websphere. Sun’s WS-* implementation to run within JBoss.
Maybe my concern is not real. Maybe most OSGi evangelists are not positioning OSGi as an application API. Let’s hope they aren’t.
Apr 02, 2009 @ 22:44:51
I think there’s definitely been an effort to allow developers to eliminate compile time dependencies on OSGi. As an example, the Declarative Services spec was changed recently to allow you to implement services as POJOs.
But it’s a good point that many people don’t think about this issue too much. We get all excited with the features that OSGi provides but don’t consider the consequences of compile time dependencies on the framework.
— Patrick
Apr 03, 2009 @ 02:57:34
What I do like about OSGi is not about the module system. I do like that too but is not essential. Its about the service layer. The way this allows me as a developer to decouple different components that I use. And how it changed the way I program, if I want to be a good citizen in the OSGi world and react accordingly to fact as a service being available or not or how I can still perform the job of my component without a certain service being available.
And lets not diminish the great job OSGI Alliance has done regarding the specs of compendium services, which in 99% of the cases I encountered services were just working as expected regardless the implementor. I recall the J2EE times when it was not an easy job to move your EJB’s from one Application Server to another. I do not know nowadays as I moved away from those things for a while…
You may say that I’m an OSGi evangelist but I’m one that moved from EJB 1.1 to EJB 2.0, Spring and then to OSGI. And for the moment I do not what to get back, not that they are exclusive. So, do not take that away from me. let me have the option. If I wanna use it, fine. Is MY decision.
Apr 03, 2009 @ 09:54:52
Removing dependencies on the OSGi APIs has been considered a best practice for many years. Spring-DM helps, as do other techniques in OSGi such as Declarative Services, or even just isolating all of the OSGi API calls in “glue” classes while keeping application code in POJOs.
I believe that your second paragraph about what you “hoped OSGi would become” describes quite well what OSGi already is and has been for some time.
Apr 03, 2009 @ 14:36:17
@Neal
You should see some of the deployment abstractions we have in JBoss 5. For example, if you want to augment a servlet deployment you can plug a deployer in that gets notified of servlet metadata, changes/adds to it. All before the web archive gets deployed. An example of this would be Seam or JAX-RS looking for annotated component and adding new servlets or filters to the deployment. If we could get their in OSGi land, you’d have the ability to extend and expand the capabilities of a third party container. See where I’m getting at?
Apr 03, 2009 @ 18:16:39
Bill,
Now I’m confused about your objection. On TSS article I posted, I had understood your comment to be that app developers should never use OSGi at all, that it is something reserved for system programmers such as yourself.
This post seems to be arguing in favor of application developers using the OSGi programming model.
The only difference I see now is that you appear to be qualifying your earlier statement with something like “as long as you use some kind of inversion of control abstraction, the OSGi programming model is ok for application developers.”
Is that right?
BTW check my OSGi blog for a recent entry on the tooling issue, which is closely related to this debate: http://modualrit.blogspot.com/2009/04/tooling-related-challenges-for-osgi-eeg.html
Eric
Apr 03, 2009 @ 19:26:46
@Eric
Its probably both Eric. You misinterpreted what I was previously talking about. I was probably a bit unclear.
Again, I do believe OSGi APIs should be reserved for system programmers. I *know* the benefits of something like OSGi can be abstracted away from application developers and brought to existing component models like Spring, EJB, Seam, or any other component model. It just seemed from the OSGi Remoting thread that some of you were pushing OSGi as an application-consumable API.
Dependency management, classloading, hot-deployment are all great things Eric. Are all core features that at least JBoss users are used to.
Apr 03, 2009 @ 19:56:11
Bill,
Sorry for the misunderstanding! It’s also often unclear what people mean by the “OSGi programming model.” I’m sure I have contributed to the lack of clarity here.
What I mean by it is using the OSGi service model to create applications by whatever means are available. I don’t usually distinguish among the various means available to create, register, and consume OSGi services, since what I focus on are the services themselves and their interactions.
This is perhaps a subtle difference in how I would make recommendations, but I think that we are more in agreement than I first thought. I would not recommend against someone using the OSGi APIs, if they really wanted to do so I think it’s ok. I would definitely recommend that someone use something like the Blueprint service, OSGi DS, iPOJO, or Peaberry instead of the native APIs, but if someone really wanted to use them (and was aware of all the alternatives) I wouldn’t try to stop them. It’s a small difference but perhaps that is how the misinterpretation occurred.
Thanks,
Eric
Jan 08, 2010 @ 12:57:10
As per my own exprience with JBoss and now some bits on OSGi I feel JBoss modular architecture and handling of the lower level issues like hot deployment and classloading gives us more productivity.
As an example exposing some endpoints over jax-ws or jax-rs we need to get the compatible OSGi bundles as well as stick to Jetty as the servlet container as I dont see Tomcat OSGi bundles available. So choices are limited as of today..
I will prefer to commit for JBoss with Tomcat rather then OSGi which should stay at the middleware services level