Class ClassLoaderUtils

java.lang.Object
bitronix.tm.utils.ClassLoaderUtils

public class ClassLoaderUtils extends Object
Static utility methods for loading classes and resources.
  • Constructor Details

    • ClassLoaderUtils

      public ClassLoaderUtils()
  • Method Details

    • getClassLoader

      public static ClassLoader getClassLoader()
      Get the class loader which can be used to generate proxies without leaking memory.
      Returns:
      the class loader which can be used to generate proxies without leaking memory.
    • loadClass

      public static Class loadClass(String className) throws ClassNotFoundException
      Load a class by name. Tries the current thread's context loader then falls back to Class.forName(String).
      Parameters:
      className - name of the class to load.
      Returns:
      the loaded class.
      Throws:
      ClassNotFoundException - if the class cannot be found in the classpath.
    • getResourceAsStream

      public static InputStream getResourceAsStream(String resourceName)
      Load a resource from the classpath. Tries the current thread's context loader then falls back to ClassLoader.getResourceAsStream(String) using this class' classloader.
      Parameters:
      resourceName - the resource name to load.
      Returns:
      a InputStream if the resource could be found, null otherwise.