Interface RestClientBuilder
- All Superinterfaces:
Configurable<RestClientBuilder>
This is the main entry point for creating a Type Safe Rest Client.
Invoking newBuilder() is intended to always create a new instance,
not use a cached version.
The RestClientBuilder is a Configurable class as defined
by JAX-RS. This allows a user to register providers, implementation specific
configuration.
Implementations are expected to implement this class and provide the instance
via the mechanism in RestClientBuilderResolver.instance().
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies the base URL to be used when making requests.<T> TBased on the configured RestClientBuilder, creates a new instance of the given REST interface to invoke API calls against.static RestClientBuilder
-
Method Details
-
newBuilder
-
baseUrl
Specifies the base URL to be used when making requests. Assuming that the interface has a@Path("/api")at the interface level and aurlis given withhttp://my-service:8080/servicethen all REST calls will be invoked with aurlofhttp://my-service:8080/service/apiin addition to any@Pathannotations included on the method.- Parameters:
url- the base Url for the service.- Returns:
- the current builder with the baseUrl set
-
build
Based on the configured RestClientBuilder, creates a new instance of the given REST interface to invoke API calls against.- Type Parameters:
T- the type of the interface- Parameters:
clazz- the interface that defines REST API methods for use- Returns:
- a new instance of an implementation of this REST interface that
- Throws:
IllegalStateException- if not all pre-requisites are satisfied for the builder, this exception may get thrown. For instance, if a URL has not been set.RestClientDefinitionException- if the passed-in interface class is invalid.
-