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.booleanDeprecated.Deprecated.usebatchType()insteadClass<?>Specifies the batch class to use in 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.
An empty value generates an automatic name.Specifies the mutability of the loader.booleanDeprecated.UseSINGLE_FALLBACK_NOT_EXPECTEDinsteadClass<? 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. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName to suppress single-fallback warning using @SuppressWarnings
-
Field Details
-
SINGLE_FALLBACK_NOT_EXPECTED
Name to suppress single-fallback warning using @SuppressWarnings- See Also:
-
-
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
-
noFallback
Deprecated.UseSINGLE_FALLBACK_NOT_EXPECTEDinsteadSpecifies if fallback class is unexpected.- Returns:
- true if fallback class is expected, false otherwise
- Default:
- false
-
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. 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:
- ""
-
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
Deprecated.usebatchType()insteadSpecifies if batch loading should be allowed.- Returns:
- true if batch loading should be allowed, false otherwise
- Default:
- false
-
batchName
Deprecated.usebatchType()insteadSpecifies the fully qualified name of the batch loading. 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:
- ""
-
batchType
Class<?> batchTypeSpecifies the batch class to use in batch loading.Requirements:
- Batch type must be an interface or an abstract class
- Batch method must be unique
- Returns:
- the batch class if required,
Voidotherwise
- Default:
- java.lang.Void.class
-
batchType()instead