Take the 2-minute tour ×

I have a problem and possibly found a solution, however I have doubts that everything I think is possible to achieve with following technologies. To details: I have to write an application in Java that will solve some problem (details are not important). Mentioned problem can be solved by some algoritms. Each algoritm is solving in diffrent way. Everyone of them is computationally complex, but they can be distributed in many threads (and clusters). What's more, at the moment I want to implement only one algorithm, other in future, so I would like to my application be flexible and can join other algorithms in future. My technicaly solution is to use OSGi container and implement algorithms as bundles. I'll create an interface that will cover abstract algorithm solution, and in this way I will be able to join algorithms written in future without big cost (or maybe any?). However I've got some doubts:

  1. I know my description is very general, but do you think that this approach is good? Will that construction "survive"?:)
  2. I'm not quite sure if is possible to write multithread (or even multicluster) application using OSGi. And if it is possible, can I write in the same way like "normal" java app, using threadExecutors, futuretasks and so on?
  3. What about clustering problem? I found framework that allow that (http://mpj-express.org/) but as I reed the readme, the way it works can't be merged with OSGi bundle? Some suggestions about this?

Thanks in advance for any advices!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, I think it will work out fine.

In a bit more detail:

  • Multithreading is no different in OSGi, you can write it the same way as 'normal' java.
  • I don't know MPJ, but there are some quite mature clustering solutions for OSGi, like Apache Cellar, Service Fabric or Fuse Fabric. Look for dOSGi (distributed OSGi).

I do suggest you use Declarative Services or Blueprint, that way you can use POJO's, and only use OSGi for wiring them together. If for whatever reason you want to use them outside OSGi it is easier to do that as you don't rely on the OSGi api's

share|improve this answer
Thanks for your advices! I will look into that. –  PastorPL Jan 15 '13 at 11:36

Your Answer


