Class ReloadingClassLoader

    • Constructor Detail

      • ReloadingClassLoader

        public ReloadingClassLoader​(ClassLoader parent)
        Create a new reloading ClassLoader from a list of URLs, and initialize the ModificationWatcher to detect class file modifications
        Parameters:
        parent - the parent classloader in case the class file cannot be loaded from the above locations
    • Method Detail

      • tryClassHere

        protected boolean tryClassHere​(String name)
        Parameters:
        name -
        Returns:
        true if class if found, false otherwise
      • includePattern

        public static void includePattern​(String pattern)
        Include a pattern
        Parameters:
        pattern - the pattern to include
      • excludePattern

        public static void excludePattern​(String pattern)
        Exclude a pattern
        Parameters:
        pattern - the pattern to exclude
      • getPatterns

        public static List<StringgetPatterns()
        Returns the list of all configured inclusion or exclusion patterns
        Returns:
        list of patterns as String
      • addLocation

        public static void addLocation​(URL url)
        Add the location of a directory containing class files
        Parameters:
        url - the URL for the directory
      • getLocations

        public static Set<URLgetLocations()
        Returns the list of all configured locations of directories containing class files
        Returns:
        list of locations as URL
      • getResource

        public final URL getResource​(String name)
        Gets a resource from this 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.
        Overrides:
        getResource in class ClassLoader
        Parameters:
        name - of resource
      • loadClass

        public final Class<?> loadClass​(String name,
                                        boolean resolve)
                                 throws ClassNotFoundException
        Loads the class from this 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.
        Overrides:
        loadClass in class ClassLoader
        Parameters:
        name - the name of the class
        resolve - if true then resolve the class
        Returns:
        the resulting Class object
        Throws:
        ClassNotFoundException - if the class could not be found
      • setListener

        public void setListener​(IChangeListener<Class<?>> listener)
        Sets the listener that will be notified when a class changes
        Parameters:
        listener - the listener to notify upon class change
      • destroy

        public void destroy()
        Remove the ModificationWatcher from the current reloading class loader