Class UberJarRealmClassLoader

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

    public class UberJarRealmClassLoader
    extends RealmClassLoader
    Classloader for ClassRealms.

    Loads classes from an "uberjar".

    Version:
    $Id: UberJarRealmClassLoader.java 126 2006-01-12 04:17:51Z $
    Author:
    bob mcwhirter
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map classIndex  
      private java.util.Map jarIndexes  
      private java.util.List urls  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addConstituent​(java.net.URL constituent)
      Add a constituent to this realm for locating classes.
      private void buildIndexForJar​(java.net.URL inUrl)  
      protected byte[] findClassInDirectoryUrl​(java.net.URL url, java.lang.String path)  
      protected byte[] findClassInJarStream​(java.net.URL inUrl, java.lang.String path)  
      java.net.URL findResource​(java.lang.String name)
      Find a resource within this ClassLoader only (don't delegate to the parent).
      protected java.net.URL findResourceInDirectoryUrl​(java.net.URL inUrl, java.lang.String path)  
      protected java.net.URL findResourceInJarStream​(java.net.URL inUrl, java.lang.String path)  
      java.util.Enumeration findResourcesDirect​(java.lang.String name)
      Find resources from this ClassLoader, and don't search the realm.
      java.lang.Class loadClassDirect​(java.lang.String className)
      Load a class directly from this classloader without defering through any other ClassRealm.
      private byte[] readStream​(java.io.InputStream in)  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, getPermissions, getResourceAsStream, 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, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, 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
    • Field Detail

      • classIndex

        private java.util.Map classIndex
      • urls

        private java.util.List urls
      • jarIndexes

        private java.util.Map jarIndexes
    • Constructor Detail

      • UberJarRealmClassLoader

        public UberJarRealmClassLoader​(DefaultClassRealm realm)
    • Method Detail

      • addConstituent

        public void addConstituent​(java.net.URL constituent)
        Description copied from class: RealmClassLoader
        Add a constituent to this realm for locating classes. If the url definition ends in .class its a BytesURLStreamHandler so use defineClass insead. addURL is still called for byte[] even though it has no affect and we use defineClass instead, this is for consistentency and to allow access to the class with getURLs()
        Overrides:
        addConstituent in class RealmClassLoader
        Parameters:
        constituent - URL to contituent jar or directory.
      • buildIndexForJar

        private void buildIndexForJar​(java.net.URL inUrl)
      • loadClassDirect

        public java.lang.Class loadClassDirect​(java.lang.String className)
                                        throws java.lang.ClassNotFoundException
        Load a class directly from this classloader without defering through any other ClassRealm.
        Overrides:
        loadClassDirect in class RealmClassLoader
        Parameters:
        className - The name of the class to load.
        Returns:
        The loaded class.
        Throws:
        java.lang.ClassNotFoundException - If the class could not be found.
      • findResource

        public java.net.URL findResource​(java.lang.String name)
        Description copied from class: RealmClassLoader
        Find a resource within this ClassLoader only (don't delegate to the parent).
        Overrides:
        findResource in class RealmClassLoader
        Returns:
        The resource.
      • findResourcesDirect

        public java.util.Enumeration findResourcesDirect​(java.lang.String name)
        Description copied from class: RealmClassLoader
        Find resources from this ClassLoader, and don't search the realm. Otherwise we'd recurse indefinitely.
        Overrides:
        findResourcesDirect in class RealmClassLoader
        Returns:
        The resource.
      • findResourceInJarStream

        protected java.net.URL findResourceInJarStream​(java.net.URL inUrl,
                                                       java.lang.String path)
      • findResourceInDirectoryUrl

        protected java.net.URL findResourceInDirectoryUrl​(java.net.URL inUrl,
                                                          java.lang.String path)
      • findClassInJarStream

        protected byte[] findClassInJarStream​(java.net.URL inUrl,
                                              java.lang.String path)
      • findClassInDirectoryUrl

        protected byte[] findClassInDirectoryUrl​(java.net.URL url,
                                                 java.lang.String path)
      • readStream

        private byte[] readStream​(java.io.InputStream in)
                           throws java.io.IOException
        Throws:
        java.io.IOException