Skip to content
Examples for working with and extending Stardog
JavaScript HTML Java CSS
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Remove the need for artifactory creds from the k8s yaml Oct 30, 2019
examples Force cache module presence in API example. This is a workaround to the Dec 6, 2019
gradle/wrapper Adding an example for HttpHandler extension. May 25, 2018
weblog Update to use stardog-spring 6.1.1 Apr 17, 2019
.gitignore add an example for a user-defined DESCRIBE strategy May 3, 2018
.profile Gradle 5 and doLast Jul 12, 2019
LICENSE Rename COPYING to LICENSE Jul 18, 2014
build.gradle Upgrade to 7.0.2, define option to set library path Nov 4, 2019
gradlew.bat * Added gradle wrapper. Feb 20, 2015 Add readme Apr 12, 2018
settings.gradle Adding an example for HttpHandler extension. May 25, 2018

Join the chat at

Programming Stardog: Examples

This is a small collection of examples of working with Stardog via its APIs, as well as examples of how to use some of the extension points within Stardog.

How to build examples

First, you'll need a valid Stardog download.

For the examples in examples/api, example/foaf, and examples/function, you'll need Gradle.

To compile or run the examples, gradle will automatically download the dependencies from our public maven repository:

gradle compileJava

To run the examples, they require a valid $STARDOG_HOME; you can provide this via the parameter stardog.home (eg -PstardogHome=/my/stardog/home).

To run any of the examples, you can use the Gradle execute task. By default, this will run the ConnectionAPIExample program, but you can specify the fully-qualified class name of any of the other examples using the mainClass parameter.

gradle execute -PmainClass=com.complexible.stardog.examples.api.ICVExample

Generating Documentation

The Stardog documentation and its javadocs are a good place to start. But some examples in this repository are annotated using Markdown; they can be processed by Docco.

If you don't have Docco installed, it's pretty easy to get started:

sudo npm install -g docco

Then, you can run it directly against any example:

docco -o docs main/src/com/complexible/stardog/api/

Or you can use the supplied gradle docs task in each build file that will run Docco against all annotated source files.

Service Loading

You'll notice that a number of examples have in their source a directory META-INF/services, these are the service registrations for each example.

Stardog uses the JDK ServiceLoader to load new services at runtime and make them available to the various parts of the system. The files in the services directory should be the fully qualified class name of the class/service, such as com.complexible.stardog.plan.filter.functions.Function, and the contents of the file should be a list of the fully qualified class names of the implementations of that service.

These need to be a part of your classpath, usually embedded in the jar file with the compiled source, in order for the ServiceLoader to make them up.

List of Examples

  1. Custom Analyzers
  2. Stardog API Examples
  3. Integrity Constraint Validation
  4. Stardog Versioning
  5. CSV example
  6. Docs Examples
  7. Database Archetype Extensibility
  8. Function Extensibility
  9. Transaction Listener
  10. Cloud Foundry Example Application
  11. Machine Learning
  12. AML Example
You can’t perform that action at this time.