开发者

Using OSGi to implement a modular API

We are planning to develop a client side Java API t开发者_运维知识库o retrieve stock market data. It is expected to design the API as modular system so that various components can be plugged into the core API to facilitate extended features.

Components should be plugged into the core API dynamically and there should be a way to control component's life cycle via common API.

Up to now my selection is to use OSGI container for the API and develop pluggable components as OSGi bundles. Since this is an API, will OSGi be the best solution for this context?

can anybody advise on me this?


Having worked w/ the OSGi f/w for close to a year, i've been totally impressed by what OSGi has to offer - strong and enforced modularity, zero downtime, reliable pluggability of modules and performance.

However, having said that, let me assure you that all the goodness is not instantly apparent. Be sure to get hold of some good technical document [the in-action book is a fine text, so is the r4 specification]. a lack of understanding can put you in the company of LinkageErrors and BundleExceptions, which are usually very cryptic, and can serve as good sources of headaches.

besides understanding the f/w, you should also emphasise on "good-practices" related to cohesion and loose-coupling, programming against interfaces. you should also look into the BND tool which is an excellent way to package the OSGi bundles.

you might often come across arguments stating that OSGi is quite an "overkill", and i won't outrightly deny it. however, if you truly desire the unique features available through OSGi, it's simpler to get your hands dirty w/ this f/w than to implement a complicated work-around from the scratch.

one last thing - you might keep encountering Spring time and again when working w/ OSGi, but it's really not required, and unless you're familiar w/ Spring it might not really be worth it to get into that as well.


We're working on a big project using osgi and Apache Felix. On the bonus side: we only rarely encountered a problem due to Osgi itself, no one in the last year anyway. Osgi do really work as promised.

On the minus side, many common library and framework doesn't behave properly (like Hibernate who doesn't return correctly on the ClassLoader chain). Trying to integrate with db and web container other than Jetty could be problematic.

In my view the biggest problem is that something like Osgi should be part of the Java Standard Api and should be supported by the whole toolchain. Apparently Oracle want to go with the Java Jigsaw project for the future, that is a much less ambitious modularisation standard.

Anyway if you need dynamic plugins, I think there is nothing better than Osgi around, but be prepared to write a lot of code to support it.


OSGi does provide pluggability, and is pretty mature. Rolling your own equivalent framework would be a lot of work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜