Interface RestRegistry
- All Superinterfaces:
AutoCloseable, Service, 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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDetails about the REST service -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRestService(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.voidaddRestSpecification(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)@Nullable StringOutputs the Rest services API documentation in JSON (requires camel-openapi-java on classpath)voidRecords a hit on the REST service matching the given HTTP method and path.List all REST services from this registry.List all REST API specification (ie api-doc)voidremoveRestService(Consumer consumer) Removes the REST service from the registryintsize()Number of rest services in the registry.
-
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 consumercontractFirst- is the rest service based on code-first or contract-firsturl- the absolute url of the REST servicebaseUrl- the base url of the REST servicebasePath- the base pathuriTemplate- the uri templatemethod- the HTTP methodconsumes- optional details about what media-types the REST service acceptsproduces- optional details about what media-types the REST service returnsinType- optional detail input binding to a FQN class nameoutType- optional detail output binding to a FQN class namerouteId- the id of the route this rest service will be usingoperationId- optional operationId from the OpenAPI contractspecificationUri- optional URI of the OpenAPI spec file (contract-first only)description- optional description about the service
-
hit
-
removeRestService
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 consumercontractFirst- is the rest service based on code-first or contract-firsturl- the absolute url of the REST servicebaseUrl- the base url of the REST servicebasePath- the base pathmethod- the HTTP methodproduces- optional details about what media-types the REST service returnsdescription- 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
-