Interface ResourceProviderSpi


public interface ResourceProviderSpi
This interface must be made available to the BuildContext by implementations of resource providers.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Resource>
    Stream<T>
    Provide the requested resources.
  • Method Details

    • provide

      <T extends Resource> Stream<T> provide(ResourceRequest<T> request)

      Provide the requested resources. This method is not intended to be invoked directly. Rather, it must be invoked via BuildContext.resources(ResourceProvider, ResourceRequest).

      When properly invoked through BuildContext.resources(ResourceProvider, ResourceRequest), this method is never invoked twice for the same request (unless there has been a request for Cleanliness in between). The method may, however, be invoked concurrently for different requests.

      Providers that evaluate all potentially provided resources anyway and return only a subset for some actually requested ResourceTypes should therefore invoke themselves through ResourceProvider.resources(ResourceRequest) with a request for all resources and filter the (automatically cached) result.

      Special care must be taken when handling resource type hierarchies. If ResourceType B extends ResourceType A and the provider provides ResourceType B, it must also provide its resources in response to a request for ResourceType A. However, the caching mechanism is unaware of relationships between resource types. Requests for A and B are therefore forwarded independently. To avoid duplicate evaluation, the provider must map a request for A to a request for B (via ResourceProvider.resources(ResourceRequest)).

      Type Parameters:
      T - the type of the requested (and provided) resource
      Parameters:
      request - the request for resources
      Returns:
      the provided resource(s) as stream