- All Superinterfaces:
AutoCloseable
A simple service locator for initialization purposes and external services provided by
plugins. If there is no suitable
name for the service use
"default". -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringServices that do not have multiple options or need a default should use "default". -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<T> List<T> Finds all services of a specific type.default <T> @Nullable TfindOrNull(Class<T> type) Finds a service with the default name of "default" or null.<T> @Nullable TfindOrNull(Class<T> type, String name) Finds a service or null.static ServiceRegistryof()Creates an empty service registry.voidonClose(AutoCloseable closeable) Add a closeable to close on close in LIFO order.<T> voidPuts a service.default <T> voidPuts a service.<T> TputIfAbsent(Class<T> type, String name, Supplier<T> supplier) Puts a service if absent.default <T> TputIfAbsent(Class<T> type, Supplier<T> supplier) Puts a service if absent.
-
Field Details
-
DEFAULT_SERVICE_NAME
Services that do not have multiple options or need a default should use "default".- See Also:
-
-
Method Details
-
of
Creates an empty service registry.- Returns:
- registry.
-
put
Puts a service.- Type Parameters:
T- service type.- Parameters:
type- type.name- name of service.service- service instance.
-
put
Puts a service.- Type Parameters:
T- service type.- Parameters:
type- type.service- service instance.
-
putIfAbsent
Puts a service if absent.- Type Parameters:
T- service type.- Parameters:
type- type.name- name of the service.supplier- service instance.- Returns:
- service.
-
putIfAbsent
Puts a service if absent.- Type Parameters:
T- service type.- Parameters:
type- type.supplier- service instance.- Returns:
- service.
-
findOrNull
Finds a service or null.- Type Parameters:
T- service type- Parameters:
type- service class.name- name of service.- Returns:
- service or
null.
-
findOrNull
Finds a service with the default name of "default" or null.- Type Parameters:
T- service type- Parameters:
type- service class.- Returns:
- service or
null.
-
find
Finds all services of a specific type.- Type Parameters:
T- service type.- Parameters:
type- service class.- Returns:
- list of services.
-
onClose
Add a closeable to close on close in LIFO order.- Parameters:
closeable- closeable.
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-