001/**
002 * Unit-API - Units of Measurement API for Java
003 * Copyright (c) 2014-2015 Jean-Marie Dautelle, Werner Keil, V2COM
004 * All rights reserved.
005 *
006 * See LICENSE.txt for details.
007 */
008package javax.measure.spi;
009
010import java.util.List;
011
012/**
013 * This class models the component to managing the lifecycle of the
014 * Unit and Quantity services.
015 * 
016 * @author Werner Keil
017 */
018public interface ServiceProvider {
019
020    /**
021     * This method allows to define a priority for a registered ServiceProvider instance. When multiple providers are
022     * registered in the system the provider with the highest priority value is taken.
023     *
024     * @return the provider's priority (default is 0).
025     */
026    public int getPriority();
027
028    /**
029     * Access a list of services, given its type. The bootstrap mechanism should
030     * order the instance for precedence, hereby the most significant should be
031     * first in order. If no such services are found, an empty list should be
032     * returned.
033     *
034     * @param serviceType
035     *            the service type.
036     * @return The instance to be used, never {@code null}
037     */
038    <T> List<T> getServices(Class<T> serviceType);
039
040    /**
041     * Access a single service, given its type. The bootstrap mechanism should
042     * order the instance for precedence, hereby the most significant should be
043     * first in order and returned. If no such services are found, null is
044     * returned.
045     *
046     * @param serviceType the service type.
047     * @return The instance, (with highest precedence) or {@code null}, if no such service is available.
048     */
049    <T> T getService(Class<T> serviceType);
050}