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.

    Internal storage summary:

     optional none                  :        final           Optional<T>
     optional basic                 :                        Optional<T>
     optional concurrent            :        final AtomicRef<Optional<T>>
     optional none       +singleton : static final           Optional<T>
     optional basic      +singleton : static                 Optional<T>
     optional concurrent +singleton : static final AtomicRef<Optional<T>>
    
     single   none                  :        final           T
     single   basic                 :                        T
     single   concurrent            :        final AtomicRef<T>
     single   none       +singleton : static final           T
     single   basic      +singleton : static                 T
     single   concurrent +singleton : static final AtomicRef<T>
    
     multiple none                  :        final           UmodifiableList<T>
     multiple basic                 :                        UmodifiableList<T>
     multiple concurrent            :        final AtomicRef<UmodifiableList<T>>
     multiple none       +singleton : static final           UmodifiableList<T>
     multiple basic      +singleton : static                 UmodifiableList<T>
     multiple concurrent +singleton : static final AtomicRef<UmodifiableList<T>>
     
    Author:
    Philippe Charles
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      Class<?> fallback
      Specifies the fallback class to use if no service is available.
      This option is only used in conjunction with Quantifier.SINGLE.
      String loaderName
      Specifies the fully qualified name of the loader.
      Mutability mutability
      Specifies the mutability of the loader.
      Class<? extends UnaryOperator<? extends Stream>> preprocessor
      Specifies the preprocessor class to be used in advanced preprocessing.
      This operation happens between loading and storage.
      It may include filtering, sorting and mapping.
      Quantifier quantifier
      Specifies how many instances are returned by the loader.
      boolean singleton
      Specifies if the loader must be a singleton.
      Class<?> wrapper
      Specifies the wrapper class to be used in basic preprocessing.
    • Element Detail

      • quantifier

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

        Mutability mutability
        Specifies the mutability of the loader.
        Returns:
        a non-null mutability
        Default:
        nbbrd.service.Mutability.NONE
      • singleton

        boolean singleton
        Specifies if the loader must be a singleton.
        Returns:
        true if the loader is a singleton, false otherwise
        Default:
        false
      • 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
      • wrapper

        Class<?> wrapper
        Specifies the wrapper class to be used in basic preprocessing.

        Requirements:

        • must be assignable to the service type
        • must be instantiable either by constructor or static method, both with single parameter of service type
        Returns:
        the wrapper class if required, Void otherwise
        Default:
        java.lang.Void.class
      • preprocessor

        Class<? extends UnaryOperator<? extends Stream>> preprocessor
        Specifies the preprocessor class to be used in advanced preprocessing.
        This operation happens between loading and storage.
        It may include filtering, sorting and mapping.

        Requirements:

        • must be assignable to UnaryOperator<? extends Stream<T>>
        • must be instantiable either by constructor, static method, enum field or static final field
        Returns:
        the preprocessor class if required, ServiceDefinition.NoProcessing otherwise
        Default:
        nbbrd.service.ServiceDefinition.NoProcessing.class
      • loaderName

        String loaderName
        Specifies the fully qualified name of the loader. An empty value generates an automatic name.
        Returns:
        a fully qualified name
        Default:
        ""