Class URLClassSpace

java.lang.Object
org.eclipse.sisu.space.URLClassSpace
All Implemented Interfaces:
ClassSpace
Direct Known Subclasses:
CloningClassSpace

public class URLClassSpace extends Object implements ClassSpace
ClassSpace backed by a strongly-referenced ClassLoader and a URL class path.
  • Field Details

    • MANIFEST_ENTRY

      private static final String MANIFEST_ENTRY
      See Also:
    • NO_URLS

      private static final URL[] NO_URLS
    • NO_ENTRIES

      private static final Enumeration<URL> NO_ENTRIES
    • EMPTY_CLASSPATH

      private static final String[] EMPTY_CLASSPATH
    • SYSTEM_LOADER

      private static final ClassLoader SYSTEM_LOADER
    • SYSTEM_CLASSPATH

      private static final String SYSTEM_CLASSPATH
    • loader

      private final ClassLoader loader
    • pathDetails

      private final String pathDetails
    • classPath

      private URL[] classPath
  • Constructor Details

  • Method Details

    • loadClass

      public final Class<?> loadClass(String name)
      Description copied from interface: ClassSpace
      Loads the named class from the surrounding class space.
      Specified by:
      loadClass in interface ClassSpace
      Parameters:
      name - The class name
      Returns:
      Class instance
      See Also:
    • deferLoadClass

      public final DeferredClass<?> deferLoadClass(String name)
      Description copied from interface: ClassSpace
      Defers loading of the named class from the surrounding class space.
      Specified by:
      deferLoadClass in interface ClassSpace
      Parameters:
      name - The class name
      Returns:
      Deferred class
      See Also:
    • getResource

      public final URL getResource(String name)
      Description copied from interface: ClassSpace
      Queries the surrounding class space for the resource with the given name.
      Specified by:
      getResource in interface ClassSpace
      Parameters:
      name - The resource name
      Returns:
      URL pointing to the resource; null if it wasn't found
      See Also:
    • getResources

      public final Enumeration<URL> getResources(String name)
      Description copied from interface: ClassSpace
      Queries the surrounding class space for all resources with the given name.
      Specified by:
      getResources in interface ClassSpace
      Parameters:
      name - The resource name
      Returns:
      Sequence of URLs, one for each matching resource
      See Also:
    • findEntries

      public final Enumeration<URL> findEntries(String path, String glob, boolean recurse)
      Description copied from interface: ClassSpace
      Queries local class space content for entries matching the given pattern.
      Specified by:
      findEntries in interface ClassSpace
      Parameters:
      path - The initial search directory; for example "META-INF"
      glob - The filename glob pattern; for example "*.xml"
      recurse - If true recurse into sub-directories; otherwise only search initial directory
      Returns:
      Sequence of URLs, one for each matching entry
      See Also:
      • Bundle.findEntries(String, String, boolean)
    • getURLs

      public final URL[] getURLs()
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • getClassPath

      private URL[] getClassPath()
      Returns the associated URL class path; this can either be explicit or implicit.
    • getSystemClassPath

      private static URL[] getSystemClassPath()
      Returns the system URL class path.
    • expandClassPath

      private static URL[] expandClassPath(URL[] classPath)
      Expands the given URL class path to include Class-Path entries from local manifests.
      Parameters:
      classPath - The URL class path
      Returns:
      Expanded URL class path
    • normalizeEntry

      private static URL normalizeEntry(URL url)
      Normalizes the given class path entry by removing any extraneous "jar:"..."!/" padding.
      Parameters:
      path - The URL to normalize
      Returns:
      Normalized class path entry
    • getClassPathEntries

      private static String[] getClassPathEntries(URL url) throws IOException
      Looks for Class-Path entries in the given jar or directory; returns empty array if none are found.
      Parameters:
      url - The jar or directory to inspect
      Returns:
      Array of Class-Path entries
      Throws:
      IOException