public class FilteredClassLoader extends URLClassLoader implements SmartClassLoader
URLClassLoader
that can filter the classes and resources it can load.Modifier and Type | Class and Description |
---|---|
static class |
FilteredClassLoader.ClassFilter
Filter to restrict the classes that can be loaded.
|
static class |
FilteredClassLoader.ClassPathResourceFilter
Filter to restrict the resources that can be loaded.
|
static class |
FilteredClassLoader.PackageFilter
Filter to restrict the packages that can be loaded.
|
Constructor and Description |
---|
FilteredClassLoader(Class<?>... hiddenClasses)
Create a
FilteredClassLoader that hides the given classes. |
FilteredClassLoader(ClassPathResource... hiddenResources)
Create a
FilteredClassLoader that hides resources from the given
classpath resources . |
FilteredClassLoader(Predicate<String>... filters)
Create a
FilteredClassLoader that filters based on the given predicate. |
FilteredClassLoader(String... hiddenPackages)
Create a
FilteredClassLoader that hides classes from the given packages. |
Modifier and Type | Method and Description |
---|---|
URL |
getResource(String name) |
InputStream |
getResourceAsStream(String name) |
Enumeration<URL> |
getResources(String name) |
protected Class<?> |
loadClass(String name,
boolean resolve) |
Class<?> |
publicDefineClass(String name,
byte[] b,
ProtectionDomain protectionDomain) |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
defineClass, defineClass
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOriginalClassLoader, isClassReloadable
public FilteredClassLoader(Class<?>... hiddenClasses)
FilteredClassLoader
that hides the given classes.hiddenClasses
- the classes to hidepublic FilteredClassLoader(String... hiddenPackages)
FilteredClassLoader
that hides classes from the given packages.hiddenPackages
- the packages to hidepublic FilteredClassLoader(ClassPathResource... hiddenResources)
FilteredClassLoader
that hides resources from the given
classpath resources
.hiddenResources
- the resources to hide@SafeVarargs public FilteredClassLoader(Predicate<String>... filters)
FilteredClassLoader
that filters based on the given predicate.filters
- a set of filters to determine when a class name or resource should
be hidden. A result
of true
indicates a
filtered class or resource. The input of the predicate can either be the binary
name of a class or a resource name.protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
public URL getResource(String name)
getResource
in class ClassLoader
public Enumeration<URL> getResources(String name) throws IOException
getResources
in class ClassLoader
IOException
public InputStream getResourceAsStream(String name)
getResourceAsStream
in class URLClassLoader
public Class<?> publicDefineClass(String name, byte[] b, ProtectionDomain protectionDomain)
publicDefineClass
in interface SmartClassLoader