Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

most suitable OSGi platform? [closed]

We are currently developing a new software for which we decided OSGi modularity would be quite useful, as the software itself can be pretty well decomposed into modular structure in order to avoid code mess in the future and be able to easily add new features and hook into existing ones.

I have been playing with two (probably most popular) OSGi platforms, Eclipse Equinox (with Gemini Blueprint) and Apache Felix (with Aries). Basically I am now at the point of making a decision, which one we should use.

We have pretty much experience with Spring, so we would like to continue using that, along with annotations (such as @Autowired for autowiring beans WITHIN the SAME bundle, @ServiceReference for autowiring across bundles), some particular Spring addons (such as Data JPA), Hibernate as a JPA provider (so far, we have experience only with Hibernate as an JPA implementation, it has all features we need so we want to avoid having to switch to something else), JMS messaging (with ActiveMQ client) and few other features. Later on, we also want to be able to implement our own security manager (to control access to certain bundles, based on e.g. their digital signatures, certificates with Permissions embedded in them)

So far, I have been able to make two testing bundles (one was using a service from the other) and treat them as Spring Beans on Equinox with Gemini BP. However, I've had some problems with annotations, though (and I don't really like wiring beans in XMLs, especially with not so complicated architecture - most of them are Singletons).

I've tried Aries as well (but not succeeded with enabling Spring there; probably just haven't spent enough time on that yet :) ).

Which OSGi platform do you recommend for such use case?

like image 637
Michal Boska Avatar asked Jan 08 '14 11:01

Michal Boska


1 Answers

This one will be probably not the best answer but I think it is useful for you if I share my experiences. A couple of years ago I had exactly the same situation. I was experienced with Spring, JPA (Hibernate and EclipseLink). I found OSGi modularity useful so we started projects based on OSGi.

As I had used Spring before, it was obvious to use Blueprint (we ended up using Apache Aries as it was more stable than Gemini Blueprint). We did that for two years. However, we had many issues so I started to implement a new Blueprint container based on the specification. I heard many times that OSGi DS is better but as I had been a Spring fan before, the tutorials did not make me change my mind. I had the feeling that ConfigAdmin would have been really nice to use but with Blueprint it was not really possible to write nice code (I know that there is the cm namespace but it did not work well for us).

At the EclipseCon I talked to Peter Kriens and he convinced me to try out DS on a project. I did so and now I feel really sad about the time I used Blueprint (I did not mean to hurt you, Aries guys :)). Declarative Services together with ConfigurationAdmin is designed to work within the OSGi modularized world. I am pretty sure I know well your current feelings but if I really suggest to you not to make the same mistakes I did. Try to create two bundles with DS components, getting the Configuration from felix-configadmin and feel the power.

As of JPA, we used first EclipseLink. As it was too buggy, we switched to Hibernate. I wrote an adapter to be able to use it (available on GitHub). As much as I know, Hibernate has now more support in this topic, I have never tried it. In the end, we decided to leave JPA. We are on the end of replacing our infrastructure from JPA to Liquibase+QueryDSL. The components are more or less ready at https://github.com/everit-org, we need to work on documentation. If you are interested, why we switched from JPA, read the comments under the this blog post: http://blog.osgi.org/2013/12/attributes-attributes-and-attributes.html

My answer in short:

  • If you want to avoid of using Declarative Services due to historical reasons (that is a mistake, but I can understand it), use Apache Aries or Gemini BP (that you find better). As Apache Aries was created for OSGi, all namespace handlers that are written for Aries will work for sure. Aries will not support the namespace handlers written for Spring as Aries has its own API. However, ActiveMQ and other projects have Aries namespace handler implementations. Once more, I suggest to consider using DS instead and write your code in Java instead of XML. If you design small modules, deployment time will not be a problem. On the other hand, you will get lots of benefits at the configuration and stability part.
  • JPA with Hibernate can be used in OSGi. An example can be found here: https://github.com/everit-org/osgi-hibernate. More up-to-date examples are available if you google. I recommend that you should look around as JPA works, but it is not OSGi friendly.
  • Concerning to the engine: If you use Felix, you can be sure that your code will run on other containers like Equinox or Knopflerfish. The other two has special features that if you use, you may run into the problem that you cannot port your code later. I personally use Equinox, but it has historical reasons.
like image 164
Balazs Zsoldos Avatar answered Sep 21 '22 04:09

Balazs Zsoldos