views:

9

answers:

0

I've used the JDK's SPI mechanism in numerous other applications without any problem; however, I can't seem to get it to work within Grails.

I've tried the usual code (shown below) both from within a static initializer, and from within a class constructor, but neither worked.

ServiceLoader loader = ServiceLoader.load(QueryEngine.class);
Iterator<QueryEngine> it = loader.iterator();

The iterator doesn't actually iterate through the implementing classes.

I've also tried:

ServiceLoader.load(QueryEngine.class, Thread.currentThread().getContextClassLoader());

which should use the classloader for the current class, but that doesn't work either.

Is there some other mechanism I should be using to load implementing classes?