org.apache.hadoop.hbase.coprocessor
Class CoprocessorClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.apache.hadoop.hbase.coprocessor.CoprocessorClassLoader
public class CoprocessorClassLoader
- extends URLClassLoader
ClassLoader used to load Coprocessor instances.
This ClassLoader always tries to load classes from the Coprocessor jar first
before delegating to the parent ClassLoader, thus avoiding dependency
conflicts between HBase's classpath and classes in the coprocessor's jar.
Certain classes are exempt from being loaded by this ClassLoader because it
would prevent them from being cast to the equivalent classes in the region
server. For example, the Coprocessor interface needs to be loaded by the
region server's ClassLoader to prevent a ClassCastException when casting the
coprocessor implementation.
This ClassLoader also handles resource loading. In most cases this
ClassLoader will attempt to load resources from the coprocessor jar first
before delegating to the parent. However, like in class loading,
some resources need to be handled differently. For all of the Hadoop
default configurations (e.g. hbase-default.xml) we will check the parent
ClassLoader first to prevent issues such as failing the HBase default
configuration version check.
Methods inherited from class java.lang.ClassLoader |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, 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 |
CoprocessorClassLoader
public CoprocessorClassLoader(List<URL> paths,
ClassLoader parent)
- Creates a CoprocessorClassLoader that loads classes from the given paths.
- Parameters:
paths
- paths from which to load classes.parent
- the parent ClassLoader to set.
loadClass
public Class<?> loadClass(String name)
throws ClassNotFoundException
- Overrides:
loadClass
in class ClassLoader
- Throws:
ClassNotFoundException
getResource
public URL getResource(String name)
- Overrides:
getResource
in class ClassLoader
isClassExempt
protected boolean isClassExempt(String name)
- Determines whether the given class should be exempt from being loaded
by this ClassLoader.
- Parameters:
name
- the name of the class to test.
- Returns:
- true if the class should *not* be loaded by this ClassLoader;
false otherwise.
loadResourceUsingParentFirst
protected boolean loadResourceUsingParentFirst(String name)
- Determines whether we should attempt to load the given resource using the
parent first before attempting to load the resource using this ClassLoader.
- Parameters:
name
- the name of the resource to test.
- Returns:
- true if we should attempt to load the resource using the parent
first; false if we should attempt to load the resource using this
ClassLoader first.
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.