Class DefaultServiceLocator

java.lang.Object
org.eclipse.aether.impl.DefaultServiceLocator
All Implemented Interfaces:
org.eclipse.aether.spi.locator.ServiceLocator

@Deprecated public final class DefaultServiceLocator extends Object implements org.eclipse.aether.spi.locator.ServiceLocator
Deprecated.
Use of out-of-the-box DI implementation recommended, or, as alternative new supplier from module maven-resolver-supplier.
A simple service locator that is already setup with all components from this library. To acquire a complete repository system, clients need to add an artifact descriptor reader, a version resolver, a version range resolver and optionally some repository connector and transporter factories to access remote repositories. Once the locator is fully populated, the repository system can be created like this:
 RepositorySystem repoSystem = serviceLocator.getService( RepositorySystem.class );
 
Note: This class is not thread-safe. Clients are expected to create the service locator and the repository system on a single thread.
  • Constructor Details

    • DefaultServiceLocator

      Deprecated.
      Creates a new service locator that already knows about all service implementations included this library.
  • Method Details

    • setService

      public <T> DefaultServiceLocator setService(Class<T> type, Class<? extends T> impl)
      Deprecated.
      Sets the implementation class for a service. The specified class must have a no-arg constructor (of any visibility). If the service implementation itself requires other services for its operation, it should implement Service to gain access to this service locator.
      Type Parameters:
      T - The service type.
      Parameters:
      type - The interface describing the service, must not be null.
      impl - The implementation class of the service, must not be null.
      Returns:
      This locator for chaining, never null.
    • addService

      public <T> DefaultServiceLocator addService(Class<T> type, Class<? extends T> impl)
      Deprecated.
      Adds an implementation class for a service. The specified class must have a no-arg constructor (of any visibility). If the service implementation itself requires other services for its operation, it should implement Service to gain access to this service locator.
      Type Parameters:
      T - The service type.
      Parameters:
      type - The interface describing the service, must not be null.
      impl - The implementation class of the service, must not be null.
      Returns:
      This locator for chaining, never null.
    • setServices

      public <T> DefaultServiceLocator setServices(Class<T> type, T... services)
      Deprecated.
      Sets the instances for a service.
      Type Parameters:
      T - The service type.
      Parameters:
      type - The interface describing the service, must not be null.
      services - The instances of the service, may be null but must not contain null elements.
      Returns:
      This locator for chaining, never null.
    • getService

      public <T> T getService(Class<T> type)
      Deprecated.
      Specified by:
      getService in interface org.eclipse.aether.spi.locator.ServiceLocator
    • getServices

      public <T> List<T> getServices(Class<T> type)
      Deprecated.
      Specified by:
      getServices in interface org.eclipse.aether.spi.locator.ServiceLocator
    • setErrorHandler

      Deprecated.
      Sets the error handler to use.
      Parameters:
      errorHandler - The error handler to use, may be null to ignore/swallow errors.