Download NetBeans!

20081104 Tuesday November 04, 2008

@org.openide.util.lookup.ServiceProvider

Read issue 150447 and then look at the code below:

public interface DemoInterface {
    
    public String getName();

}
@org.openide.util.lookup.ServiceProvider(service=DemoInterface.class)
public class DemoServiceProvider1 implements DemoInterface {

    public String getName() {
        return "John";
    }

}
public class Installer extends ModuleInstall {

    @Override
    public void restored() {
        for (DemoInterface di : Lookup.getDefault().lookupAll(DemoInterface.class)) {
            System.out.println("Hello " + di.getName());
        }
    }

}

The above works using a build I picked up today. No more META-INF/services (unless you want to continue using that approach). I especially like Jarda's comment in that issue: "This is how our future should look like". Would be nice to work with Actions and so on via annotations and to increasingly forget the layer.xml file. Seems extremely likely that will be increasingly possible. That would be the biggest revolution for the NetBeans Platform since its creation.

Nov 04 2008, 07:47:24 AM PST Permalink