'. '

Talk:OSGi

From APIDesign

(Difference between revisions)
Jump to: navigation, search
(Comment provided by Mirko Jahn - via ArticleComments extension)
Line 31: Line 31:
--[http://osgi.mjahn.net Mirko Jahn] 19:59, 23 November 2011 (CET)
--[http://osgi.mjahn.net Mirko Jahn] 19:59, 23 November 2011 (CET)
</div>
</div>
 +
 +
A comment by [[Jesse]] Glick left at [http://netbeans.org/bugzilla/show_bug.cgi?id=205019 bug 205019]:
 +
I think this is a bit off the mark. Seems like [[Eclipse]] is not really using [[OSGi]]
 +
as designed. Proper [[OSGi]] bundles are (acc. to spec) supposed to work regardless
 +
of what other bundles have or have not been started; that is why dynamic
 +
services exist, and why bundles are not started in topological order. In other
 +
words, we are working around misdesign in [[Eclipse]], not [[OSGi]] per se. The problem
 +
presumably does not affect [[Eclipse]] and its RCP apps because they are not
 +
attempting to load code from an arbitrary compliant [[OSGi]] container, and so can
 +
make assumptions about runtime behavior not guaranteed by the spec.
 +
 +
--[http://netbeans.org/bugzilla/show_bug.cgi?id=205019 Jesse Glick] 14:00, 23 November 2011 (CET)

Revision as of 17:31, 24 November 2011

Comments on OSGi <comments />


Neil Bartlett said ...

In the introduction you appear to be asking to be enlightened about OSGi, but then you go on to attack it from a position of ignorance and with heaps of bad attitude. Sorry but this is not the way to engage with people when you're asking for help.

If you have some specific questions about how or why OSGi works the way it does, then I and many others will be delighted to help you on the osgi-dev mailing list. Unfortunately this particular page is little more than a rant and can't be the basis for useful discourse.

--Neil Bartlett 00:07, 20 November 2011 (CET)

Hello Neil, thanks for your comment. Yes, you are right, the page is unlikely good start for a useful discourse. On the other hand, it nicely illustrates my frustration with OSGi. Still, I'd be glad to be enlighten about the design misconceptions.

--JaroslavTulach 10:02, 21 November 2011 (UTC)

Mirko Jahn said ...

First of all, I agree that OSGi is not perfect. In fact I do not know any technology that reached some sort of complexity that doesn't have its flaws. I guess that's nature. However, I think you're missing some background/ experience in the underlying concepts and frameworks you're referring too.

First of all, start/stop of a bundle. Here it is important to distinguish between a mere library and a state aware module. For libraries it is perfectly fine to not have an initialization (static initialization is fine here as well, but no "object" related one). In the OSGi world you then do not need to create an Activator. For all modules that are in fact state aware or need some sort of initialization (like Service dependencies), you could create you Activator (or use a declarative way of expressing that). In case a module does not comply with this contract this is a bug in the bundle code. As a general rule, you only expose API's and provide the instances as services, as long as the bundle is not started, no services will be available and no harm is done. Of course there is the "ugly" overhead of needing to know what bundles need to be started and which don't (you could also start all of them - no overhead in case of library bundles, because they won't execute any code). This seems not entirely clean as an approach, but it is powerful. Just imagine you have one bundle providing the API and a simple default service with the implementation. Once you realized the implementation is not good enough, you could just go ahead, reuse the API and not the exposed service (simply do not start the bundle) and provide your own bundle implementing the service in a way you require it.

Second, stopping order. There is an order in which bundles are stopped and they are stopped in the reverse order they were actually started, so what you saw might be a timing issue or an error in the implementation. Also Eclipse is not a perfect OSGi citizen. They did a lot to improve that but they are still not there. For instance many bundles still do not use the service registry, but a more static eclipse specific construct that has flaws with the dynamism of OSGi. I guess this might explain the problem you were experiencing. Also when done correctly (with services), a stopped bundle would not expose the service any longer and the bundle consuming such service would be able to call such bean (because it wouldn't find it) - no harm could be done here. Unfortunately the developer has to account for that or us a framework that does it for him like BluePrint for instance.

Range dependencies are tricky, I agree. Also the approach on handling the correct version, updating handles in the container, refreshing the wiring between bundles. All that is not trivial and error prone. However, I haven't seen anything even close to what is possible with OSGi. You could by designing the exposed and consumed packages correctly, a powerful and future prove API. Implementers know base on version changes when they have to take a closer look (minor version change) and simple service consumers can rely on the major version as an indicator that something might have changed that they should be aware of. Especially with many modules, keeping track of changes is hell. With such ranges, it at least gives you a way to better track where to look and what to adapt in case something happens. This is still not perfect and I am not sure there is a silver bullet at all, but it's the best thing I've seen so far.

To summarize what I am trying to say. OSGi, like many other specs, is not perfect and there might be a better one in the future, but for the time being, it is pretty good and well thought through. Unfortunately the concepts are not simple and certainly not easy to adhere. Especially with the latest version 4.3, many improvements have been done to make it easier and remove potential for errors, but like every complex system, one first has to know it to fully appreciate it. ;-)

--Mirko Jahn 19:59, 23 November 2011 (CET)

A comment by Jesse Glick left at bug 205019: I think this is a bit off the mark. Seems like Eclipse is not really using OSGi as designed. Proper OSGi bundles are (acc. to spec) supposed to work regardless of what other bundles have or have not been started; that is why dynamic services exist, and why bundles are not started in topological order. In other words, we are working around misdesign in Eclipse, not OSGi per se. The problem presumably does not affect Eclipse and its RCP apps because they are not attempting to load code from an arbitrary compliant OSGi container, and so can make assumptions about runtime behavior not guaranteed by the spec.

--Jesse Glick 14:00, 23 November 2011 (CET)

Personal tools
buy