org.netbeans.spi.project
@Retention(value=SOURCE) @Target(value={TYPE,METHOD}) public @interface ProjectServiceProvider
LookupProvider
but registers a single object into a project's lookup.
An annotated class must have one public constructor, which may take Project
and/or Lookup
parameters.
An annotated factory method must have similar parameters.
public final class TestAction implements ActionListener { public void actionPerformed(ActionEvent e) { System.err.println("===> running action"); for (Project p : OpenProjects.getDefault().getOpenProjects()) { Service s = p.getLookup().lookup(Service.class); if (s != null) { System.err.println("===> got a service: " + s.m()); } else { System.err.println("===> nothing for " + p); } } } public static abstract class Service { static { System.err.println("===> loading Service"); } public abstract String m(); } @ProjectServiceProvider(service=Service.class, projectType="org-netbeans-modules-java-j2seproject") public static class ServiceImpl extends Service { static { System.err.println("===> loading ServiceImpl"); } private final Project p; public ServiceImpl(Project p) { this.p = p; System.err.println("===> new ServiceImpl on " + p); } public String m() { return ProjectUtils.getInformation(p).getDisplayName(); } } }
Modifier and Type | Required Element and Description |
---|---|
Class<?>[] |
service
Service class(es) to be registered.
|
Modifier and Type | Optional Element and Description |
---|---|
String[] |
projectType
Token(s) denoting one or more project types, e.g.
|
LookupProvider.Registration.ProjectType[] |
projectTypes
Alternate registration of project types with positions.
|
public abstract Class<?>[] service
public abstract String[] projectType
"org-netbeans-modules-java-j2seproject"
LookupProviderSupport.createCompositeLookup(org.openide.util.Lookup, java.lang.String)
may be used with the path Projects/TYPE/Lookup
.public abstract LookupProvider.Registration.ProjectType[] projectTypes
projectType()
(or both).Built on March 18 2014. | Portions Copyright 1997-2014 Sun Microsystems, Inc. All rights reserved.