Class ServiceLoaderUtil

java.lang.Object
ch.kk7.confij.common.ServiceLoaderUtil

public class ServiceLoaderUtil
extends java.lang.Object
  • Constructor Summary

    Constructors
    Constructor Description
    ServiceLoaderUtil()  
  • Method Summary

    Modifier and Type Method Description
    <T> java.util.List<T> instancesOf​(java.lang.Class<T> serviceClass)
    Loads and caches all instances of a given class using a ServiceLoader and sorts them by ServiceLoaderPriority first and by class name otherwise.
    <T> java.util.List<T> maybeNewOf​(java.lang.Class<T> serviceClass)  
    <T> java.util.List<T> requireInstancesOf​(java.lang.Class<T> serviceClass)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServiceLoaderUtil

      public ServiceLoaderUtil()
  • Method Details

    • requireInstancesOf

      public <T> java.util.List<T> requireInstancesOf​(java.lang.Class<T> serviceClass)
    • instancesOf

      public <T> java.util.List<T> instancesOf​(java.lang.Class<T> serviceClass)
      Loads and caches all instances of a given class using a ServiceLoader and sorts them by ServiceLoaderPriority first and by class name otherwise.
      Returns:
      list of initialized singletons of given type in deterministic order
    • maybeNewOf

      public <T> java.util.List<T> maybeNewOf​(java.lang.Class<T> serviceClass)