Class BuildCompatibleExtensionLoader

java.lang.Object
org.jboss.weld.lite.extension.translator.BuildCompatibleExtensionLoader

public class BuildCompatibleExtensionLoader extends Object
A helper class used to load all implementations of BuildCompatibleExtension via service loader which also allows to specify a ClassLoader for this process.

Main use of this class is to give integrators the ability to pre-load all classes and determine if there are any such extensions. If the returned set is empty, there is no need to register LiteExtensionTranslator portable extension which may save some bootstrap time.

Author:
Matej Novotny
  • Method Details

    • getBuildCompatibleExtensions

      public static List<Class<? extends jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension>> getBuildCompatibleExtensions(ClassLoader classLoader)
      Uses service classLoader to discover all BuildCompatibleExtension implementations. The parameter is a ClassLoader that is to be used for this discovery. Returns a collection of all discovered extensions; can be empty but can never return null.
      Parameters:
      classLoader - ClassLoader with which classes will be loaded
      Returns:
      collection of build compatible extensions or an empty collection if none was found
    • getBuildCompatibleExtensions

      public static List<Class<? extends jakarta.enterprise.inject.build.compatible.spi.BuildCompatibleExtension>> getBuildCompatibleExtensions()
      Uses service loader to discover all BuildCompatibleExtension implementations. Returns a collection of all discovered extensions; can be empty but can never return null. This method variant uses Thread.currentThread().getContextClassLoader() as the CL with which it attempts to load all services.
      Returns:
      collection of build compatible extensions or an empty collection if none was found
    • clearDiscoveredExtensions

      public static void clearDiscoveredExtensions()
      Clears out all discovered extensions. This is automatically performed from within LiteExtensionTranslator once an instance of it is created.

      This is necessary because of testing environment where multiple deployments happen on the same running JVM and the static list could be therefore retained in between deployments.