Interface ResourceManager

All Known Implementing Classes:
DefaultResourceManager, ResourceManagerImpl

public interface ResourceManager
Locates resources that are used at runtime. The ResourceManager queries registered ResourceResolver to find resources.
  • Method Details

    • resolveResource

      <T> T resolveResource(String name, Class<T> type)
      Resolve a resource. The ResourceManager will query all of the registered ResourceResovler objects until one manages to resolve the resource
      Parameters:
      name - name of resource to resolve.
      type - type of resource to resolve.
      Returns:
      the resolved resource or null if nothing found.
    • resolveResource

      <T> T resolveResource(String name, Class<T> type, List<ResourceResolver> resolvers)
      Resolve a resource with via a specified list of resovlers. This allows resources to be specified with a locally defined list of resolvers.
      Parameters:
      name - name of resource to resolve.
      type - type of resource to resolve.
      resolvers - list of ResourceResolvers to search.
      Returns:
      the resolved resource or null if nothing found.
    • getResourceAsStream

      InputStream getResourceAsStream(String name)
      Open stream to resource.
      Parameters:
      name - name of resource to resolve.
      Returns:
      the InputStream to the resource or null if the resource cannot be found.
    • addResourceResolver

      void addResourceResolver(ResourceResolver resolver)
      Add a ResourceResolver. The newly added resolver is added at the head of the list so the most recently added will be queried first.
      Parameters:
      resolver - the ResourceResolver to add. Duplicates will be ignored.
    • removeResourceResolver

      void removeResourceResolver(ResourceResolver resolver)
      Remove a ResourceResolver.
      Parameters:
      resolver - the ResourceResolver to remove. If not previously registered, it is ignored.
    • getResourceResolvers

      List<ResourceResolver> getResourceResolvers()
      Get all the currently registered resolvers. This method should return an unmodifiable view of the list of resolvers so that resolvers added after this method has been called will alter the list returned.