org.quartz.simpl
Class CascadingClassLoadHelper

java.lang.Object
  extended by org.quartz.simpl.CascadingClassLoadHelper
All Implemented Interfaces:
ClassLoadHelper

public class CascadingClassLoadHelper
extends Object
implements ClassLoadHelper

A ClassLoadHelper uses all of the ClassLoadHelper types that are found in this package in its attempts to load a class, when one scheme is found to work, it is promoted to the scheme that will be used first the next time a class is loaded (in order to improve performance).

This approach is used because of the wide variance in class loader behavior between the various environments in which Quartz runs (e.g. disparate application servers, stand-alone, mobile devices, etc.). Because of this disparity, Quartz ran into difficulty with a one class-load style fits-all design. Thus, this class loader finds the approach that works, then 'remembers' it.

Author:
jhouse, pl47ypus
See Also:
ClassLoadHelper, LoadingLoaderClassLoadHelper, SimpleClassLoadHelper, ThreadContextClassLoadHelper, InitThreadContextClassLoadHelper

Constructor Summary
CascadingClassLoadHelper()
           
 
Method Summary
 ClassLoader getClassLoader()
          Enable sharing of the "best" class-loader with 3rd party.
 URL getResource(String name)
          Finds a resource with a given name.
 InputStream getResourceAsStream(String name)
          Finds a resource with a given name.
 void initialize()
          Called to give the ClassLoadHelper a chance to initialize itself, including the opportunity to "steal" the class loader off of the calling thread, which is the thread that is initializing Quartz.
 Class<?> loadClass(String name)
          Return the class with the given name.
<T> Class<? extends T>
loadClass(String name, Class<T> clazz)
          Return the class of the given type with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CascadingClassLoadHelper

public CascadingClassLoadHelper()
Method Detail

initialize

public void initialize()
Called to give the ClassLoadHelper a chance to initialize itself, including the opportunity to "steal" the class loader off of the calling thread, which is the thread that is initializing Quartz.

Specified by:
initialize in interface ClassLoadHelper

loadClass

public Class<?> loadClass(String name)
                   throws ClassNotFoundException
Return the class with the given name.

Specified by:
loadClass in interface ClassLoadHelper
Parameters:
name - the fqcn of the class to load.
Returns:
the requested class.
Throws:
ClassNotFoundException - if the class can be found in the classpath.

loadClass

public <T> Class<? extends T> loadClass(String name,
                                        Class<T> clazz)
                             throws ClassNotFoundException
Description copied from interface: ClassLoadHelper
Return the class of the given type with the given name.

Specified by:
loadClass in interface ClassLoadHelper
Parameters:
name - the fqcn of the class to load.
Returns:
the requested class.
Throws:
ClassNotFoundException - if the class can be found in the classpath.

getResource

public URL getResource(String name)
Finds a resource with a given name. This method returns null if no resource with this name is found.

Specified by:
getResource in interface ClassLoadHelper
Parameters:
name - name of the desired resource
Returns:
a java.net.URL object

getResourceAsStream

public InputStream getResourceAsStream(String name)
Finds a resource with a given name. This method returns null if no resource with this name is found.

Specified by:
getResourceAsStream in interface ClassLoadHelper
Parameters:
name - name of the desired resource
Returns:
a java.io.InputStream object

getClassLoader

public ClassLoader getClassLoader()
Enable sharing of the "best" class-loader with 3rd party.

Specified by:
getClassLoader in interface ClassLoadHelper
Returns:
the class-loader user be the helper.


Copyright 2001-2019, Terracotta, Inc.