Interface Describable<D,R>

Type Parameters:
D - The type of API Descriptor object that will be the result of the description. For example, for CREST this would be the ApiDescription class from the api-descriptor module.
R - The type of request that will be presented to get API descriptions.
All Known Subinterfaces:
DescribableHandler
All Known Implementing Classes:
AbstractConnectionWrapper, AbstractRouter, DescribedSyncRequestHandlerAdapter, FilterChain, Router, Router

public interface Describable<D,R>
A routing component (a CHF Handler or CREST RequestHandler) can describe its API by implementing this interface.
  • Method Details

    • api

      D api(ApiProducer<D> producer)
      Provide the API description for the component. This method should perform the heavy-lifting of computing the API descriptor, and should be expected to be called rarely. Upstream handlers should call this method in order to compose all of their downstream API Descriptors into a single descriptor.
      Parameters:
      producer - The API producer that provides general information to be built into the descriptor.
      Returns:
      The description object.
    • handleApiRequest

      D handleApiRequest(Context context, R request)
      Handle a request for the API Descriptor. This method should not do any computation, but should return the already computed descriptor.
      Parameters:
      context - The request context.
      request - The request.
      Returns:
      The descriptor.
      Throws:
      IllegalStateException - When the request cannot be routed to an acceptable handler.
      UnsupportedOperationException - When there is no API Descriptor available for the request.
    • addDescriptorListener

      default void addDescriptorListener(Describable.Listener listener)
      Add a listener for API Descriptor changes. The described object should call all the listeners.
      Parameters:
      listener - The listener.
    • removeDescriptorListener

      default void removeDescriptorListener(Describable.Listener listener)
      Remove a listener from API Descriptor changes.
      Parameters:
      listener - The listener.