Questo contenuto non è disponibile nella lingua selezionata.
Chapter 6. Managing Service Registry content using a Java client
This chapter explains how to use the Service Registry Java client:
6.1. Service Registry Java client Copia collegamentoCollegamento copiato negli appunti!
You can manage artifacts stored in Service Registry using a Java client application. You can create, read, update, or delete artifacts stored in the registry using the Service Registry Java client classes. You can also perform admin functions using the client, such as managing global rules or importing and exporting registry data.
You can access the Service Registry Java client by adding the correct dependency to your project. For more details, see Section 6.2, “Writing Service Registry Java client applications”
The Service Registry client is implemented using the HTTP client provided by the JDK. This gives you the ability to customize its use, for example, by adding custom headers or enabling options for Transport Layer Security (TLS) authentication. For more details, see Section 6.3, “Service Registry Java client configuration”
6.2. Writing Service Registry Java client applications Copia collegamentoCollegamento copiato negli appunti!
This section explains how to manage artifacts stored in Service Registry using a Java client application.
Prerequisites
- Service Registry is installed and running in your environment
Procedure
Add the following dependency to your Maven project:
<dependency> <groupId>io.apicurio</groupId> <artifactId>apicurio-registry-client</artifactId> <version>${apicurio-registry.version}</version> </dependency>
<dependency> <groupId>io.apicurio</groupId> <artifactId>apicurio-registry-client</artifactId> <version>${apicurio-registry.version}</version> </dependency>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a registry client as follows:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
If you specify an example registry URL of
https://my-registry.my-domain.com
, the client will automatically append/apis/registry/v2
. - For more options when creating a Service Registry client, see the Java client configuration in the next section.
-
If you specify an example registry URL of
When the client is created, you can use all the operations available in the Service Registry REST API in the client. For more details, see the Apicurio Registry REST API documentation.
6.3. Service Registry Java client configuration Copia collegamentoCollegamento copiato negli appunti!
The Service Registry Java client includes the following configuration options, based on the client factory:
Option | Description | Arguments |
---|---|---|
Plain client | Basic REST client used to interact with a running registry. |
|
Client with custom configuration | Registry client using the configuration provided by the user. |
|
Client with custom configuration and authentication | Registry client that accepts a map containing custom configuration. For example, this is useful to add custom headers to the calls. You must also provide an authentication server to authenticate the requests. |
|
Custom header configuration
To configure custom headers, you must add the apicurio.registry.request.headers
prefix to the configs
map key. For example, a key of apicurio.registry.request.headers.Authorization
with a value of Basic: xxxxx
results in a header of Authorization
with value of Basic: xxxxx
.
TLS configuration options
You can configure Transport Layer Security (TLS) authentication for the Service Registry Java client using the following properties:
-
apicurio.registry.request.ssl.truststore.location
-
apicurio.registry.request.ssl.truststore.password
-
apicurio.registry.request.ssl.truststore.type
-
apicurio.registry.request.ssl.keystore.location
-
apicurio.registry.request.ssl.keystore.password
-
apicurio.registry.request.ssl.keystore.type
-
apicurio.registry.request.ssl.key.password