Class UberJarRealmClassLoader

All Implemented Interfaces:
Closeable, 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 Details

    • classIndex

      private Map classIndex
    • urls

      private List urls
    • jarIndexes

      private Map jarIndexes
  • Constructor Details

  • Method Details

    • addConstituent

      public void addConstituent(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(URL inUrl)
    • loadClassDirect

      public Class loadClassDirect(String className) throws 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:
      ClassNotFoundException - If the class could not be found.
    • findResource

      public URL findResource(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 Enumeration findResourcesDirect(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 URL findResourceInJarStream(URL inUrl, String path)
    • findResourceInDirectoryUrl

      protected URL findResourceInDirectoryUrl(URL inUrl, String path)
    • findClassInJarStream

      protected byte[] findClassInJarStream(URL inUrl, String path)
    • findClassInDirectoryUrl

      protected byte[] findClassInDirectoryUrl(URL url, String path)
    • readStream

      private byte[] readStream(InputStream in) throws IOException
      Throws:
      IOException