Package nbbrd.service

Annotation Type ServiceDefinition


@Documented @Target(TYPE) @Retention(SOURCE) public @interface ServiceDefinition
Declarative definition of a service that generates a specialized service loader that takes care of the loading and enforces a specific usage.
Author:
Philippe Charles
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Specifies the batch class to use in batch loading.
    Specifies the fallback class to use if no service is available.
    This option is only used in conjunction with Quantifier.SINGLE.
    Specifies the fully qualified name of the loader.
    An empty value generates an automatic name.
    Specifies how many instances are returned by the loader.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name to suppress single-fallback warning using @SuppressWarnings
  • Field Details

  • Element Details

    • quantifier

      Quantifier quantifier
      Specifies how many instances are returned by the loader.
      Returns:
      a non-null quantifier
      Default:
      OPTIONAL
    • loaderName

      String loaderName
      Specifies the fully qualified name of the loader.
      An empty value generates an automatic name. A non-empty value is interpreted as a Mustache template with the following tags:
      • {{packageName}}: The package name of the service class, or "" if this is in the default package.
      • {{simpleName}}: The service class name.
      • {{canonicalName}}: The full service class name.
      Returns:
      a fully qualified name
      Default:
      ""
    • fallback

      Class<?> fallback
      Specifies the fallback class to use if no service is available.
      This option is only used in conjunction with Quantifier.SINGLE.

      Requirements:

      • must be assignable to the service type
      • must be instantiable either by constructor, static method, enum field or static final field
      Returns:
      the fallback class if required, Void otherwise
      Default:
      java.lang.Void.class
    • batchType

      Class<?> batchType
      Specifies the batch class to use in batch loading.

      Requirements:

      1. Batch type must be an interface or an abstract class
      2. Batch method must be unique
      Returns:
      the batch class if required, Void otherwise
      Default:
      java.lang.Void.class