Entry point to services in Helidon.
The service registry has knowledge about all the services within your application.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescription<T> List
<T> Get all service instances matching the contract with the expectation that there may not be a match available.default <T> List
<T> Get all service instances matching the contract with the expectation that there may not be a match available.allServices
(TypeName contract) Get all services for a specific contract.default List
<ServiceInfo> allServices
(Class<?> contract) Get all services for a specific contract.<T> Optional
<T> Get the first service instance matching the contract with the expectation that there may not be a match available.default <T> Optional
<T> Get the first service instance matching the contract with the expectation that there may not be a match available.<T> T
Get the first service instance matching the contract with the expectation that there is a match available.<T> Optional
<T> get
(ServiceInfo serviceInfo) Provide a value for a specific service info instance.default <T> T
Get the first service instance matching the contract with the expectation that there is a match available.<T> Supplier
<T> Get the first service supplier matching the contract with the expectation that there is a match available.default <T> Supplier
<T> Get the first service supplier matching the contract with the expectation that there is a match available.Lookup a supplier of a list of instances of the requested contract, with the expectation that there may not be a match available.Lookup a supplier of a list of instances of the requested contract, with the expectation that there may not be a match available.supplyFirst
(TypeName contract) Get the first service supplier matching the contract with the expectation that there may not be a match available.supplyFirst
(Class<T> contract) Get the first service supplier matching the contract with the expectation that there may not be a match available.
-
Field Details
-
TYPE
Type name of this interface.
-
-
Method Details
-
get
Get the first service instance matching the contract with the expectation that there is a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to look-up- Returns:
- the best service instance matching the contract
- Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup, or the resolution to instance failed
-
get
Get the first service instance matching the contract with the expectation that there is a match available.- Type Parameters:
T
- type of the contract (we will "blindly" cast the result to the expected type, make sure you use the right one)- Parameters:
contract
- contract to look-up- Returns:
- the best service instance matching the contract
- Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup, or the resolution to instance failed
-
first
Get the first service instance matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to look-up- Returns:
- the best service instance matching the contract, or an empty
Optional
if none match - Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup, or the resolution to instance failed
-
first
Get the first service instance matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to look-up- Returns:
- the best service instance matching the contract, or an empty
Optional
if none match - Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup, or the resolution to instance failed
-
all
Get all service instances matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to look-up- Returns:
- list of services matching the criteria, may be empty if none matched, or no instances were provided
-
all
Get all service instances matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to look-up- Returns:
- list of services matching the criteria, may be empty if none matched, or no instances were provided
-
supply
Get the first service supplier matching the contract with the expectation that there is a match available. The providedSupplier.get()
may throw anServiceRegistryException
in case the matching service cannot provide a value (either because of scope mismatch, or because an instance was not provided by the service provider.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to find- Returns:
- the best service supplier matching the lookup
- Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup
-
supply
Get the first service supplier matching the contract with the expectation that there is a match available. The providedSupplier.get()
may throw anServiceRegistryException
in case the matching service cannot provide a value (either because of scope mismatch, or because an instance was not provided by the service provider.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract to find- Returns:
- the best service supplier matching the lookup
- Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup
-
supplyFirst
Get the first service supplier matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract we look for- Returns:
- supplier of an optional instance
-
supplyFirst
Get the first service supplier matching the contract with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract we look for- Returns:
- supplier of an optional instance
-
supplyAll
Lookup a supplier of a list of instances of the requested contract, with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract we look for- Returns:
- a supplier of list of instances
-
supplyAll
Lookup a supplier of a list of instances of the requested contract, with the expectation that there may not be a match available.- Type Parameters:
T
- type of the contract- Parameters:
contract
- contract we look for- Returns:
- a supplier of list of instances
-
get
Provide a value for a specific service info instance. This method uses instance equality for service info, so be careful to use the singleton instance from the service descriptor, or instances provided byallServices(Class)
.- Type Parameters:
T
- type of the expected instance, we just cast to it, so this may cause runtime issues if assigned to invalid type- Parameters:
serviceInfo
- service info instance- Returns:
- value of the service described by the service info provided (always a single value), as there is support
for providers that are
Supplier
of an instance, and that may returnOptional
, we may not get a value, hence we returnOptional
as well
-
allServices
Get all services for a specific contract. The list may be empty if there are no services available. To get an instance, useget(ServiceInfo)
.- Parameters:
contract
- contract we look for- Returns:
- list of service metadata of services that satisfy the provided contract
-
allServices
Get all services for a specific contract. The list may be empty if there are no services available. To get an instance, useget(ServiceInfo)
.- Parameters:
contract
- contract we look for- Returns:
- list of service metadata of services that satisfy the provided contract
-