Package com.inrupt.client.spi
package com.inrupt.client.spi
Service interfaces for the Inrupt Java Client Libraries.
This module provides a pluggable service provider interface, which allows the HTTP, JSON, and RDF services to be used with any concrete implementation.
One can make use of available implementation such as:
- for HTTP processing:
OkHttpService
or theHttpClientService
; - for JSON processing:
JsonbService
or theJacksonService
; - for RDF processing:
JenaService
or theRDF4JService
.
To make use of a concrete implementation make sure, first, to add the needed modules to the pom of your module. Example:
<dependency> <groupId>com.inrupt</groupId> <artifactId>inrupt-client-xxxConcreteImplementationNamexxx</artifactId> <version>${project.version}</version> </dependency>
Example of using the HTTP service send() method to request the Solid logo:
HttpService client = ServiceProvider.getHttpService();
Request request = Request.newBuilder()
.uri("https://example.example/solid.png")
.GET()
.build();
Response<byte[]> response = client.send(request, Response.BodyHandlers.ofByteArray())
.toCompletableFuture().join();
System.out.println("HTTP status code: " + response.statusCode());
System.out.println("Response uri: " + response.uri());
System.out.println("Content type: " + response.headers().get("Content-Type"));
Example of using the JSON processor fromJson() method to read a custom type:
JsonService service = ServiceProvider.getJsonService();
try (InputStream is = Test.class.getResourceAsStream("customType.json")) {
CustomType obj = service.fromJson(is, CustomType.class);
System.out.println("The CustomType Id is: " + obj.id);
}
Example of using the RDF service toDataset() method to read triples
from a trig file into a org.apache.commons.rdf.api.Dataset
:
RdfService processor = ServiceProvider.getRdfService();
Dataset dataset;
try (InputStream input = Test.class.getResourceAsStream("/oneTriple.trig")) {
dataset = processor.toDataset(RDFSyntax.TRIG, input);
}
System.out.println("Number of triples in file: " + dataset.size());
-
ClassDescriptionAn authentication mechanism that knows how to authenticate over network connections.A cache builder abstraction for use with different cache implementations.An abstraction that loads the available
Client
from, the classpath.A DPoP management abstraction.A parser interface for handling HTTP header parsers.An HTTP handling abstraction.A JSON handling abstraction.A RDF commons handling abstraction.A generic abstraction for interacting with different underlying RDF libraries.This is the class used to access data processors for the Inrupt Java Client Libraries libraries.