Java plugin framework choice

Marcus Leon picture Marcus Leon · Oct 23, 2009 · Viewed 22.4k times · Source

We're trying to determine how to implement a simple plugin framework for a service we are implementing that allows different types of calculators to be "plugged-in".

After reading a number of posts about Java plugin frameworks, it seems like the most common options are:

OSGI seems to be more than we need.

"Rolling your own" is ok but it would be nice to reuse a common library.

So we're down to the JPF and JSPF. JPF doesn't seem to be in active development anymore.

JSPF seems very simple and really all we need. However I haven't heard much about it. I've only seen one post on StackOverflow about it. Does anyone else have any experience with JSPF? Or any other comments on this design choice?


Update: There isn't necessarily a correct answer to this.. however we're going to go with Pavol's idea as we need just a really, really simple solution. Thanks EoH for the nice guide.

Answer

EoH picture EoH · Nov 2, 2009

(Disclaimer: I am the author of JSPF, so better take my comment with a grain of salt ;-)

The main reason I started with the JSPF was because I had the same problem as you have now: I was looking for a simple solution to make my thesis-project 1) extensible and 2) give it a more or less clear code structure.

The reason why I haven't decided to use an existing framework was because most of them were so heavyweight to start with, that I got lost in reading documentation and was almost forgetting my original task. So, according to your statement

We're trying to determine how to implement a simple plugin framework for a service we are implementing that allows different types of calculators to be "plugged-in".

I'd think that you could give JSPF a shot and see how far you come within one or two hours.

However, the final decision also depends a bit on what exactly you want to achieve, and the specific circumstances.

I have heard positive results from a number of individuals who have been using it to structure their projects or load plugins in their projects. On the other hand, I also know of one person in our department who discarded it again because he didn't feel it was mixing well with his programming style.

So, to answer your question briefly (and surely in a biased way), I would use

OSGi for projects and teams

  • which are large and have many people working on it
  • that justify the overhead of setting up the infrastructure
  • in need of the specific services offered

JPF for projects and teams

  • of medium size (?, honestly I am not sure about the project / team size they are targeting)
  • which are in need of more structured facilities to organize their code, like XML configurations, detailed plugin lifecycle management, extensible plugins ...

JSPF for projects and teams

  • of small size, following an agile paradigm
  • that just need something that works out of the box, without the need of configurations or setup
  • willing to sacrifice some features for simplicity

I hope you find the plugin framework most suitable for your scenario. And, no matter what you try, I would be happy to hear about your results.