views:

54

answers:

2

I would like to discover all implementations of an interface during runtime in a Java app, and load those classes dynamically from JAR files that the user can add to a folder. It's a plug-in system, basically.

I found a few solutions for this:

Are there any other widely used solutions for this?

Update: There is no need for code separation, and OSGi seems to be far too complex for my simple needs right now. I also added "Simple" to the title of this question to clarify my intentions.

+3  A: 

It's bit on the heavy side, but you should consider Apache Felix or Eclipse Equinox, both are OSGi implementations which are very much alive and kicking, but possibly overkill for your needs. However, this is one of the very problems that OSGi is designed to solve.

skaffman
A: 

Like @skaffman told, OSGi and modern implementations built upon seems like a perfect solution. If you're on the guice bandwagon, consider iPOJO, which perfectly incorporates annotations in the OSGi stack (notice iPOJO works on any OSGi platform). If you're more in the XML/Spring bandwagon, consider using Blueprint.

Finally, considering JSPF, I won't share your opinon about its immaturity. Having collaborated a little on that project, I find it really useful in its field, as it allows easy plugin use, without the hassle and classpath separaion that OSGi provides.

Riduidel