Enum ClassLoaderHelper

java.lang.Object
java.lang.Enum<ClassLoaderHelper>
com.amazonaws.util.ClassLoaderHelper
All Implemented Interfaces:
Serializable, Comparable<ClassLoaderHelper>, java.lang.constant.Constable

public enum ClassLoaderHelper extends Enum<ClassLoaderHelper>
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Method Summary

    Modifier and Type
    Method
    Description
    static URL
    getResource(String resource, boolean classesFirst, Class<?>... classes)
    If classesFirst is false, retrieves the resource via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
    static URL
    getResource(String resource, Class<?>... classes)
    Retrieves the resource via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
    getResourceAsStream(String resource, boolean classesFirst, Class<?>... classes)
    If classesFirst is false, retrieves the resource as an input stream via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
    getResourceAsStream(String resource, Class<?>... classes)
    Retrieves the resource as an input stream via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
    static Class<?>
    loadClass(String fqcn, boolean classesFirst, Class<?>... classes)
    If classesFirst is false, loads the class via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the caller class loader as the last resort.
    static Class<?>
    loadClass(String fqcn, Class<?>... classes)
    Loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • values

      public static ClassLoaderHelper[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ClassLoaderHelper valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getResource

      public static URL getResource(String resource, Class<?>... classes)
      Retrieves the resource via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
      Parameters:
      resource - resource to be loaded
      classes - class loader providers
      Returns:
      the resource loaded as an URL or null if not found.
    • getResource

      public static URL getResource(String resource, boolean classesFirst, Class<?>... classes)
      If classesFirst is false, retrieves the resource via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.

      If classesFirst is true, retrieves the resource via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the class loader of ClassLoaderHelper as the last resort.

      Parameters:
      resource - resource to be loaded
      classesFirst - true if the class loaders of the optionally specified classes take precedence over the context class loader of the current thread; false if the opposite is true.
      classes - class loader providers
      Returns:
      the resource loaded as an URL or null if not found.
    • loadClass

      public static Class<?> loadClass(String fqcn, Class<?>... classes) throws ClassNotFoundException
      Loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort.
      Parameters:
      fqcn - fully qualified class name of the target class to be loaded
      classes - class loader providers
      Returns:
      the class loaded; never null
      Throws:
      ClassNotFoundException - if failed to load the class
    • loadClass

      public static Class<?> loadClass(String fqcn, boolean classesFirst, Class<?>... classes) throws ClassNotFoundException
      If classesFirst is false, loads the class via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the caller class loader as the last resort.

      If classesFirst is true, loads the class via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the caller class loader as the last resort.

      Parameters:
      fqcn - fully qualified class name of the target class to be loaded
      classesFirst - true if the class loaders of the optionally specified classes take precedence over the context class loader of the current thread; false if the opposite is true.
      classes - class loader providers
      Returns:
      the class loaded; never null
      Throws:
      ClassNotFoundException - if failed to load the class
    • getResourceAsStream

      public static InputStream getResourceAsStream(String resource, Class<?>... classes)
      Retrieves the resource as an input stream via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.
      Parameters:
      resource - resource to be loaded
      classes - class loader providers
      Returns:
      the resource loaded as an input stream or null if not found.
    • getResourceAsStream

      public static InputStream getResourceAsStream(String resource, boolean classesFirst, Class<?>... classes)
      If classesFirst is false, retrieves the resource as an input stream via the context class loader of the current thread, and if not found, via the class loaders of the optionally specified classes in the order of their specification, and if not found, from the class loader of ClassLoaderHelper as the last resort.

      If classesFirst is true, retrieves the resource as an input stream via the optionally specified classes in the order of their specification, and if not found, via the context class loader of the current thread, and if not found, from the class loader of ClassLoaderHelper as the last resort.

      Parameters:
      resource - resource to be loaded
      classesFirst - true if the class loaders of the optionally specified classes take precedence over the context class loader of the current thread; false if the opposite is true.
      classes - class loader providers
      Returns:
      the resource loaded as an input stream or null if not found.