views:

1552

answers:

9

I've read on wikipedia and other sites about OSGi, but I don't really see the big picture. It says that it's a component based platform, and that you can reload modules at runtime. Also the "practical example" given everywhere is the Eclipse Plugin Framework.

My questions are:

1) What is the CLEAR and SIMPLE definition of OSGi?

2) What COMMON PROBLEMS does it solve?

By "common problems" I mean problems we face everyday, like "what can OSGi do for making our jobs more efficient/fun/simple"

Thanks.

+2  A: 

edited for clarity. OSGi page gave a better simple answer than mine

A simple answer: An OSGi Service Platform provides a standardized, component-oriented computing environment for cooperating networked services. This architecture significantly reduces the overall complexity of building, maintaining and deploying applications. The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring a restarts.

In a single application structure, say the Eclipse IDE, it's not a big deal to restart when you install a new plugin. Using the OSGi implementation completely, you should be able to add plugins at runtime, get the new functionality, but not have to restart eclipse at all.

Again, not a big deal for every day, small application use.

But, when you start to look at multi-computer, distributed application frameworks, that's where it starts to get interesting. When you have to have 100% uptime for critical systems, the capability to hotswap components or add new functionality at runtime is useful. Granted, there are capabilities for doing this now for the most part, but OSGi is trying to bundle everything into a nice little framework with common interfaces.

Does OSGi solve common problems, I'm not sure about that. I mean, it can, but the overhead may not be worth it for simpler problems. But it's something to consider when you are starting to deal with larger, networked, applications.

scubabbl
Are you saying that OSGi provides an inter-JVM mechanism for service discovery in a distributed environment? My own question (http://stackoverflow.com/questions/375725/how-does-osgi-manage-interaction-of-components-running-in-separate-jvms#378173) has been answered as if OSGi is single-VM
oxbow_lakes
What do you mean by "networks" in "change the composition dynamically on the device of a variety of networks"?
Thilo
+10  A: 

Jar hell, for instance.

Fabian Steeg
+12  A: 

I've found the following benefits from OSGi:

  • Each plugin is a versioned artifact that has its own classloader.
  • Each plugin depends on both specific jars that it contains and also other specific versioned plug-ins.
  • Because of the versioning and isolated classloaders, different versions of the same artifact can be loaded at the same time. If one component of your application relies on one version of a plug-in and another depends on another version, they both can be loaded at the same time.

With this, you can structure your application as a set of versioned plugin artifacts that are loaded on demand. Each plugin is a standalone component. Just as Maven helps you structure your build so it is repeatable and defined by a set of specific versions of artifacts it is created by, OSGi helps you do this at runtime.

Travis B. Hartwell
One of the biggest benefits of this strong versioning mechanism is that dependencies are verified during deployment, meaning that you get unresolved dependency errors at deployment time instead of NoClassDefFoundErrors at run time.Aside from the module system, the OSGi service layer does deserve mention. It's not as easy to start with because it impacts your architecture (and it's not always appropriate to use it), but it's a very powerful system once you have adopted it.
Barend
+15  A: 

I don't care too much about the hotplugability of OSGi modules (at least currently). It's more the enforced modularity. Not having millions of "public" classes available on the classpath at any time protects well from cyclomatic dependencies: You have to really think about your public interfaces - not just in terms of the java language construct "public", but in terms of your library/module: What (exactly) are the components, that you want to make available for others? What (exactly) are the interfaces (of other modules) you really need to implement your functionality?

It's nice, that hotplug comes with it, but I'd rather restart my usual applications than testing all combinations of hotplugability...

Olaf
You can achieve the same using Guice and packages, exporting only interfaces and Modules and marking everything else package-private
Pablo Fernandez
+1  A: 

It is also being used to bring additional portability of middleware and applications on the mobile side. Mobile side is available for WinMo, Symbian, Android for example. As soon as integration with device features occurs, can get fragmented.

+5  A: 

I just wrote a blog post attempting to describe why OSGi is useful. I'd definitely be interested in your feedback.

http://rcpquickstart.com/2009/05/04/why-is-osgi-important/

--- Patrick

I commented on your post
Pablo Fernandez
This is very clear and simple, and actually convinced me there is benefit when I was originally thinking there was none for my purposes. Adding (requiring?!) encapsulation at a higher level is not obvious in any of the OSGi docs that I've read, but seems like the most significant benefit.
Zac Thompson
+1  A: 

I have also just blogged about OSGi (from a pure beginner's point of view - I was as confused as you were!)

Check out http://seewah.blogspot.com/2009/05/osgi-next-big-thing-beginners-view.html

IMHO, hotswappability of modules is great, but the killer feature for me is the ability to eliminate jar hell.

Thanks!

A: 

I'd upvote Patrick's link: http://rcpquickstart.com/2009/05/04/why-is-osgi-important/ if I had the rep.
It does a great job of describing OSGi

Markus Jevring
+1  A: 

I think the following blog post from Hal Hildebrand answers part of the question quite nicely. My latest incoherent ramblings on (one of) the value propositions of OSGi

Mirko Jahn