Class ServiceFactory


  • public class ServiceFactory
    extends Object
    • Constructor Detail

      • ServiceFactory

        public ServiceFactory()
    • Method Detail

      • getImplClasses

        public static <T> List<Class<?>> getImplClasses​(Class<T> clazz)
        Acquires the list of implementation classes when multiple classes may be provided.
        Type Parameters:
        T - The interface type.
        Parameters:
        clazz - The class representing the interface for which to look for registered implementations.
        Returns:
        The list of types provided. Ordering is based on classloader behavior and should not be depended upon. (never null)
      • getSingleImpl

        public static <T> T getSingleImpl​(Class<T> clazz,
                                          ArgPair<?>... args)
        Acquires the implementation when one and only one implementation is expected. Provides an instance if the first instance encountered is instantiable. Logs warnings if there are more than 1 impls available. Returned impl type is based upon classloader behavior and may be non-deterministic.
        Type Parameters:
        T - The interface type.
        Parameters:
        clazz - The class representing the Interface for which to look for registered implementations.
        Returns:
        A instance of the impl created using the no-argument constructor.
        Throws:
        RuntimeException - when errors are encountered.