I am really excited about the Netbeans OpenIDE Lookup library! The library allows you to retrieve service-providing class implementations at runtime. My favorite part is that it is elegantly simple to use, just one call to a static method returns all of the registered service providers for a particular abstract class or interface. On top of this it is easy register modules so that they are discoverable via the Lookup library; all that you need to add to implementations is one simple @ServiceProvider annotation.
This library prevents a great deal of hard-coding. This became particularly evident in my spanning tree module development for the Gephi project. I wanted to make the module capable of finding a spanning tree using any one of an undefined number of spanning tree algorithms. With the Lookup library, someone else can add a @ServiceProvider-annotated implementation of the abstract SpanningTreeAlgorithm class, and have it appear in the GUI and be utilized to find a tree. No modification of the GUI code or the abstract class would be necessary.
If you are pumped about making your Java software more dynamic and extendable, see the following links:
- Lookup Library API Documentation (how to look up implementations)
- Documentation on the @ServiceProviderAnnotation (how to register implementations)
- Java provides a similar non-Netbeans-specific feature