Monday Nov 03, 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.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« November 2008 »
SunMonTueWedThuFriSat
      
4
7
15
16
17
20
22
23
25
27
29
30
      
Today