public class SailRepository extends AbstractRepository implements FederatedServiceResolverClient, RepositoryResolverClient, HttpClientDependent, SessionManagerDependent
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();
logger
Constructor and Description |
---|
SailRepository(Sail sail)
Creates a new repository object that operates on the supplied Sail.
|
Modifier and Type | Method and Description |
---|---|
SailRepositoryConnection |
getConnection()
Opens a connection to this repository that can be used for querying and updating the contents of the repository.
|
File |
getDataDir()
Get the directory where data and logging for this repository is stored.
|
org.apache.http.client.HttpClient |
getHttpClient()
HttpClient that has been assigned or has been used by this object. |
HttpClientSessionManager |
getHttpClientSessionManager()
HttpClientSessionManager that has been assigned or has been used by this object. |
Sail |
getSail()
Gets the Sail object that is on top of the Sail stack that this repository operates on.
|
ValueFactory |
getValueFactory()
Gets a ValueFactory for this Repository.
|
protected void |
initializeInternal() |
boolean |
isWritable()
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 |
setFederatedServiceResolver(FederatedServiceResolver resolver)
Sets the
FederatedServiceResolver to use for this client. |
void |
setHttpClient(org.apache.http.client.HttpClient client)
Assign an
HttpClient that this object should use. |
void |
setHttpClientSessionManager(HttpClientSessionManager client)
Assign an
HttpClientSessionManager that this object should use. |
void |
setRepositoryResolver(RepositoryResolver resolver) |
protected void |
shutDownInternal() |
String |
toString() |
init, initialize, isInitialized, shutDown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSesameClient, setSesameClient
public SailRepository(Sail sail)
sail
- A Sail object.public File getDataDir()
Repository
getDataDir
in interface Repository
public void setDataDir(File dataDir)
Repository
setDataDir
in interface Repository
dataDir
- the directory where data for this repository is storedpublic void setFederatedServiceResolver(FederatedServiceResolver resolver)
FederatedServiceResolverClient
FederatedServiceResolver
to use for this client.setFederatedServiceResolver
in interface FederatedServiceResolverClient
resolver
- The resolver to use.public void setRepositoryResolver(RepositoryResolver resolver)
setRepositoryResolver
in interface RepositoryResolverClient
public HttpClientSessionManager getHttpClientSessionManager()
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 whether HttpClientSessionManager
was passed to or
created by this object respectively.getHttpClientSessionManager
in interface SesameClientDependent
getHttpClientSessionManager
in interface SessionManagerDependent
HttpClientSessionManager
instance or nullpublic void setHttpClientSessionManager(HttpClientSessionManager client)
SessionManagerDependent
HttpClientSessionManager
that this object should use. The life cycle of the given
HttpClientSessionManager
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.setHttpClientSessionManager
in interface SesameClientDependent
setHttpClientSessionManager
in interface SessionManagerDependent
public org.apache.http.client.HttpClient getHttpClient()
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 whether HttpClient
was passed to or created by this object
respectively.getHttpClient
in interface HttpClientDependent
HttpClient
instance or nullpublic void setHttpClient(org.apache.http.client.HttpClient client)
HttpClientDependent
HttpClient
that this object should use. The life cycle of the given HttpClient
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.setHttpClient
in interface HttpClientDependent
protected void initializeInternal() throws RepositoryException
initializeInternal
in class AbstractRepository
RepositoryException
protected void shutDownInternal() throws RepositoryException
shutDownInternal
in class AbstractRepository
RepositoryException
public Sail getSail()
public boolean isWritable() throws RepositoryException
Repository
isWritable
in interface Repository
RepositoryException
public ValueFactory getValueFactory()
Repository
getValueFactory
in interface Repository
public SailRepositoryConnection getConnection() throws RepositoryException
Repository
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 own RepositoryConnection
s.getConnection
in interface Repository
RepositoryException
- If something went wrong during the creation of the Connection.Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.