Class SailRepository
java.lang.Object
org.eclipse.rdf4j.repository.base.AbstractRepository
org.eclipse.rdf4j.repository.sail.SailRepository
- All Implemented Interfaces:
HttpClientDependent
,SessionManagerDependent
,FederatedServiceResolverClient
,Repository
,RepositoryResolverClient
- Direct Known Subclasses:
FedXRepository
public class SailRepository
extends AbstractRepository
implements FederatedServiceResolverClient, RepositoryResolverClient, HttpClientDependent, SessionManagerDependent
An implementation of the
Repository
interface that operates on a (stack of) Sail
object(s). The
behaviour of the repository is determined by the Sail stack that it operates on; for example, the repository will
only support RDF Schema or OWL semantics if the Sail stack includes an inferencer for this.
Creating a repository object of this type is very easy. For example, the following code creates and initializes a main-memory store with RDF Schema semantics:
Repository repository = new SailRepository(new ForwardChainingRDFSInferencer(new MemoryStore())); repository.initialize();
Or, alternatively:
Sail sailStack = new MemoryStore(); sailStack = new ForwardChainingRDFSInferencer(sailStack); Repository repository = new SailRepository(sailStack); repository.initialize();
- Author:
- Arjohn Kampman
-
Field Summary
Fields inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
logger
-
Constructor Summary
ConstructorDescriptionSailRepository
(Sail sail) Creates a new repository object that operates on the supplied Sail. -
Method Summary
Modifier and TypeMethodDescriptionOpens a connection to this repository that can be used for querying and updating the contents of the repository.Get the directory where data and logging for this repository is stored.org.apache.http.client.HttpClient
HttpClient
that has been assigned or has been used by this object.HttpClientSessionManager
that has been assigned or has been used by this object.getSail()
Gets the Sail object that is on top of the Sail stack that this repository operates on.Gets a ValueFactory for this Repository.protected void
boolean
Checks whether this repository is writable, i.e.void
setDataDir
(File dataDir) Set the directory where data and logging for this repository is stored.void
Sets theFederatedServiceResolver
to use for this client.void
setHttpClient
(org.apache.http.client.HttpClient client) Assign anHttpClient
that this object should use.void
Assign anHttpClientSessionManager
that this object should use.void
setRepositoryResolver
(RepositoryResolver resolver) protected void
toString()
Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
init, isInitialized, shutDown
-
Constructor Details
-
SailRepository
Creates a new repository object that operates on the supplied Sail.- Parameters:
sail
- A Sail object.
-
-
Method Details
-
getDataDir
Description copied from interface:Repository
Get the directory where data and logging for this repository is stored.- Specified by:
getDataDir
in interfaceRepository
- Returns:
- the directory where data for this repository is stored.
-
setDataDir
Description copied from interface:Repository
Set the directory where data and logging for this repository is stored.- Specified by:
setDataDir
in interfaceRepository
- Parameters:
dataDir
- the directory where data for this repository is stored
-
setFederatedServiceResolver
Description copied from interface:FederatedServiceResolverClient
Sets theFederatedServiceResolver
to use for this client.- Specified by:
setFederatedServiceResolver
in interfaceFederatedServiceResolverClient
- Parameters:
resolver
- The resolver to use.
-
setRepositoryResolver
- Specified by:
setRepositoryResolver
in interfaceRepositoryResolverClient
-
getHttpClientSessionManager
Description copied from interface:SessionManagerDependent
HttpClientSessionManager
that has been assigned or has been used by this object. The life cycle might not be or might be tied to this object, depending on whetherHttpClientSessionManager
was passed to or created by this object respectively.- Specified by:
getHttpClientSessionManager
in interfaceSessionManagerDependent
- Returns:
- a
HttpClientSessionManager
instance or null
-
setHttpClientSessionManager
Description copied from interface:SessionManagerDependent
Assign anHttpClientSessionManager
that this object should use. The life cycle of the givenHttpClientSessionManager
is independent of this object. Closing or shutting down this object does not have any impact on the given client. Callers must ensure that the given client is properly closed elsewhere.- Specified by:
setHttpClientSessionManager
in interfaceSessionManagerDependent
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()Description copied from interface:HttpClientDependent
HttpClient
that has been assigned or has been used by this object. The life cycle might not be or might be tied to this object, depending on whetherHttpClient
was passed to or created by this object respectively.- Specified by:
getHttpClient
in interfaceHttpClientDependent
- Returns:
- an
HttpClient
instance or null
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient client) Description copied from interface:HttpClientDependent
Assign anHttpClient
that this object should use. The life cycle of the givenHttpClient
is independent of this object. Closing or shutting down this object does not have any impact on the given client. Callers must ensure that the given client is properly closed elsewhere.- Specified by:
setHttpClient
in interfaceHttpClientDependent
-
initializeInternal
- Specified by:
initializeInternal
in classAbstractRepository
- Throws:
RepositoryException
-
shutDownInternal
- Specified by:
shutDownInternal
in classAbstractRepository
- Throws:
RepositoryException
-
getSail
Gets the Sail object that is on top of the Sail stack that this repository operates on.- Returns:
- A Sail object.
-
isWritable
Description copied from interface:Repository
Checks whether this repository is writable, i.e. if the data contained in this repository can be changed. The writability of the repository is determined by the writability of the Sail that this repository operates on.- Specified by:
isWritable
in interfaceRepository
- Throws:
RepositoryException
-
getValueFactory
Description copied from interface:Repository
Gets a ValueFactory for this Repository.- Specified by:
getValueFactory
in interfaceRepository
- Returns:
- A repository-specific ValueFactory.
-
getConnection
Description copied from interface:Repository
Opens a connection to this repository that can be used for querying and updating the contents of the repository. Created connections need to be closed to make sure that any resources they keep hold of are released. The best way to do this is to use a try-with-resources block, as follows:try (RepositoryConnection conn = repository.getConnection()) { // perform operations on the connection }
Note that
RepositoryConnection
is not guaranteed to be thread-safe! The recommended pattern for repository access in a multi-threaded application is to share the Repository object between threads, but have each thread create and use its ownRepositoryConnection
s.- Specified by:
getConnection
in interfaceRepository
- Returns:
- A connection that allows operations on this repository.
- Throws:
RepositoryException
- If something went wrong during the creation of the Connection.
-
toString
-