Class FactoryFinder


  • class FactoryFinder
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      FactoryFinder()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <T> T find​(java.lang.Class<T> factoryClass, java.lang.String defaultClassName, boolean tryFallback)
      Finds the implementation Class object for the given factory type.
      private static java.lang.String fromSystemProperty​(java.lang.String factoryId)  
      private static java.lang.String getSystemProperty​(java.lang.String property)  
      private static boolean isOsgi()  
      private static void logFound​(java.lang.String value)  
      private static <T> T lookupUsingOSGiServiceLoader​(java.lang.String factoryId)  
      private static <T> T newInstance​(java.lang.String className, java.lang.String defaultClassName, java.lang.ClassLoader tccl)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • OSGI_SERVICE_LOADER_CLASS_NAME

        private static final java.lang.String OSGI_SERVICE_LOADER_CLASS_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • FactoryFinder

        FactoryFinder()
    • Method Detail

      • find

        static <T> T find​(java.lang.Class<T> factoryClass,
                          java.lang.String defaultClassName,
                          boolean tryFallback)
                   throws java.lang.RuntimeException
        Finds the implementation Class object for the given factory type. If it fails and tryFallback is true finds the Class object for the given default class name. The arguments supplied must be used in order Note the default class name may be needed even if fallback is not to be attempted in order to check if requested type is fallback.

        This method is package private so that this code can be shared.

        Parameters:
        factoryClass - factory abstract class or interface to be found
        defaultClassName - the implementation class name, which is to be used only if nothing else is found; null to indicate that there is no default class name
        tryFallback - whether to try the default class as a fallback
        Returns:
        the Class object of the specified message factory; may not be null
        Throws:
        java.lang.RuntimeException - if there is no factory found
      • newInstance

        private static <T> T newInstance​(java.lang.String className,
                                         java.lang.String defaultClassName,
                                         java.lang.ClassLoader tccl)
                                  throws java.lang.RuntimeException
        Throws:
        java.lang.RuntimeException
      • fromSystemProperty

        private static java.lang.String fromSystemProperty​(java.lang.String factoryId)
      • getSystemProperty

        private static java.lang.String getSystemProperty​(java.lang.String property)
      • logFound

        private static void logFound​(java.lang.String value)
      • isOsgi

        private static boolean isOsgi()
      • lookupUsingOSGiServiceLoader

        private static <T> T lookupUsingOSGiServiceLoader​(java.lang.String factoryId)