org.sonatype.aether.impl.internal
Class DefaultServiceLocator

java.lang.Object
  extended by org.sonatype.aether.impl.internal.DefaultServiceLocator
All Implemented Interfaces:
ServiceLocator

public class DefaultServiceLocator
extends Object
implements ServiceLocator

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, a version resolver, a version range resolver and some repository connectors.

Author:
Benjamin Bentmann

Constructor Summary
DefaultServiceLocator()
          Creates a new service locator that already knows about all service implementations included this library.
 
Method Summary
<T> DefaultServiceLocator
addService(Class<T> type, Class<? extends T> impl)
          Adds the implementation class for a service.
<T> T
getService(Class<T> type)
          Gets an instance of the specified service.
<T> List<T>
getServices(Class<T> type)
          Gets all available instances of the specified service.
protected  void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception)
           
<T> DefaultServiceLocator
setService(Class<T> type, Class<? extends T> impl)
          Sets the implementation class for a service.
<T> DefaultServiceLocator
setServices(Class<T> type, T... services)
          Sets the instances for a service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceLocator

public DefaultServiceLocator()
Creates a new service locator that already knows about all service implementations included this library.

Method Detail

setService

public <T> DefaultServiceLocator setService(Class<T> type,
                                            Class<? extends T> impl)
Sets the implementation class for a service.

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)
Adds the implementation class for a service.

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)
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, must not be null.
Returns:
This locator for chaining, never null.

getService

public <T> T getService(Class<T> type)
Description copied from interface: ServiceLocator
Gets an instance of the specified service.

Specified by:
getService in interface ServiceLocator
Type Parameters:
T - The service type.
Parameters:
type - The interface describing the service, must not be null.
Returns:
The service instance or null if the service could not be located/initialized.

getServices

public <T> List<T> getServices(Class<T> type)
Description copied from interface: ServiceLocator
Gets all available instances of the specified service.

Specified by:
getServices in interface ServiceLocator
Type Parameters:
T - The service type.
Parameters:
type - The interface describing the service, must not be null.
Returns:
The (read-only) list of available service instances, never null.

serviceCreationFailed

protected void serviceCreationFailed(Class<?> type,
                                     Class<?> impl,
                                     Throwable exception)


Copyright © 2010-2012. All Rights Reserved.