Class JasperLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class JasperLoader
    extends java.net.URLClassLoader
    Class loader for loading servlet class files (corresponding to JSP files) and tag handler class files (corresponding to tag files).
    Author:
    Anil K. Vijendran, Harish Prabandham
    • Constructor Summary

      Constructors 
      Constructor Description
      JasperLoader​(java.net.URL[] urls, java.lang.ClassLoader parent, java.lang.String packageName, java.security.PermissionCollection permissionCollection)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.security.PermissionCollection getPermissions​(java.security.CodeSource codeSource)
      Get the Permissions for a CodeSource.
      java.io.InputStream getResourceAsStream​(java.lang.String name)
      Delegate to parent
      java.lang.Class<?> loadClass​(java.lang.String name)
      Load the class with the specified name.
      java.lang.Class<?> loadClass​(java.lang.String name, boolean resolve)
      Load the class with the specified name, searching using the following algorithm until it finds and returns the class.
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, findResources, 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, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JasperLoader

        public JasperLoader​(java.net.URL[] urls,
                            java.lang.ClassLoader parent,
                            java.lang.String packageName,
                            java.security.PermissionCollection permissionCollection)
    • Method Detail

      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Load the class with the specified name. This method searches for classes in the same manner as loadClass(String, boolean) with false as the second argument.
        Overrides:
        loadClass in class java.lang.ClassLoader
        Parameters:
        name - Name of the class to be loaded
        Throws:
        java.lang.ClassNotFoundException - if the class was not found
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name,
                                            boolean resolve)
                                     throws java.lang.ClassNotFoundException
        Load the class with the specified name, searching using the following algorithm until it finds and returns the class. If the class cannot be found, returns ClassNotFoundException.
        • Call findLoadedClass(String) to check if the class has already been loaded. If it has, the same Class object is returned.
        • If the delegate property is set to true, call the loadClass() method of the parent class loader, if any.
        • Call findClass() to find this class in our locally defined repositories.
        • Call the loadClass() method of our parent class loader, if any.
        If the class was found using the above steps, and the resolve flag is true, this method will then call resolveClass(Class) on the resulting Class object.
        Overrides:
        loadClass in class java.lang.ClassLoader
        Parameters:
        name - Name of the class to be loaded
        resolve - If true then resolve the class
        Throws:
        java.lang.ClassNotFoundException - if the class was not found
      • getResourceAsStream

        public java.io.InputStream getResourceAsStream​(java.lang.String name)
        Delegate to parent
        Overrides:
        getResourceAsStream in class java.net.URLClassLoader
        See Also:
        ClassLoader.getResourceAsStream(java.lang.String)
      • getPermissions

        public final java.security.PermissionCollection getPermissions​(java.security.CodeSource codeSource)
        Get the Permissions for a CodeSource. Since this ClassLoader is only used for a JSP page in a web application context, we just return our preset PermissionCollection for the web app context.
        Overrides:
        getPermissions in class java.net.URLClassLoader
        Parameters:
        codeSource - Code source where the code was loaded from
        Returns:
        PermissionCollection for CodeSource