|
org.openide.util.lookup 8.3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=SOURCE) @Target(value=TYPE) public @interface ServiceProvider
Declarative registration of a singleton service provider.
By marking an implementation class with this annotation,
you automatically register that implementation, normally in Lookup.getDefault()
.
The class must be public and have a public no-argument constructor.
Example of usage:
package my.module; import org.netbeans.spi.whatever.Thing; import org.openide.util.lookup.ServiceProvider; @ServiceProvider(service=Thing.class) public class MyThing implements Thing {...}
would result in a resource file META-INF/services/org.netbeans.spi.whatever.Thing
containing the single line of text: my.module.MyThing
Lookups.metaInfServices(ClassLoader)
Required Element Summary | |
---|---|
Class<?> |
service
The interface (or abstract class) to register this implementation under. |
Optional Element Summary | |
---|---|
String |
path
An optional path to register this implementation in. |
int |
position
An optional position in which to register this service relative to others. |
String[] |
supersedes
An optional list of implementations (given as fully-qualified class names) which this implementation supersedes. |
Element Detail |
---|
public abstract Class<?> service
If you need to register one class under multiple interfaces, use ServiceProviders
.
Requests to look up the specified interface should result in this implementation. Requests for any other types may or may not result in this implementation even if the implementation is assignable to those types.
public abstract int position
public abstract String[] supersedes
public abstract String path
Projects/sometype/Nodes
could be used.
This style of registration would be recognized by Lookups.forPath(java.lang.String)
rather than Lookup.getDefault()
.
|
org.openide.util.lookup 8.3.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |