Joseki: The Client Library

There is a library of classes to access a remote Joseki server in the package com.hp.hpl.jena.joseki. There are classes to perform queries and fetch RDF data objects, both at the protocol level and within the RDQL query framework of Jena, and classes to perform the non-query operations like "ping", "options" as well as modify remote RDF graphs by adding and removing RDF graphs from remote models.  For operations to succeed, the remote server must allow such operations on the target model.

There are also libraries for performing queries for Python and Perl.  See Python/ and Perl/.

Query languages provided in the Joseki distribution are:

See the "Query Languages" page for full details about these query languages.

The protocol used for access remote RDF is a simple use of HTTP GET which returns the smallest subgraph that matches the query (i.e. it gives the same results as the query on the original graph).  Other operations use HTTP POST.

There is also a client library of Python, which issues queries to a Joseki server and uses the RDFLib toolkit for client-side handling of the results.

Fetching all the RDF about a Resource

Access to the fetch functionality on RDF data objects is provided by the class HttpFetch.  The "fetch" query language specifies the target model and the resource.  A "fetch" request returns all the RDF associated with the resource known to the model.  The exact model of RDF statements is determined by the server configuration.

HttpFetch fetch = new HttpFetch(modelURI, resourceURI) ;
Model obj = fetch.exec() ;

Because fetching data objects is a query, requests use HTTP GET with all the usual caching and bookmarking.

Executing RDQL queries on a remote model

The primary class is QueryEngineHTTP, which implements the standard Jena QueryExecution interface for variable bindings.  Remote queries are executed in the same manner as local queries, except that a different query execution object is used.

The following code fragments show using the client API in Java. See the Jena javadoc for more detailed documentation on the general query classes and the Joseki javadoc for QueryEngineHTTP.

Query q = new Query(queryString) ;
QueryExecution qe = new QueryEngineHTTP(q, modelURI) ;
QueryResults results = qe.exec() ;
for ( Iterator iter = results ; iter.hasNext() ; )
{
    ResultBinding rbind = (ResultBinding)iter.next() ;
    //  Assuming the query has a variable called "x" ...
    Object obj = rbind.get("x") ;
    // obj will be a Jena object: resource, property or RDFNode.
    System.out.println("x = "+obj.toString() ;
}
results.close() ;

Low-level interface to query

The class HttpQuery provides a wrapper to HTTP GET and is used by HttpFetch and QueryEngineHTTP.

Other Operations

See the javadoc for the package com.hp.hpl.jena.joseki.