Download Fluent-API

Download JAR

Classes | Sources | Javadoc

eXist-db Fluent-API

In summer 2007 Piotr Kaminski contributed an extension package org.exist.fluent, an API for databases running in embedded mode that takes advantage of Java 5.0 features.

Although the API has been part of eXist-db since then, the API did not get too much attention. This is a pity because Fluent actually provides a nice clean and well documented embedded API to eXist-db which is far more easy to use compared to the API of eXist-db core.

The purpose of this site is to give Fluent a bit more exposure to the eXist-db community.

The Fluent API has been well documented in the Javadoc documentation which can be browsed here. On the right side of the page JAR files can be downloaded containing the sources, classes and the documentation.

Code example

A simple example of the API (Download)

// Configure logging
BasicConfigurator.configure();

// Database Startup
Database.startup(new File("conf.xml"));
Database db = Database.login("admin", null);

// Load conf.xml into database as /db/fluent/mydata.xml
// This is 'just' a datafile for the query example below
Folder folder = db.createFolder("/db/fluent");
Name docname = Name.create("mydata.xml");
XML xml = XML.xml(new File("conf.xml"));
folder.documents().load(docname, xml);

// Perform query, list result
ItemList items = folder.query().all("//module/@uri");
for (String name : items.values()) {
System.out.println("uri: " + name);
}

// Cleanup
folder.delete();

Database.shutdown();

Note

The Fluent API is built on top of the eXist-db classes. To be able to use the library, it is required get all JAR files from lib/core directory, plus the conf.xml file for configuring the database.