Entry point to services in Helidon.
The service registry has knowledge about all the services within your application.
-
Field Summary
Fields -
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.<T> List
<T> Get all service instances matching the lookup 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.<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> T
Get the first service instance matching the lookup 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> List
<ServiceInstance<T>> lookupInstances
(Lookup lookup) A lookup method that provides a list of qualified instances, rather than just a service instance.lookupServices
(Lookup lookup) A lookup method operating on the service descriptors, rather than service instances.metrics()
Provides registry metrics information.<T> Supplier
<T> Get the first service supplier matching the contract with the expectation that there is a match available.<T> Supplier
<T> Get the first service supplier matching the lookup 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 all services matching the lookup 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
(Lookup lookup) Find the first service matching the lookup 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
-
get
Get the first service instance matching the lookup with the expectation that there is a match available.- Type Parameters:
T
- type of the service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- the best service instance matching the lookup, cast to the expected type; please use a
Object
as the type if the result may contain an unknown instance - 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 service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- the best service instance matching the lookup, cast to the expected type; please use a
Object
as the type if the result may contain an unknown instance
-
all
Get all service instances matching the lookup with the expectation that there may not be a match available.- Type Parameters:
T
- type of the service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- 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 lookup 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 there is no available instance, and we use a runtime resolution throughService.ServicesFactory
,Service.InjectionPointFactory
, or similar).- Type Parameters:
T
- type of the service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- the best service supplier matching the lookup, cast to the expected type; please use a
Object
as the type if the result may contain an unknown instance - Throws:
ServiceRegistryException
- if there is no service that could satisfy the lookup
-
supplyFirst
Find the first service matching the lookup with the expectation that there may not be a match available.- Type Parameters:
T
- type of the service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- the best service matching the lookup, cast to the expected type; please use a
Object
as the type if the result may contain an unknown instance
-
supplyAll
Lookup a supplier of all services matching the lookup with the expectation that there may not be a match available.- Type Parameters:
T
- type of the service, if you use any other thanObject
, make sure you have configured appropriate contracts in the lookup, as we cannot infer this- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- supplier of list of services ordered, may be empty if there is no match
-
lookupServices
A lookup method operating on the service descriptors, rather than service instances. This is useful for tools that need to analyze the structure of the registry, for testing etc.The registry is optimized for look-ups based on service type and service contracts, all other lookups trigger a full registry scan.
- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- a list of service descriptors that match the lookup criteria
-
lookupInstances
A lookup method that provides a list of qualified instances, rather than just a service instance. This is to align with the possible injection points in services.The registry is optimized for look-ups based on service type and service contracts, all other lookups trigger a full registry scan.
- Type Parameters:
T
- type of the expected result, useObject
for results with more than one contract- Parameters:
lookup
- lookup criteria to find matching services- Returns:
- a list of qualified service instances that match the lookup criteria
-
metrics
RegistryMetrics metrics()Provides registry metrics information.- Returns:
- registry metrics
-