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 theRepositoryinterface that operates on a (stack of)Sailobject(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
Constructors Constructor Description SailRepository(Sail sail)Creates a new repository object that operates on the supplied Sail.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SailRepositoryConnectiongetConnection()Opens a connection to this repository that can be used for querying and updating the contents of the repository.FilegetDataDir()Get the directory where data and logging for this repository is stored.FederatedServiceResolvergetFederatedServiceResolver()Gets theFederatedServiceResolverused by this client.org.apache.http.client.HttpClientgetHttpClient()HttpClientthat has been assigned or has been used by this object.HttpClientSessionManagergetHttpClientSessionManager()HttpClientSessionManagerthat has been assigned or has been used by this object.SailgetSail()Gets the Sail object that is on top of the Sail stack that this repository operates on.ValueFactorygetValueFactory()Gets a ValueFactory for this Repository.protected voidinitializeInternal()booleanisWritable()Checks whether this repository is writable, i.e.voidsetDataDir(File dataDir)Set the directory where data and logging for this repository is stored.voidsetFederatedServiceResolver(FederatedServiceResolver resolver)Sets theFederatedServiceResolverto use for this client.voidsetHttpClient(org.apache.http.client.HttpClient client)Assign anHttpClientthat this object should use.voidsetHttpClientSessionManager(HttpClientSessionManager client)Assign anHttpClientSessionManagerthat this object should use.voidsetRepositoryResolver(RepositoryResolver resolver)protected voidshutDownInternal()StringtoString()-
Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
init, isInitialized, shutDown
-
-
-
-
Constructor Detail
-
SailRepository
public SailRepository(Sail sail)
Creates a new repository object that operates on the supplied Sail.- Parameters:
sail- A Sail object.
-
-
Method Detail
-
getDataDir
public File getDataDir()
Description copied from interface:RepositoryGet the directory where data and logging for this repository is stored.- Specified by:
getDataDirin interfaceRepository- Returns:
- the directory where data for this repository is stored.
-
setDataDir
public void setDataDir(File dataDir)
Description copied from interface:RepositorySet the directory where data and logging for this repository is stored.- Specified by:
setDataDirin interfaceRepository- Parameters:
dataDir- the directory where data for this repository is stored
-
setFederatedServiceResolver
public void setFederatedServiceResolver(FederatedServiceResolver resolver)
Description copied from interface:FederatedServiceResolverClientSets theFederatedServiceResolverto use for this client.- Specified by:
setFederatedServiceResolverin interfaceFederatedServiceResolverClient- Parameters:
resolver- The resolver to use.
-
getFederatedServiceResolver
public FederatedServiceResolver getFederatedServiceResolver()
Description copied from interface:FederatedServiceResolverClientGets theFederatedServiceResolverused by this client.- Specified by:
getFederatedServiceResolverin interfaceFederatedServiceResolverClient
-
setRepositoryResolver
public void setRepositoryResolver(RepositoryResolver resolver)
- Specified by:
setRepositoryResolverin interfaceRepositoryResolverClient
-
getHttpClientSessionManager
public HttpClientSessionManager getHttpClientSessionManager()
Description copied from interface:SessionManagerDependentHttpClientSessionManagerthat 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 whetherHttpClientSessionManagerwas passed to or created by this object respectively.- Specified by:
getHttpClientSessionManagerin interfaceSessionManagerDependent- Returns:
- a
HttpClientSessionManagerinstance or null
-
setHttpClientSessionManager
public void setHttpClientSessionManager(HttpClientSessionManager client)
Description copied from interface:SessionManagerDependentAssign anHttpClientSessionManagerthat this object should use. The life cycle of the givenHttpClientSessionManageris 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:
setHttpClientSessionManagerin interfaceSessionManagerDependent
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
Description copied from interface:HttpClientDependentHttpClientthat 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 whetherHttpClientwas passed to or created by this object respectively.- Specified by:
getHttpClientin interfaceHttpClientDependent- Returns:
- an
HttpClientinstance or null
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient client)
Description copied from interface:HttpClientDependentAssign anHttpClientthat this object should use. The life cycle of the givenHttpClientis 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:
setHttpClientin interfaceHttpClientDependent
-
initializeInternal
protected void initializeInternal() throws RepositoryException- Specified by:
initializeInternalin classAbstractRepository- Throws:
RepositoryException
-
shutDownInternal
protected void shutDownInternal() throws RepositoryException- Specified by:
shutDownInternalin classAbstractRepository- Throws:
RepositoryException
-
getSail
public Sail getSail()
Gets the Sail object that is on top of the Sail stack that this repository operates on.- Returns:
- A Sail object.
-
isWritable
public boolean isWritable() throws RepositoryExceptionDescription copied from interface:RepositoryChecks 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:
isWritablein interfaceRepository- Throws:
RepositoryException
-
getValueFactory
public ValueFactory getValueFactory()
Description copied from interface:RepositoryGets a ValueFactory for this Repository.- Specified by:
getValueFactoryin interfaceRepository- Returns:
- A repository-specific ValueFactory.
-
getConnection
public SailRepositoryConnection getConnection() throws RepositoryException
Description copied from interface:RepositoryOpens 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
RepositoryConnectionis 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 ownRepositoryConnections.- Specified by:
getConnectionin interfaceRepository- Returns:
- A connection that allows operations on this repository.
- Throws:
RepositoryException- If something went wrong during the creation of the Connection.
-
-