Interface RestRegistry

All Superinterfaces:
AutoCloseable, Service, StaticService

public interface RestRegistry extends StaticService
A live registry of all REST services running within the CamelContext that were defined using the Camel REST DSL.

Each REST-DSL route registers its verb-plus-path pair at startup via addRestService(); the registry keeps a RestRegistry.RestService record per operation that carries the URL, HTTP method, media types, binding types, and hit counter. The developer console, JMX management layer, and the camel-openapi-java module all query this registry to render live service listings and to generate the OpenAPI specification (apiDocAsJson()). Separately, OpenAPI contract entries are tracked as "specifications" via addRestSpecification().

See Rest DSL in the Camel user manual.

See Also:
  • Method Details

    • addRestService

      void addRestService(Consumer consumer, boolean contractFirst, String url, String baseUrl, String basePath, @Nullable String uriTemplate, String method, @Nullable String consumes, @Nullable String produces, @Nullable String inType, @Nullable String outType, String routeId, @Nullable String operationId, @Nullable String specificationUri, @Nullable String description)
      Adds a new REST service to the registry.
      Parameters:
      consumer - the consumer
      contractFirst - is the rest service based on code-first or contract-first
      url - the absolute url of the REST service
      baseUrl - the base url of the REST service
      basePath - the base path
      uriTemplate - the uri template
      method - the HTTP method
      consumes - optional details about what media-types the REST service accepts
      produces - optional details about what media-types the REST service returns
      inType - optional detail input binding to a FQN class name
      outType - optional detail output binding to a FQN class name
      routeId - the id of the route this rest service will be using
      operationId - optional operationId from the OpenAPI contract
      specificationUri - optional URI of the OpenAPI spec file (contract-first only)
      description - optional description about the service
    • hit

      void hit(String method, String basePath, String path)
      Records a hit on the REST service matching the given HTTP method and path.
      Parameters:
      method - the HTTP method (GET, POST, etc.)
      basePath - the base path
      path - the URI path or template (e.g. /users/{id})
      Since:
      4.21
    • removeRestService

      void removeRestService(Consumer consumer)
      Removes the REST service from the registry
      Parameters:
      consumer - the consumer
    • listAllRestServices

      List<RestRegistry.RestService> listAllRestServices()
      List all REST services from this registry.
      Returns:
      all the REST services
    • addRestSpecification

      void addRestSpecification(Consumer consumer, boolean contractFirst, String url, String baseUrl, String basePath, String method, @Nullable String produces, @Nullable String description)
      Adds information about the API specification (ie api-doc)
      Parameters:
      consumer - the consumer
      contractFirst - is the rest service based on code-first or contract-first
      url - the absolute url of the REST service
      baseUrl - the base url of the REST service
      basePath - the base path
      method - the HTTP method
      produces - optional details about what media-types the REST service returns
      description - optional description about the service
    • listAllRestSpecifications

      List<RestRegistry.RestService> listAllRestSpecifications()
      List all REST API specification (ie api-doc)
      Returns:
      all the API specification (ie api-doc)
    • size

      int size()
      Number of rest services in the registry.
      Returns:
      number of rest services in the registry.
    • apiDocAsJson

      @Nullable String apiDocAsJson()
      Outputs the Rest services API documentation in JSON (requires camel-openapi-java on classpath)
      Returns:
      the API docs in JSon, or null if camel-openapi-java is not on classpath