Package com.chemaxon.apidiscovery.util
Class ServiceUtil
java.lang.Object
com.chemaxon.apidiscovery.util.ServiceUtil
@Beta
@PublicAPI
@Deprecated(forRemoval=true)
@SubjectToRemoval(date=JAN_01_2025)
public final class ServiceUtil
extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
The API discovery tool will be removed.
Utility class to ease service location.
Please note that in the future different DI solutions might be used instead of ServiceLoader.
Please note that this class is annotated with the Beta
annotation, so
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S> boolean
isServiceAvailable
(Class<S> service) Deprecated, for removal: This API element is subject to removal in a future version.Check if a specific service is defined and implementation can be loaded.static <S> S
loadService
(Class<S> service, boolean ensureSingle) Deprecated, for removal: This API element is subject to removal in a future version.Load and instantiate an implementation for a given service interface.
-
Method Details
-
loadService
public static <S> S loadService(Class<S> service, boolean ensureSingle) throws ServiceConfigurationError Deprecated, for removal: This API element is subject to removal in a future version.Load and instantiate an implementation for a given service interface.- Type Parameters:
S
- Interface type to instantiate- Parameters:
service
- Service interface classensureSingle
- Ensure that only one implementation exists. If set and multiple implementations found then aServiceConfigurationError
is thrown.- Returns:
- One instantiated implementation for the given interface
- Throws:
ServiceConfigurationError
- When something goes wrong (in the underlyingServiceLoader
, incase no implementation found, orensureSingle
is true and multiple implementations found
-
isServiceAvailable
Deprecated, for removal: This API element is subject to removal in a future version.Check if a specific service is defined and implementation can be loaded.Note that there is no guarantee regarding the successfull instantiation of the service.
- Type Parameters:
S
- Interface type- Parameters:
service
- Service interface class- Returns:
- true when at least one implementation of the given service is available
- Throws:
ServiceConfigurationError
- can be thrown by the underlyingServiceLoader
.
-