-
@Documented @Repeatable(ServiceProviders.class) @Retention(RUNTIME) @Target(TYPE) public @interface ServiceProvider
Declarative verification of a singleton service provider. By marking an implementation class with this annotation, you automatically verify that the implementation to be loaded byServiceLoader
is valid and that a corresponding provides … with directive is present into themodule-info.java
file. The service provider class must be public and have a public no-argument constructor.Example of usage:
package my.module; import my.module.spi.SomeService; import eu.ess.xaos.tools.annotation.ServiceProvider; @ServiceProvider(service=SomeService.class) public class MyService implements SomeService { ... }
Note: when using
ServiceProvider
theservice()
class must be listed in themodule-info
class inside a uses statement. Moreover a provides … with statement must also be added to declare the annotated class as provider for the parameter class.- Author:
- claudio.rosati@esss.se
- See Also:
- NetBeans Lookup API
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description int
order
An optional number determining the load order of this service relative to others.
-
-
-
Element Detail
-
service
Class<?> service
The interface (or abstract class) to register this implementation under. It is an error if the implementation class is not in fact assignable to the interface.Requests to look up the specified interface through
ServiceLoader.load(java.lang.Class)
should result in this implementation.- Returns:
- The service interface or abstract class.
-
-
-
order
int order
An optional number determining the load order of this service relative to others. Lower-numbered services are returned in the lookup result first. Services with no specified position are returned last (ordered by name), followed by services registered using the standard Java mechanism.- Returns:
- The load order of this service relative to others.
- Default:
- 2147483646
-
-