public class ReloadingClassLoader extends URLClassLoader
Constructor and Description |
---|
ReloadingClassLoader(ClassLoader parent)
Create a new reloading ClassLoader from a list of URLs, and initialize the
ModificationWatcher to detect class file modifications
|
Modifier and Type | Method and Description |
---|---|
static void |
addLocation(URL url)
Add the location of a directory containing class files
|
void |
destroy()
Remove the ModificationWatcher from the current reloading class loader
|
static void |
excludePattern(String pattern)
Exclude a pattern
|
static Set<URL> |
getLocations()
Returns the list of all configured locations of directories containing class files
|
static List<String> |
getPatterns()
Returns the list of all configured inclusion or exclusion patterns
|
URL |
getResource(String name)
Gets a resource from this
ClassLoader. |
static void |
includePattern(String pattern)
Include a pattern
|
Class<?> |
loadClass(String name,
boolean resolve)
Loads the class from this
ClassLoader. |
void |
setListener(IChangeListener<Class<?>> listener)
Sets the listener that will be notified when a class changes
|
protected boolean |
tryClassHere(String name) |
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
defineClass, defineClass
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public ReloadingClassLoader(ClassLoader parent)
parent
- the parent classloader in case the class file cannot be loaded from the above
locationsprotected boolean tryClassHere(String name)
name
- public static void includePattern(String pattern)
pattern
- the pattern to includepublic static void excludePattern(String pattern)
pattern
- the pattern to excludepublic static List<String> getPatterns()
public static void addLocation(URL url)
url
- the URL for the directorypublic static Set<URL> getLocations()
public final URL getResource(String name)
ClassLoader. If the
resource does not exist in this one, we check the parent.
Please note that this is the exact opposite of the
ClassLoader
spec. We use it to work around inconsistent class loaders from third
party vendors.
getResource
in class ClassLoader
name
- of resourcepublic final Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
ClassLoader. If the
class does not exist in this one, we check the parent. Please
note that this is the exact opposite of the
ClassLoader
spec. We use it to load the class from the same classloader as
WicketFilter or WicketServlet. When found, the class file is watched for modifications.
loadClass
in class ClassLoader
name
- the name of the classresolve
- if true
then resolve the classClass
objectClassNotFoundException
- if the class could not be foundpublic void setListener(IChangeListener<Class<?>> listener)
listener
- the listener to notify upon class changepublic void destroy()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.