Package nbbrd.service
Annotation Type 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classstatic final class -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the class that creates a service loader.booleanSpecifies if batch loading should be allowed.Specifies the fully qualified name of the batch loading.Specifies the class that deals with the cache cleaning.Class<?>Specifies the fallback class to use if no service is available.
This option is only used in conjunction withQuantifier.SINGLE.Specifies the fully qualified name of the loader.Specifies the mutability of the loader.Class<? extends UnaryOperator<? extends Stream>>Specifies the preprocessor class to be used in advanced preprocessing.
This operation happens between loading and storage.
It may include filtering, sorting and mapping.Specifies how many instances are returned by the loader.booleanSpecifies if the loader must be a singleton.Class<?>Specifies the wrapper class to be used in basic preprocessing.
-
Element Details
-
quantifier
Quantifier quantifierSpecifies how many instances are returned by the loader.- Returns:
- a non-null quantifier
- Default:
- OPTIONAL
-
mutability
Mutability mutabilitySpecifies the mutability of the loader.- Returns:
- a non-null mutability
- Default:
- NONE
-
singleton
boolean singletonSpecifies if the loader must be a singleton.- Returns:
- true if the loader is a singleton, false otherwise
- Default:
- false
-
fallback
Class<?> fallbackSpecifies the fallback class to use if no service is available.
This option is only used in conjunction withQuantifier.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,
Voidotherwise
- Default:
- java.lang.Void.class
-
wrapper
Class<?> wrapperSpecifies 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,
Voidotherwise
- Default:
- java.lang.Void.class
-
preprocessor
Class<? extends UnaryOperator<? extends Stream>> preprocessorSpecifies 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<SERVICE_TYPE>> - must be instantiable either by constructor, static method, enum field or static final field
- Returns:
- the preprocessor class if required,
ServiceDefinition.NoProcessingotherwise
- Default:
- nbbrd.service.ServiceDefinition.NoProcessing.class
- must be assignable to
-
loaderName
String loaderNameSpecifies the fully qualified name of the loader. An empty value generates an automatic name.- Returns:
- a fully qualified name
- Default:
- ""
-
backend
Specifies the class that creates a service loader.
The default backend usesServiceLoader.load(Class).Requirements:
- must be assignable to
Function<Class, ? extends Iterable> - must be instantiable either by constructor, static method, enum field or static final field
- Returns:
- the backend class if required,
ServiceDefinition.DefaultBackendotherwise
- Default:
- nbbrd.service.ServiceDefinition.DefaultBackend.class
- must be assignable to
-
cleaner
Specifies the class that deals with the cache cleaning.
The default cleaner usesServiceLoader.reload().Requirements:
- must be assignable to
Consumer<? extends Iterable> - must be instantiable either by constructor, static method, enum field or static final field
- Returns:
- the backend class if required,
ServiceDefinition.DefaultCleanerotherwise
- Default:
- nbbrd.service.ServiceDefinition.DefaultCleaner.class
- must be assignable to
-
batch
boolean batchSpecifies if batch loading should be allowed.- Returns:
- true if batch loading should be allowed, false otherwise
- Default:
- false
-
batchName
String batchNameSpecifies the fully qualified name of the batch loading. An empty value generates an automatic name.- Returns:
- a fully qualified name
- Default:
- ""
-