Interface ResourceLoader

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      default void close()
      Closes this resource, relinquishing any underlying resources.
      default ResourceLoader createSubloader​(java.lang.String relativePath, java.lang.String rootName)
      Create a loader which loads resources under a relative subdirectory relative to this loader.
      ClassSpec getClassSpec​(java.lang.String fileName)
      Get the class specification for the given class name.
      java.lang.String getLibrary​(java.lang.String name)
      Get the absolute physical filesystem path for a library with the given name.
      default java.net.URI getLocation()
      Get the base location of the resources in this loader (if any).
      PackageSpec getPackageSpec​(java.lang.String name)
      Get the package specification for the given directory name.
      java.util.Collection<java.lang.String> getPaths()
      Get the collection of resource paths.
      Resource getResource​(java.lang.String name)
      Get a resource with the given name.
      default java.lang.String getRootName()
      Deprecated.
    • Method Detail

      • getRootName

        @Deprecated
        default java.lang.String getRootName()
        Deprecated.
        Get the name of the root represented by this resource loader.
        Returns:
        the name of the root
      • getClassSpec

        ClassSpec getClassSpec​(java.lang.String fileName)
                        throws java.io.IOException
        Get the class specification for the given class name. If no matching class is found, null is returned.
        Parameters:
        fileName - the fileName of the class, e.g. for the class org.jboss.modules.ResourceLoader the fileName will be org/jboss/modules/ResourceLoader.class
        Returns:
        the class specification, or null if the named class is not found
        Throws:
        java.io.IOException - if an I/O error occurs
      • getPackageSpec

        PackageSpec getPackageSpec​(java.lang.String name)
                            throws java.io.IOException
        Get the package specification for the given directory name. Always returns a package specification; this method cannot be used to test for the existence of a package. A package spec should always be acquired from the same resource loader which provided the class specification. The directory name will always be specified using "/" separators.
        Parameters:
        name - the directory name
        Returns:
        the package specification
        Throws:
        java.io.IOException - if an I/O error occurs
      • getResource

        Resource getResource​(java.lang.String name)
        Get a resource with the given name. If no such resource is available, null is returned. The resource name will always be specified using "/" separators for the directory segments.
        Parameters:
        name - the resource name
        Returns:
        the resource, or null if it is not available
      • getLibrary

        java.lang.String getLibrary​(java.lang.String name)
        Get the absolute physical filesystem path for a library with the given name. The resultant path should be path-separated using "/" characters.
        Parameters:
        name - the name
        Returns:
        the path or null if the library is not present
      • getPaths

        java.util.Collection<java.lang.String> getPaths()
        Get the collection of resource paths. Called one time only when the resource loader is initialized. The paths should use "/" characters to separate the path segments.
        Returns:
        the resource paths
      • close

        default void close()
        Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.
        Specified by:
        close in interface java.lang.AutoCloseable
      • getLocation

        default java.net.URI getLocation()
        Get the base location of the resources in this loader (if any). If the location is not known, or the resource loader does not support locations, or the resource loader does not support this method, null is returned.
        Returns:
        the base location of the resources in this loader, or null if not available
      • createSubloader

        default ResourceLoader createSubloader​(java.lang.String relativePath,
                                               java.lang.String rootName)
        Create a loader which loads resources under a relative subdirectory relative to this loader. If the resource loader does not support subloaders, null is returned.
        Parameters:
        relativePath - the relative path
        rootName - the name of the subloader's root
        Returns:
        the resource loader, or null if subloaders are not supported