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 Type
    Method
    Description
    static <S> boolean
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 class
      ensureSingle - Ensure that only one implementation exists. If set and multiple implementations found then a ServiceConfigurationError is thrown.
      Returns:
      One instantiated implementation for the given interface
      Throws:
      ServiceConfigurationError - When something goes wrong (in the underlying ServiceLoader, incase no implementation found, or ensureSingle is true and multiple implementations found
    • isServiceAvailable

      public static <S> boolean isServiceAvailable(Class<S> service) throws ServiceConfigurationError
      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 underlying ServiceLoader.