Class SingleProviderResolver


  • public class SingleProviderResolver
    extends Object
    Loads singletons of service provider implementations.
    Author:
    Jens Wilke
    • Constructor Detail

      • SingleProviderResolver

        public SingleProviderResolver()
    • Method Detail

      • resolveMandatory

        public static <T> T resolveMandatory​(Class<T> c)
        Return a provider for this interface.
        Type Parameters:
        T - type of provider interface
        Parameters:
        c - the provider interface that is implemented
        Returns:
        instance of the provider, never null
        Throws:
        LinkageError - if there is a problem instantiating the provider or no provider was specified
      • resolve

        public static <T> T resolve​(Class<T> c)
        Return a provider for this interface.
        Type Parameters:
        T - type of provider interface
        Parameters:
        c - the provider interface that is implemented
        Returns:
        instance of the provider or null if not found
        Throws:
        LinkageError - if there is a problem instantiating the provider
      • resolve

        public static <T> T resolve​(Class<T> c,
                                    Class<? extends T> defaultImpl)
        Return a provider for this interface.
        Type Parameters:
        T - type of provider interface
        Parameters:
        c - the provider interface that is implemented
        defaultImpl - if no provider is found, instantiate the default implementation
        Returns:
        instance of the provider or null if not found
        Throws:
        LinkageError - if there is a problem instantiating the provider