com.amazonaws.util
Enum ClassLoaderHelper

java.lang.Object
  extended by java.lang.Enum<ClassLoaderHelper>
      extended by com.amazonaws.util.ClassLoaderHelper
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ClassLoaderHelper>

public enum ClassLoaderHelper
extends java.lang.Enum<ClassLoaderHelper>


Method Summary
static java.net.URL getResource(java.lang.String resource, boolean classesFirst, java.lang.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 java.net.URL getResource(java.lang.String resource, java.lang.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.
static java.io.InputStream getResourceAsStream(java.lang.String resource, boolean classesFirst, java.lang.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.
static java.io.InputStream getResourceAsStream(java.lang.String resource, java.lang.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 java.lang.Class<?> loadClass(java.lang.String fqcn, boolean classesFirst, java.lang.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 java.lang.Class<?> loadClass(java.lang.String fqcn, java.lang.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.
static ClassLoaderHelper valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ClassLoaderHelper[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

values

public static ClassLoaderHelper[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (ClassLoaderHelper c : ClassLoaderHelper.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ClassLoaderHelper valueOf(java.lang.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:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

getResource

public static java.net.URL getResource(java.lang.String resource,
                                       java.lang.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 java.net.URL getResource(java.lang.String resource,
                                       boolean classesFirst,
                                       java.lang.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 java.lang.Class<?> loadClass(java.lang.String fqcn,
                                           java.lang.Class<?>... classes)
                                    throws java.lang.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:
java.lang.ClassNotFoundException - if failed to load the class

loadClass

public static java.lang.Class<?> loadClass(java.lang.String fqcn,
                                           boolean classesFirst,
                                           java.lang.Class<?>... classes)
                                    throws java.lang.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:
java.lang.ClassNotFoundException - if failed to load the class

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resource,
                                                      java.lang.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 java.io.InputStream getResourceAsStream(java.lang.String resource,
                                                      boolean classesFirst,
                                                      java.lang.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.


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.