public class RDF2Go extends Object
This is the main entry point to use RDF2Go, and in particular to create Models. You have to register an adaptor once to use this. Example:
// register adapter of implementation XYZ, could be Jena or Sesame or anything.
RDF2Go.register( new org.ontoware.rdf2go.impl.XYZ.ModelFactoryImpl() );
// start using RDF2Go
Model m = RDF2Go.getModelFactory().createModel();
m.addTriple(...)
For each RDF2Go adapter, an ModelFactoy implementation is needed.
User can call the or #register(String)
method
to do that.
As a fall-back, when a user calls getModelFactory() but no adapter has been
registered yet, RDF2Go looks for a class named
org.ontoware.rdf2go.impl.StaticBinding and tries to call a method named
"getModelFactory" to get a model factory. This approach has been inspired by
SL4Js static bindign approach. When multiple adapters are found, the first in
the class path is used. This fall-back allows one to simply pack together a
bunch of JARs an be ready to used RDF2Go without any configuration and
without any OSGi.
The expected class looks like this:
package org.ontoware.rdf2go.impl;
import org.ontoware.rdf2go.ModelFactory;
public class StaticBinding {
public static ModelFactory getModelFactory() {
return new org.ontoware.rdf2go.impl.XXXX.ModelFactoryImpl();
}
}
Modifier and Type | Field and Description |
---|---|
protected static ModelFactory |
modelFactory
the default factory for RDF2Go.
|
Constructor and Description |
---|
RDF2Go() |
Modifier and Type | Method and Description |
---|---|
static ModelFactory |
getModelFactory()
get the currently registered RDF2Go factory.
|
static void |
register(ModelFactory modelFactory)
register an implementation of the RDF2Go framework.
|
static void |
register(String modelFactoryClassname) |
protected static ModelFactory modelFactory
public static final ModelFactory getModelFactory()
public static final void register(ModelFactory modelFactory)
modelFactory
- the factory to register. You can pass
null
to unregister a modelFactory. Unregistering
is restricted to frameworks, you will not need it in simple
applications.RuntimeException
- if registered already. See the cause of this
exception for a stacktrace where you first registered.public static final void register(String modelFactoryClassname) throws ModelRuntimeException
ModelRuntimeException
Copyright © 2005–2017 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.