I'm looking for functionality in Java similar to the .NET Managed Extensibility Framework (http://mef.codeplex.com/). For those who don't know MEF, I want something like this:
Given an interface
public interface IFoo {
...
}
Dynamically load an implementation of an interface by looking in loaded jars.
IFoo foo = loadClassThatImplementsInterface<IFoo>();
The point is that the programmer does not know the name of the implementation at code time, but provides in code an extentsion point.
Is this not possible in Java at all? I found some Google hits stating that it is not possible, but this seems a bit... eh?
There are plenty of examples of using a class loader when the fully qualified name of the implementation is know at compile time. That is not what I want.