Interface ResourceLoader

All Known Implementing Classes:
AbstractResourceLoader, FileResourceLoader, JarResourceLoader, ServletContextResourceLoader, ThreadContextClasspathResourceLoader, URLResourceLoader

public interface ResourceLoader
Version:
$Id$
Author:
Trygve Laugstøl
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default configuration ordinal value, 100.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    Returns the Identifier Named class
    default int
    Return the ordinal priority value of this configuration source.
    Returns the resource with the given name.
    Retrieves the resource paths as a Set from a given directory.
  • Field Details

    • DEFAULT_ORDINAL

      static final int DEFAULT_ORDINAL
      The default configuration ordinal value, 100.
      See Also:
  • Method Details

    • addSearchPath

      void addSearchPath(String path)
    • getResource

      Returns the resource with the given name.
      Parameters:
      name - The resources name.
      Returns:
      The resource with the given name.
      Throws:
      ResourceNotFoundException - The resource wasn't found, or wasn't available.
    • getResourceURL

      Set<URL> getResourceURL(String path) throws ResourceNotFoundException
      Retrieves the resource paths as a Set from a given directory. This method reads the files in the specified directory, converts their paths to URLs, and returns them in a Set. If no resources are found, a ResourceNotFoundException will be thrown.
      Parameters:
      path - The base path in the file system, which can be either relative or absolute. This path is used to locate the directory containing the resources. The path must start with a "/".
      Returns:
      A Set containing the URLs of the resources found in the directory.
      Throws:
      ResourceNotFoundException - If no resources are found or if an error occurs while reading the directory or converting paths to URLs.
    • getId

      String getId()
      Returns the Identifier Named class
      Returns:
      Identifier Named loader
    • getOrdinal

      default int getOrdinal()
      Return the ordinal priority value of this configuration source.

      If a resource can be loaded by multiple resource loader, the value in the resource loader with the highest ordinal takes precedence. For resource loader with the same ordinal value, the resource loader name will be used for sorting according to string sorting criteria.

      Note that this method is only evaluated during the construction of the resource manager, and does not affect the ordering of configuration sources within a configuration after that time.

      The ordinal values for the default configuration sources can be found above.

      The default implementation of this method looks for a configuration property named "config_ordinal" to determine the ordinal value for this configuration source. If the property is not found, then the default ordinal value is used.

      This method may be overridden by source loader implementations to provide a different behavior.

      Returns:
      the ordinal value