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 theApiDescription
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.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Interface for listener instances. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
addDescriptorListener
(Describable.Listener listener) Add a listener for API Descriptor changes.api
(ApiProducer<D> producer) Provide the API description for the component.handleApiRequest
(Context context, R request) Handle a request for the API Descriptor.default void
removeDescriptorListener
(Describable.Listener listener) Remove a listener from API Descriptor changes.
-
Method Details
-
api
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
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
Add a listener for API Descriptor changes. The described object should call all the listeners.- Parameters:
listener
- The listener.
-
removeDescriptorListener
Remove a listener from API Descriptor changes.- Parameters:
listener
- The listener.
-