public class SailRepository extends RepositoryBase implements FederatedServiceResolverClient, RepositoryResolverClient, HttpClientDependent, SesameClientDependent
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();
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. |
Sail |
getSail()
Gets the Sail object that is on top of the Sail stack that this repository
operates on.
|
SesameClient |
getSesameClient()
SesameClient that has been assigned or has been used by this
object. |
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 |
setRepositoryResolver(RepositoryResolver resolver) |
void |
setSesameClient(SesameClient client)
Assign an
SesameClient that this object should use. |
protected void |
shutDownInternal() |
String |
toString() |
initialize, isInitialized, shutDown
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 SesameClient getSesameClient()
SesameClientDependent
SesameClient
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 SesameClient
was passed to or created by this
object respectively.getSesameClient
in interface SesameClientDependent
SesameClient
instance or nullpublic void setSesameClient(SesameClient client)
SesameClientDependent
SesameClient
that this object should use. The life cycle
of the given SesameClient
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.setSesameClient
in interface SesameClientDependent
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 RepositoryBase
RepositoryException
protected void shutDownInternal() throws RepositoryException
shutDownInternal
in class RepositoryBase
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
Connection con = repository.getConnection(); try { // perform operations on the connection } finally { con.close(); }Note that
RepositoryConnection
is not guaranteed to be
thread-safe! The recommended pattern for repository access in a
multithreaded 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 © 2001-2016 Aduna. All Rights Reserved.