Problem with netbeans platform platform

I am reading the Netbeans Platform Quick Installation Tutorial ( http://platform.netbeans.org/tutorials/nbm-quick-start.html ), and I don’t quite understand the 6th part in the “Modular Application Using Lookup” section, TIP:

During compilation, the @ServiceProvider annotation will create a META-INF / services folder with a file that registers your implementation of the TextFilter interface, following the JDK 6 ServiceLoader mechanism. You need to establish a dependency on the Utilities API module that provides the ServiceProvider annotation.

Does anyone know in which module I should install the dependency on the Utilities API module? Because when I install the dependency in MyFilter, the compiler tells me that it "cannot find the character".

+3
source share
2 answers

I realized I used an older version of netBeans that does not support this. It is available from version 6.7

+1
source

You need to make the MyFilter project dependent on the API Utilities module. And you need to change the code from

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

at

package org.demo.myfilter;

import org.demo.textfilter.TextFilter;
import org.openide.util.lookup.ServiceProvider;

@ServiceProvider(service=TextFilter.class)
public class UpperCaseFilter implements TextFilter {

    public String process(String s) {
        return s.toUpperCase();
    }

}

Note. If you add the module dependency first, you can use the Fix Imports element in the Source menu (CTRL-SHIFT-I / Clover-SHIFT-I) to automatically take care of the second.

+3
source

Source: https://habr.com/ru/post/1735493/


All Articles