org.apache.hadoop.hbase.util
Class DynamicClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.apache.hadoop.hbase.util.DynamicClassLoader

@InterfaceAudience.Private
public class DynamicClassLoader
extends URLClassLoader

This is a class loader that can load classes dynamically from new jar files under a configured folder. It always uses its parent class loader to load a class at first. Only if its parent class loader can not load a class, we will try to load it using the logic here.

We can't unload a class already loaded. So we will use the existing jar files we already know to load any class which can't be loaded using the parent class loader. If we still can't load the class from the existing jar files, we will check if any new jar file is added, if so, we will load the new jar file and try to load the class again. If still failed, a class not found exception will be thrown.

Be careful in uploading new jar files and make sure all classes are consistent, otherwise, we may not be able to load your classes properly.


Constructor Summary
DynamicClassLoader(org.apache.hadoop.conf.Configuration conf, ClassLoader parent)
          Creates a DynamicClassLoader that can load classes dynamically from jar files under a specific folder.
 
Method Summary
 Class<?> loadClass(String name)
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicClassLoader

public DynamicClassLoader(org.apache.hadoop.conf.Configuration conf,
                          ClassLoader parent)
Creates a DynamicClassLoader that can load classes dynamically from jar files under a specific folder.

Parameters:
conf - the configuration for the cluster.
parent - the parent ClassLoader to set.
Method Detail

loadClass

public Class<?> loadClass(String name)
                   throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.