Writing your own plugin infrastructure is fun, but completely unnecessary. This is a solvable problem, and you are not going to write a higher quality than the one that already exists and is proven in this area. I would say choose your battles.
I already tried JSPF and found it incredibly easy to use. And this comes from the one who did exactly what you are trying to do: I created my own plug-in infrastructure (mainly for the same purpose: dynamically load minigames) from scratch, recording the loading of classes and the framework myself. And if I did this again, I would not hesitate to think of a structure as a JSPF.
To load all classes from jars into a directory that is bound to a specific interface (say Game ), this is simple:
PluginManager pm = PluginManagerFactory.createPluginManager(); pm.addPluginsFrom(new File("plugins/").toURI()); Collection<Game> games = new PluginManagerUtil(pm).getPlugins(Game.class);
IIRC, the only requirement for Game performers is that it is marked with the @PluginImplementation annotation.
Edit
And then:
for ( Game game : games ) { game.someMethod(); }
source share