org.ontoware.rdf2go
Class RDF2Go
java.lang.Object
org.ontoware.rdf2go.RDF2Go
public class RDF2Go
- extends java.lang.Object
Convenience class that allows registering and finding ModelFactories If you
use one adaptor in your application, you should always use the default
instance. If you use multiple frameworks, then you should instantiate the
ModelFactory implementations directly.
Usage
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 #register() 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();
}
}
- Author:
- sauermann, voelkel
|
Method Summary |
static ModelFactory |
getModelFactory()
get the currently registered RDF2Go factory. |
static void |
register(ModelFactory modelFactory)
register an implementation of the RDF2Go framework. you can only register
one framework inside one Java application, it will throw an Exception if
you register more than one. |
static void |
register(java.lang.String modelFactoryClassname)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
modelFactory
protected static ModelFactory modelFactory
- the default factory for RDF2Go. This is a singleton. The field is
protected by design, JUnit tests inside RDF2Go may want to reset it.
RDF2Go
public RDF2Go()
getModelFactory
public static final ModelFactory getModelFactory()
- get the currently registered RDF2Go factory. Usually, you will use one
adaptor in your application, register this adaptor using the .register()
method and it is available here. If none is registered, this throws a
RuntimeException.
- Returns:
- the default RDF2Go instance.
register
public static final void register(ModelFactory modelFactory)
- register an implementation of the RDF2Go framework. you can only register
one framework inside one Java application, it will throw an Exception if
you register more than one.
- Parameters:
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.
- Throws:
java.lang.RuntimeException - if registered already. See the cause of this exception for a
stacktrace where you first registered.
register
public static final void register(java.lang.String modelFactoryClassname)
throws ModelRuntimeException
- Throws:
ModelRuntimeException
Copyright © 2005-2008 FZI - Forschungszentrum Informatik | Karlsruhe | Germany. All Rights Reserved.