Jena Interface

The Jena interface is found by getting hold of a SessionConnection. This can be done with a database session, or with a URI:

 1   // The database is created with appropriate configuration
 2   Database database = ...;
 3 
 4   // create the connection factory
 5   [[ConnectionFactory]] connectionFactory = new [[ConnectionFactory]]();
 6 
 7   // get a session from the database
 8   Session session = database.newSession();
 9 
10   // now create the connection
11   [[SessionConnection]] connection = (SessionConnection)connectionFactory.newConnection(session);

The cast is needed when creating the connection, since this method returns a "Connection" interface, but only SessionConnections can be converted to JenaConnections.

To do the same thing with a server URI:

1   // create the connection factory
2   [[ConnectionFactory]] factory = new [[ConnectionFactory]]();
3 
4   // use a URI appropriate to the required server
5   URI hostUri = new URI("rmi://localhost/server1");
6 
7   // establish a connection
8   [[SessionConnection]] connection = (SessionConnection)factory.newConnection(hostUri);

A JenaConnection is obtained from a SessionConnection with the method getJenaConnection():

1   [[JenaConnection]] jenaConnection = connection.getJenaConnection();

Jena Connection Methods

The following are the methods on the JenaConnection interface. All parameters labeled graphUri refer to URIs representing graphs on a Mulgara server.

The following create/connect methods return instance of Jena Graphs or Models. Once you have instances of these objects, they can be used in an Jena-based application.

connectModel(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Model. Does not create the model.
Returns: a Jena Model.

createModel(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Model, creating the model if it does not exist.
Returns: a Jena Model.

connectModel(String graphUri, boolean createIfDoesNotExist) - Connect to RDF data stored in a Mulgara server as a Jena Model. Only creates the model if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Model.

connectModel(URI graphUri, boolean createIfDoesNotExist) - Connect to RDF data stored in a Mulgara server as a Jena Model. Only creates the model if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Model.

connectGraph(String graphUri) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Does not create the graph.
Returns: a Jena Graph.

createGraph(String graphUri, boolean createIfDoesNotExist)) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Only creates the graph if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Graph.

connectGraph(URI graphUri, boolean createIfDoesNotExist)) - Connect to RDF data stored in a Mulgara server as a Jena Graph. Only creates the graph if it does not exist and the createIfDoesNotExist flag is set.
Returns: a Jena Graph.

dropGraph(String graphUri) - Removes the graph from the Mulgara server.

dropGraph(URI graphUri) - Removes the graph from the Mulgara server.